Exemple #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']
Exemple #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']
Exemple #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)
Exemple #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']
Exemple #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']
Exemple #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
Exemple #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']
Exemple #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)
                         ])
Exemple #9
0
 def test_create_failed_subtitle(self):
     with pytest.raises(AssertionError):
         TemplateElement(self.mock_title, subtitle='#' * 81)
Exemple #10
0
 def test_create_failed_title(self):
     with pytest.raises(AssertionError):
         TemplateElement('#' * 81)
Exemple #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
Exemple #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
Exemple #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']
Exemple #14
0
    def test_create_minimal(self):
        e = TemplateElement(self.mock_title)

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

        assert 1 == len(gt.elements)