diff --git a/tests/resources/fixtures/mediaGetMediaResponse.json b/tests/resources/fixtures/mediaGetMediaResponse.json new file mode 100644 index 00000000..748fbbf4 --- /dev/null +++ b/tests/resources/fixtures/mediaGetMediaResponse.json @@ -0,0 +1,9 @@ +{ + "api_id": "292437c0-e5a3-11e9-b521-0242ac110003", + "content_type": "image/gif", + "file_name": "SampleFile.png", + "media_id": "91f8f9ce-e236-474f-a2b8-f75d9c35988a", + "size": 700670, + "upload_time": "2020-02-17T07:53:36.643522Z", + "media_url": "https://media.plivo.com/Account/MAODZKMDFJMJU3MTEYNG/Media/91f8f9ce-e236-474f-a2b8-f75d9c35988a" +} diff --git a/tests/resources/fixtures/mediaListResponse.json b/tests/resources/fixtures/mediaListResponse.json index ac77bd16..f4b97e78 100644 --- a/tests/resources/fixtures/mediaListResponse.json +++ b/tests/resources/fixtures/mediaListResponse.json @@ -1,5 +1,12 @@ { "api_id": "95e98e4a-e5a4-11e9-b521-0242ac110003", + "meta": { + "limit": 20, + "next": "/v1/Account//Media?offset=20&limit=20", + "offset": 0, + "previous": "/v1/Account//Media?offset=0&limit=20", + "total_count": 44 + }, "objects": [{ "content_type": "image/gif", "media_id": "91f8f9ce-e236-474f-a2b8-f75d9c35988a", @@ -15,4 +22,4 @@ "size": 47343 } ] -} \ No newline at end of file +} diff --git a/tests/resources/fixtures/mediaResponse.json b/tests/resources/fixtures/mediaResponse.json deleted file mode 100644 index 81baca60..00000000 --- a/tests/resources/fixtures/mediaResponse.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "api_id": "292437c0-e5a3-11e9-b521-0242ac110003", - "content_type": "image/gif", - "media_id": "91f8f9ce-e236-474f-a2b8-f75d9c35988a", - "media_url": "http://127.0.0.1:80/media/MAODZKMDFJMJU3MTEYNG/f734eeec-e59f-11e9-89dc-0242ac110003/91f8f9ce-e236-474f-a2b8-f75d9c35988a", - "message_uuid": "f734eeec-e59f-11e9-89dc-0242ac110003", - "size": 766424 -} \ No newline at end of file diff --git a/tests/resources/fixtures/messageListMediaResponse.json b/tests/resources/fixtures/messageListMediaResponse.json new file mode 100644 index 00000000..d3f1b14d --- /dev/null +++ b/tests/resources/fixtures/messageListMediaResponse.json @@ -0,0 +1,13 @@ +{ + "api_id": "035eeada-6df1-11e6-b608-06a72a185e87", + "message_uuid": "message_uuid", + "objects": [ + { + "content_type": "application/pdf", + "media_id": "0178eb8a-461a-4fd1-bc37-13eebfdc0676", + "media_url": "https://media.plivo.com/Account/{auth_id}/Message/24d742b9-9b12-4397-93a7-da496bc874d9/Media/0178eb8a-461a-4fd1-bc37-13eebfdc0676", + "message_uuid": "24d742b9-9b12-4397-93a7-da496bc874d9", + "size": 433994 + } + ] +} diff --git a/tests/resources/test_medias.py b/tests/resources/test_medias.py index 29928e1a..5feaab90 100644 --- a/tests/resources/test_medias.py +++ b/tests/resources/test_medias.py @@ -7,7 +7,7 @@ class MediaTest(PlivoResourceTestCase): @with_response(200) def test_get_media(self): media_id = 'media_id' - media = self.client.medias.get(media_id) + media = self.client.media.get(media_id) self.assertResponseMatches(media) self.assertUrlEqual(self.client.current_request.url, self.get_url('Media', media_id)) @@ -15,9 +15,6 @@ def test_get_media(self): @with_response(200) def test_list(self): - media = self.client.medias.list() - # Test if ListResponseObject's __iter__ is working correctly - self.assertEqual(len(list(media)), 20) - self.assertUrlEqual(self.client.current_request.url, - self.get_url('Media')) + media = self.client.media.list() + self.assertEqual(len(list(media)), 2) self.assertEqual(self.client.current_request.method, 'GET') diff --git a/tests/resources/test_messages.py b/tests/resources/test_messages.py index 0dc48766..e872db06 100755 --- a/tests/resources/test_messages.py +++ b/tests/resources/test_messages.py @@ -69,7 +69,7 @@ def test_get(self): self.assertEqual(self.client.current_request.method, 'GET') @with_response(200) - def test_listMedia(self): + def test_list_media(self): message_uuid = 'message_uuid' message = self.client.messages.get(message_uuid).listMedia() self.assertResponseMatches(message) @@ -77,7 +77,6 @@ def test_listMedia(self): self.get_url('Message', message_uuid, 'Media')) self.assertEqual(self.client.current_request.method, 'GET') - @with_response(200, method_name='get') def test_response_has_user_agent(self): message_uuid = 'message_uuid' diff --git a/tox.ini b/tox.ini index bc62b245..73d95397 100755 --- a/tox.ini +++ b/tox.ini @@ -13,7 +13,7 @@ envlist = pypy [testenv] -commands = nosetests --with-coverage --cover-package=plivo --cover-html +commands = nosetests --with-coverage --cover-package=plivo --cover-html {posargs} # tox doesn't install deps automatically after env is created # so some deps are repeated here and in setup.py