|
| 1 | +# coding=utf-8 |
| 2 | +r""" |
| 3 | +This code was generated by |
| 4 | +\ / _ _ _| _ _ |
| 5 | + | (_)\/(_)(_|\/| |(/_ v1.0.0 |
| 6 | + / / |
| 7 | +""" |
| 8 | + |
| 9 | +from tests import IntegrationTestCase |
| 10 | +from tests.holodeck import Request |
| 11 | +from twilio.base.exceptions import TwilioException |
| 12 | +from twilio.http.response import Response |
| 13 | + |
| 14 | + |
| 15 | +class ContentAndApprovalsTestCase(IntegrationTestCase): |
| 16 | + |
| 17 | + def test_list_request(self): |
| 18 | + self.holodeck.mock(Response(500, '')) |
| 19 | + |
| 20 | + with self.assertRaises(TwilioException): |
| 21 | + self.client.content.v1.content_and_approvals.list() |
| 22 | + |
| 23 | + self.holodeck.assert_has_request(Request( |
| 24 | + 'get', |
| 25 | + 'https://content.twilio.com/v1/ContentAndApprovals', |
| 26 | + )) |
| 27 | + |
| 28 | + def test_read_empty_response(self): |
| 29 | + self.holodeck.mock(Response( |
| 30 | + 200, |
| 31 | + ''' |
| 32 | + { |
| 33 | + "contents": [], |
| 34 | + "meta": { |
| 35 | + "page": 0, |
| 36 | + "page_size": 10, |
| 37 | + "first_page_url": "https://content.twilio.com/v1/ContentAndApprovals?PageSize=10&Page=0", |
| 38 | + "previous_page_url": null, |
| 39 | + "next_page_url": null, |
| 40 | + "url": "https://content.twilio.com/v1/ContentAndApprovals?PageSize=10&Page=0", |
| 41 | + "key": "contents" |
| 42 | + } |
| 43 | + } |
| 44 | + ''' |
| 45 | + )) |
| 46 | + |
| 47 | + actual = self.client.content.v1.content_and_approvals.list() |
| 48 | + |
| 49 | + self.assertIsNotNone(actual) |
| 50 | + |
| 51 | + def test_read_results_response(self): |
| 52 | + self.holodeck.mock(Response( |
| 53 | + 200, |
| 54 | + ''' |
| 55 | + { |
| 56 | + "contents": [ |
| 57 | + { |
| 58 | + "date_created": "2015-07-30T19:00:00Z", |
| 59 | + "date_updated": "2015-07-30T19:00:00Z", |
| 60 | + "sid": "HXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", |
| 61 | + "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", |
| 62 | + "friendly_name": "Some content", |
| 63 | + "language": "en", |
| 64 | + "variables": { |
| 65 | + "name": "foo" |
| 66 | + }, |
| 67 | + "types": { |
| 68 | + "twilio/text": { |
| 69 | + "body": "Foo Bar Co is located at 39.7392, 104.9903" |
| 70 | + }, |
| 71 | + "twilio/location": { |
| 72 | + "longitude": 104.9903, |
| 73 | + "latitude": 39.7392, |
| 74 | + "label": "Foo Bar Co" |
| 75 | + } |
| 76 | + }, |
| 77 | + "approval_requests": { |
| 78 | + "name": "", |
| 79 | + "category": "", |
| 80 | + "content_type": "", |
| 81 | + "status": "unsubmitted", |
| 82 | + "rejection_reason": "", |
| 83 | + "allow_category_change": true |
| 84 | + } |
| 85 | + }, |
| 86 | + { |
| 87 | + "language": "en", |
| 88 | + "date_updated": "2023-01-13T23:33:46Z", |
| 89 | + "variables": { |
| 90 | + "1": "name", |
| 91 | + "2": "typedocument" |
| 92 | + }, |
| 93 | + "friendly_name": "Media Test", |
| 94 | + "account_sid": "AC25c0d4b9093547216c460212e24e77ee", |
| 95 | + "sid": "HX5fcd48a417c1cb59da349ad6d5da4607", |
| 96 | + "date_created": "2023-01-13T23:33:46Z", |
| 97 | + "types": { |
| 98 | + "twilio/media": { |
| 99 | + "body": "{{1}}, Congratulations {{2}}! For additional assistance, please contact us at [email protected]", |
| 100 | + "media": [ |
| 101 | + "https://example.com/template" |
| 102 | + ] |
| 103 | + } |
| 104 | + }, |
| 105 | + "approval_requests": { |
| 106 | + "category": "TRANSACTIONAL", |
| 107 | + "status": "approved", |
| 108 | + "rejection_reason": "", |
| 109 | + "name": "Media Test", |
| 110 | + "content_type": "twilio/media", |
| 111 | + "allow_category_change": false |
| 112 | + } |
| 113 | + }, |
| 114 | + { |
| 115 | + "language": "en", |
| 116 | + "date_updated": "2023-01-18T02:46:35Z", |
| 117 | + "variables": { |
| 118 | + "1": "name", |
| 119 | + "2": "type_video", |
| 120 | + "3": "small.mp4" |
| 121 | + }, |
| 122 | + "friendly_name": "Video Highlights", |
| 123 | + "account_sid": "AC25c0d4b9093547216c460212e24e77ee", |
| 124 | + "sid": "HX15c711fcc6d9ea5268d7ab77938a20ff", |
| 125 | + "date_created": "2023-01-18T02:46:35Z", |
| 126 | + "types": { |
| 127 | + "twilio/media": { |
| 128 | + "body": "Hi there, {{1}}, we have received your request to upload {{2}}, and should be uploaded shortly.", |
| 129 | + "media": [ |
| 130 | + "http://example.com/highlights/{{3}}" |
| 131 | + ] |
| 132 | + } |
| 133 | + }, |
| 134 | + "approval_requests": { |
| 135 | + "category": "TRANSACTIONAL", |
| 136 | + "status": "rejected", |
| 137 | + "rejection_reason": "INVALID_FORMAT. Facebook is not able to create template with templateName=Video Highlights_hx15c711fcc6d9ea5268d7ab77938a20ff due to the following error: Invalid parameter. More Details: Message template 'components' param is missing expected field(s). component of type HEADER is missing expected field(s) (example)", |
| 138 | + "name": "Video Highlights", |
| 139 | + "content_type": "twilio/media", |
| 140 | + "allow_category_change": true |
| 141 | + } |
| 142 | + } |
| 143 | + ], |
| 144 | + "meta": { |
| 145 | + "page": 0, |
| 146 | + "page_size": 20, |
| 147 | + "first_page_url": "https://content.twilio.com/v1/ContentAndApprovals?PageSize=20&Page=0", |
| 148 | + "url": "https://content.twilio.com/v1/ContentAndApprovals?PageSize=20&Page=0", |
| 149 | + "previous_page_url": null, |
| 150 | + "next_page_url": null, |
| 151 | + "key": "contents" |
| 152 | + } |
| 153 | + } |
| 154 | + ''' |
| 155 | + )) |
| 156 | + |
| 157 | + actual = self.client.content.v1.content_and_approvals.list() |
| 158 | + |
| 159 | + self.assertIsNotNone(actual) |
0 commit comments