Skip to content

Commit

Permalink
Merge pull request #132 from plivo/ppai-fix-mms-tests
Browse files Browse the repository at this point in the history
tests: Fix MMS unit tests
  • Loading branch information
nixonsam authored Jun 12, 2020
2 parents 5a420ac + e4ccbe4 commit df33a46
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 18 deletions.
9 changes: 9 additions & 0 deletions tests/resources/fixtures/mediaGetMediaResponse.json
Original file line number Diff line number Diff line change
@@ -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"
}
9 changes: 8 additions & 1 deletion tests/resources/fixtures/mediaListResponse.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"api_id": "95e98e4a-e5a4-11e9-b521-0242ac110003",
"meta": {
"limit": 20,
"next": "/v1/Account/<auth_id>/Media?offset=20&limit=20",
"offset": 0,
"previous": "/v1/Account/<auth_id>/Media?offset=0&limit=20",
"total_count": 44
},
"objects": [{
"content_type": "image/gif",
"media_id": "91f8f9ce-e236-474f-a2b8-f75d9c35988a",
Expand All @@ -15,4 +22,4 @@
"size": 47343
}
]
}
}
8 changes: 0 additions & 8 deletions tests/resources/fixtures/mediaResponse.json

This file was deleted.

13 changes: 13 additions & 0 deletions tests/resources/fixtures/messageListMediaResponse.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
9 changes: 3 additions & 6 deletions tests/resources/test_medias.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ 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))
self.assertEqual(self.client.current_request.method, 'GET')

@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')
3 changes: 1 addition & 2 deletions tests/resources/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,14 @@ 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)
self.assertUrlEqual(self.client.current_request.url,
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'
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit df33a46

Please sign in to comment.