Skip to content

Commit

Permalink
powerpack: Fix unit tests
Browse files Browse the repository at this point in the history
Most of existing powerpack unit tests are in a bad state and look like
they have been written for the sake of it or to increase coverage
metric.

This commit makes symptomatic fixes to ensure that unit tests pass.

Signed-off-by: Prashanth Pai <prashanth.pai@plivo.com>
  • Loading branch information
ppai-plivo committed Jun 12, 2020
1 parent df33a46 commit 51afd0f
Show file tree
Hide file tree
Showing 19 changed files with 327 additions and 27 deletions.
4 changes: 2 additions & 2 deletions plivo/resources/numberpools.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, client, number_pool_id):


class Numbers(PlivoResource):
_name = 'Shortcodes'
_name = 'Numbers'
_identifier_string = 'number_pool_id'

def buy_add_number(self,
Expand Down Expand Up @@ -240,4 +240,4 @@ def remove(self, tollfree, unrent=False):
'DELETE', ('NumberPool',self.number_pool_id,'Tollfree', tollfree), params,
response_type=None,
objects_type=None)

11 changes: 11 additions & 0 deletions tests/resources/fixtures/powerpackAddNumberResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"account_phone_number_resource": "/v1/Account/<auth_id>/Number/<your_number>/",
"added_on": "2019-10-09T11:24:35.085797Z",
"api_id": "612982e8-0a87-11ea-b072-0242ac110007",
"country_iso2": "CA",
"number": "15799140336",
"uuid": "ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f",
"number_pool_uuid": "ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f",
"number_pool": "/v1/Account/MAODZKMDFJMJU3MTEYNG/NumberPool/ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f/",
"type": "fixed"
}
11 changes: 11 additions & 0 deletions tests/resources/fixtures/powerpackAddTollfreeResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"account_phone_number_resource": "/v1/Account/<auth_id>/Number/<your_number>/",
"added_on": "2019-10-09T11:24:35.085797Z",
"api_id": "612982e8-0a87-11ea-b072-0242ac110007",
"country_iso2": "CA",
"number": "15799140336",
"uuid": "ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f",
"number_pool_uuid": "ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f",
"number_pool": "/v1/Account/MAODZKMDFJMJU3MTEYNG/NumberPool/ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f/",
"type": "fixed"
}
11 changes: 11 additions & 0 deletions tests/resources/fixtures/powerpackBuyAndNumberResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"account_phone_number_resource": "/v1/Account/<auth_id>/Number/<your_number>/",
"added_on": "2019-10-09T11:24:35.085797Z",
"api_id": "612982e8-0a87-11ea-b072-0242ac110007",
"country_iso2": "CA",
"number": "14845071864",
"uuid": "ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f",
"number_pool_uuid": "ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f",
"number_pool": "/v1/Account/MAODZKMDFJMJU3MTEYNG/NumberPool/ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f/",
"type": "fixed"
}
43 changes: 43 additions & 0 deletions tests/resources/fixtures/powerpackCountNumbersResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"account_phone_number_resource": "/v1/Account/<auth_id>/Number/<your_number>/",
"added_on": "2019-10-09T11:24:35.085797Z",
"api_id": "612982e8-0a87-11ea-b072-0242ac110007",
"country_iso2": "CA",
"uuid": "ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f",
"number_pool_uuid": "ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f",
"number_pool": "/v1/Account/MAODZKMDFJMJU3MTEYNG/NumberPool/ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f/",
"api_id": "0dacbefa-0a87-11ea-b072-0242ac110007",
"meta": {
"limit": 20,
"next": "",
"offset": 0,
"previous": "",
"total_count": 6
},
"objects": [
{
"account_phone_number_resource": "/v1/Account/{auth_id}/Number/{your_number}/",
"added_on": "2019-10-09T11:24:35.085797Z",
"country_iso2": "US",
"number": "{your_number}",
"number_pool_uuid": "{number_pool_uuid}",
"type": "fixed"
},
{
"account_phone_number_resource": "/v1/Account/{auth_id}/Number/{your_number}/",
"added_on": "2019-10-09T11:24:35.085797Z",
"country_iso2": "US",
"number": "{your_number}",
"number_pool_uuid": "{number_pool_uuid}",
"type": "fixed"
},
{
"account_phone_number_resource": "/v1/Account/{auth_id}/Number/{your_number}/",
"added_on": "2019-10-09T11:24:35.085797Z",
"country_iso2": "CA",
"number": "{your_number}",
"number_pool_uuid": "{number_pool_uuid}",
"type": "fixed"
}
]
}
11 changes: 11 additions & 0 deletions tests/resources/fixtures/powerpackCreatePowerpackResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"api_id": "4b2c83c4-09ff-11ea-b072-0242ac110007",
"application_id": "20342783288007824",
"application_type": "XML",
"created_on": "2019-10-09T11:10:59.666461Z",
"local_connect": true,
"name": "test",
"number_pool": "/v1/Account/{auth_id}/NumberPool/<number_pool_uuid>/",
"sticky_sender": true,
"uuid": "<powerpack_uuid>"
}
10 changes: 10 additions & 0 deletions tests/resources/fixtures/powerpackDeletePowerpackResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"uuid": "dfsd-fsdfsd-345dfsd-fsdfs-sdfsd",
"name": "My Powerpack",
"smart_sender": true,
"local_connect": false,
"application_type": "XML",
"application_id": 123912833468,
"number_pool": "/v1/Account/{auth_id}/NumberPool/<number_pool_uuid>/",
"created_on": "2019-07-15T12:22:00Z"
}
20 changes: 20 additions & 0 deletions tests/resources/fixtures/powerpackFindShortcodeResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"api_id": "614b2776-0a88-11ea-b072-0242ac110007",
"number_pool": "/v1/Account/{auth_id}/NumberPool/<number_pool_uuid>/",
"uuid": "dfsd-fsdfsd-345dfsd-fsdfs-sdfsd",
"meta": {
"limit": 20,
"next": "",
"offset": 0,
"previous": "",
"total_count": 1
},
"objects": [
{
"added_on": "2019-10-09T11:10:59.741978Z",
"country_iso2": "US",
"number_pool_uuid": "{number_pool_uuid}",
"shortcode": "444444"
}
]
}
20 changes: 20 additions & 0 deletions tests/resources/fixtures/powerpackFindTollfreeResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"api_id": "614b2776-0a88-11ea-b072-0242ac110007",
"number_pool": "/v1/Account/{auth_id}/NumberPool/<number_pool_uuid>/",
"uuid": "dfsd-fsdfsd-345dfsd-fsdfs-sdfsd",
"meta": {
"limit": 20,
"next": "",
"offset": 0,
"previous": "",
"total_count": 1
},
"objects": [
{
"added_on": "2019-10-09T11:10:59.741978Z",
"country_iso2": "US",
"number_pool_uuid": "{number_pool_uuid}",
"tollfree": "18772209942"
}
]
}
10 changes: 10 additions & 0 deletions tests/resources/fixtures/powerpackGetPowerpackResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"uuid": "5ec4c8c9-cd74-42b5-9e41-0d7670d6bb46",
"name": "My Powerpack",
"smart_sender": true,
"local_connect": false,
"application_type": "XML",
"application_id": 123912833468,
"number_pool": "/v1/Account/{auth_id}/NumberPool/<number_pool_uuid>/",
"created_on": "2019-07-15T12:22:00Z"
}
38 changes: 38 additions & 0 deletions tests/resources/fixtures/powerpackListNumbersResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"api_id": "0dacbefa-0a87-11ea-b072-0242ac110007",
"uuid": "d35f2e82-d387-427f-8594-6fa07613c43a",
"number_pool": "/v1/Account/{auth_id}/NumberPool/d35f2e82-d387-427f-8594-6fa07613c43a/",
"meta": {
"limit": 20,
"next": "",
"offset": 0,
"previous": "",
"total_count": 3
},
"objects": [
{
"account_phone_number_resource": "/v1/Account/{auth_id}/Number/{your_number}/",
"added_on": "2019-10-09T11:24:35.085797Z",
"country_iso2": "US",
"number": "{your_number}",
"number_pool_uuid": "d35f2e82-d387-427f-8594-6fa07613c43a",
"type": "fixed"
},
{
"account_phone_number_resource": "/v1/Account/{auth_id}/Number/{your_number}/",
"added_on": "2019-10-09T11:24:35.085797Z",
"country_iso2": "US",
"number": "{your_number}",
"number_pool_uuid": "d35f2e82-d387-427f-8594-6fa07613c43a",
"type": "fixed"
},
{
"account_phone_number_resource": "/v1/Account/{auth_id}/Number/{your_number}/",
"added_on": "2019-10-09T11:24:35.085797Z",
"country_iso2": "CA",
"number": "{your_number}",
"number_pool_uuid": "d35f2e82-d387-427f-8594-6fa07613c43a",
"type": "fixed"
}
]
}
41 changes: 41 additions & 0 deletions tests/resources/fixtures/powerpackListPowerpackResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"api_id": "e44c159e-0a02-11ea-b072-0242ac110007",
"meta": {
"limit": 20,
"next": "/api/v1/account/xxxxxxx/Powerpack?offset=20&limit=20",
"offset": 0,
"total_count": 53
},
"objects": [
{
"application_id": "",
"application_type": "",
"created_on": "2019-10-09T11:10:59.666461Z",
"local_connect": true,
"name": "test",
"number_pool": "/v1/Account/xxxxxxxxx/NumberPool/<number_pool_uuid>/",
"sticky_sender": true,
"uuid": "<powerpack_uuid>"
},
{
"application_id": "",
"application_type": "",
"created_on": "2019-10-09T17:03:31.837944Z",
"local_connect": false,
"name": "p23",
"number_pool": "/v1/Account/xxxxxxxx/NumberPool/<number_pool_uuid>/",
"sticky_sender": false,
"uuid": "<powerpack_uuid>"
},
{
"application_id": "",
"application_type": "",
"created_on": "2019-10-09T16:54:34.0117Z",
"local_connect": false,
"name": "p22",
"number_pool": "/v1/Account/xxxxxxxx/NumberPool/<number_pool_uuid>/",
"sticky_sender": false,
"uuid": "<powerpack_uuid>"
}
]
}
20 changes: 20 additions & 0 deletions tests/resources/fixtures/powerpackListShortcodeResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"api_id": "614b2776-0a88-11ea-b072-0242ac110007",
"uuid": "ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f",
"number_pool": "/v1/Account/xxxxxxxxx/NumberPool/ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f/",
"meta": {
"limit": 20,
"offset": 0,
"next": "",
"previous": "",
"total_count": 1
},
"objects": [
{
"added_on": "2019-10-09T11:10:59.741978Z",
"country_iso2": "US",
"number_pool_uuid": "ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f",
"shortcode": "{your_shortcode}"
}
]
}
20 changes: 20 additions & 0 deletions tests/resources/fixtures/powerpackListTollfreeResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"api_id": "614b2776-0a88-11ea-b072-0242ac110007",
"uuid": "ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f",
"number_pool": "/v1/Account/xxxxxxxxx/NumberPool/ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f/",
"meta": {
"limit": 20,
"offset": 0,
"next": "",
"previous": "",
"total_count": 1
},
"objects": [
{
"added_on": "2019-10-09T11:10:59.741978Z",
"country_iso2": "US",
"number_pool_uuid": "ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f",
"tollfree": "{your_tollfree}"
}
]
}
10 changes: 10 additions & 0 deletions tests/resources/fixtures/powerpackRemoveNumberResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"uuid": "d35f2e82-d387-427f-8594-6fa07613c43a",
"name": "My Powerpack",
"smart_sender": true,
"local_connect": false,
"application_type": "XML",
"application_id": 123912833468,
"number_pool": "/v1/Account/{auth_id}/NumberPool/<number_pool_uuid>/",
"created_on": "2019-07-15T12:22:00Z"
}
10 changes: 10 additions & 0 deletions tests/resources/fixtures/powerpackRemoveShortcodeResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"uuid": "d35f2e82-d387-427f-8594-6fa07613c43a",
"name": "My Powerpack",
"smart_sender": true,
"local_connect": false,
"application_type": "XML",
"application_id": 123912833468,
"number_pool": "/v1/Account/{auth_id}/NumberPool/<number_pool_uuid>/",
"created_on": "2019-07-15T12:22:00Z"
}
10 changes: 10 additions & 0 deletions tests/resources/fixtures/powerpackRemoveTollfreeResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"uuid": "d35f2e82-d387-427f-8594-6fa07613c43a",
"name": "My Powerpack",
"smart_sender": true,
"local_connect": false,
"application_type": "XML",
"application_id": 123912833468,
"number_pool": "/v1/Account/{auth_id}/NumberPool/<number_pool_uuid>/",
"created_on": "2019-07-15T12:22:00Z"
}
12 changes: 12 additions & 0 deletions tests/resources/fixtures/powerpackUpdatePowerpackResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"api_id": "4b2c83c4-09ff-11ea-b072-0242ac110007",
"uuid": "d35f2e82-d387-427f-8594-6fa07613c43a",
"application_id": "20342783288007824",
"application_type": "XML",
"created_on": "2019-10-09T11:10:59.666461Z",
"local_connect": true,
"name": "test",
"number_pool": "/v1/Account/{auth_id}/NumberPool/d35f2e82-d387-427f-8594-6fa07613c43a/",
"sticky_sender": true,
"uuid": "<powerpack_uuid>"
}
Loading

0 comments on commit 51afd0f

Please sign in to comment.