from adaptivecard import AdaptiveCard
from adaptivecard.containers import Container, ColumnSet, Column, Table, TableRow
from adaptivecard.card_elements import TextBlock, Image
from adaptivecard.inputs import Text, Time, ChoiceSet, Choice
from adaptivecard.types import Backgroundimage

class Test:
    def test_message(self):
        card = AdaptiveCard()
        container = Container(style='warning', bleed=True, min_height=10)
        columns = [Column([1,1,1]), Column([2,2,2])]
        column_set = ColumnSet((columns), style='warning', min_height=8, height='auto')
        bg_image = Backgroundimage(
            url="https://images.ctfassets.net/sfnkq8lmu5d7/4Ma58uke8SXDQLWYefWiIt/3f1945422ea07ea6520c7aae39180101/2021-11-24_Singleton_Puppy_Syndrome_One_Puppy_Litter.jpg?w=1000&h=750&fl=progressive&q=70&fm=jpg",
            fill_mode="cover",
            horizontal_alignment="center"
        )
        column_set[0].background_image = bg_image
        container.append(column_set)
        card.append(container)
        container_2 = Container()
        table = Table(first_row_as_header=True)
        table.append([1, 2, TextBlock("header", style='heading', weight='bolder')])
        row_2 = TableRow([4,5,6])
        table.append(row_2)
        assert table[1][0][0].text == "4"
        table[1][0] = 100
        assert table[1][0][0].text == "100"
        container_2.append(table)
        card.append(container_2)
        img = Image("https://hips.hearstapps.com/hmg-prod/images/dog-puppy-on-garden-royalty-free-image-1586966191.jpg?crop=1xw:0.74975xh;center,top&resize=1200:*",
                    size='medium', style='person', separator=True, height=70)
        card.append(img)
        text_input = Text(id="text input id")
        time_input = Time(id="time id")
        card.append(text_input)
        card.append(time_input)
        choice_set = ChoiceSet(id="choice set id")
        choice = Choice(title="some title", value="value1")
        choice_set.append(choice)
        card.append(choice_set)
        msg = card.to_message()
        json = msg.to_dict()
        assert isinstance(json, dict)