def test_set_image_with_deprecation_warning(self, image_url): card_obj = Card() with pytest.warns(DeprecationWarning): card_obj.set_image(image_url) assert card_obj.image_url == image_url
def test_set_buttons_with_deprecation_warning(self, buttons): card_obj = Card() with pytest.warns(DeprecationWarning): card_obj.set_buttons(buttons) assert card_obj.buttons == buttons
def test_set_subtitle_with_deprecation_warning(self, subtitle): card_obj = Card() with pytest.warns(DeprecationWarning): card_obj.set_subtitle(subtitle) assert card_obj.subtitle == subtitle
def test_as_dict(self, title, subtitle, image_url, buttons): card_obj = Card(title=title, subtitle=subtitle, image_url=image_url, buttons=buttons) assert card_obj._as_dict() == { 'card': { 'title': title, 'subtitle': subtitle, 'imageUri': image_url, 'buttons': buttons } }
def test_button_empty_params(self): card_obj = Card(buttons=[{}]) assert card_obj._as_dict() == {'card': {'buttons': [{}]}}
def test_button_postback_non_string(self): with pytest.raises(TypeError): Card(buttons=[{'postback': ['this is not a text']}])
def test_buttons_non_dict(self): with pytest.raises(TypeError): Card(buttons=['this is not a button'])
def test_buttons_non_list(self): with pytest.raises(TypeError): Card(buttons='this is not a list of buttons')
def test_image_url_non_string(self): with pytest.raises(TypeError): Card(image_url={'this': ['is not a string']})
def test_subtitle_non_string(self): with pytest.raises(TypeError): Card(subtitle={'this': ['is not a string']})
def test_empty_params(self): card_obj = Card() assert card_obj._as_dict() == {'card': {}}