Esempio n. 1
0
    def test_to_dict_with_image_url(self):
        e = TemplateElement(self.mock_title, image_url=self.mock_image_url)

        e_dict = e.to_dict()

        assert self.mock_title == e_dict['title']
        assert self.mock_image_url == e_dict['image_url']
Esempio n. 2
0
    def test_to_dict_with_subtitle(self):
        e = TemplateElement(self.mock_title, subtitle=self.mock_subtitle)

        e_dict = e.to_dict()

        assert self.mock_title == e_dict['title']
        assert self.mock_subtitle == e_dict['subtitle']
Esempio n. 3
0
    def test_create_multiple_elements(self):
        gt = GenericTemplate(elements=[
            TemplateElement(self.mock_first_element_title),
            TemplateElement(self.mock_second_element_title)
        ])

        assert 2 == len(gt.elements)
Esempio n. 4
0
    def test_to_dict_with_button(self):
        mock_button_title, mock_button_url = 'mock-button-title', 'test://mock-button-url/'
        e = TemplateElement(
            self.mock_title,
            buttons=[UrlButton(mock_button_title, mock_button_url)])

        e_dict = e.to_dict()

        assert self.mock_title == e_dict['title']
        assert mock_button_title == e_dict['buttons'][0]['title']
        assert mock_button_url == e_dict['buttons'][0]['url']
Esempio n. 5
0
    def test_to_dict_multiple_elements(self):
        gt = GenericTemplate(elements=[
            TemplateElement(self.mock_first_element_title),
            TemplateElement(self.mock_second_element_title)
        ])

        gt_dict = gt.to_dict()

        assert 2 == len(gt_dict['payload']['elements'])
        assert self.mock_first_element_title == gt_dict['payload']['elements'][
            0]['title']
        assert self.mock_second_element_title == gt_dict['payload'][
            'elements'][1]['title']
Esempio n. 6
0
    def test_create_with_button(self):
        mock_button_title, mock_button_url = 'mock-button-title', 'test://mock-button-url/'
        e = TemplateElement(
            self.mock_title,
            buttons=[UrlButton(mock_button_title, mock_button_url)])

        assert self.mock_title == e.title
        assert mock_button_title == e.buttons[0].title
        assert mock_button_url == e.buttons[0].url
Esempio n. 7
0
    def test_to_dict_single_element(self):
        gt = GenericTemplate(
            elements=[TemplateElement(self.mock_first_element_title)])

        gt_dict = gt.to_dict()

        assert 1 == len(gt_dict['payload']['elements'])
        assert self.mock_first_element_title == gt_dict['payload']['elements'][
            0]['title']
Esempio n. 8
0
 def test_create_failed_buttons(self):
     with pytest.raises(AssertionError):
         mock_button_title, mock_button_url = 'mock-button-title', 'test://mock-button-url/'
         TemplateElement(self.mock_title,
                         buttons=[
                             UrlButton(mock_button_title, mock_button_url),
                             UrlButton(mock_button_title, mock_button_url),
                             UrlButton(mock_button_title, mock_button_url),
                             UrlButton(mock_button_title, mock_button_url)
                         ])
Esempio n. 9
0
 def test_create_failed_subtitle(self):
     with pytest.raises(AssertionError):
         TemplateElement(self.mock_title, subtitle='#' * 81)
Esempio n. 10
0
 def test_create_failed_title(self):
     with pytest.raises(AssertionError):
         TemplateElement('#' * 81)
Esempio n. 11
0
    def test_create_with_image_url(self):
        e = TemplateElement(self.mock_title, image_url=self.mock_image_url)

        assert self.mock_title == e.title
        assert self.mock_image_url == e.image_url
Esempio n. 12
0
    def test_create_with_subtitle(self):
        e = TemplateElement(self.mock_title, subtitle=self.mock_subtitle)

        assert self.mock_title == e.title
        assert self.mock_subtitle == e.subtitle
Esempio n. 13
0
    def test_to_dict_minimal(self):
        e = TemplateElement(self.mock_title)

        e_dict = e.to_dict()

        assert self.mock_title == e_dict['title']
Esempio n. 14
0
    def test_create_minimal(self):
        e = TemplateElement(self.mock_title)

        assert self.mock_title == e.title
Esempio n. 15
0
    def test_create_single_element(self):
        gt = GenericTemplate(
            elements=[TemplateElement(self.mock_first_element_title)])

        assert 1 == len(gt.elements)