From 51afd0f71cef3b7b9c7441125b6051a88126826e Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Fri, 5 Jun 2020 15:57:02 +0530 Subject: [PATCH] powerpack: Fix unit tests 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 --- plivo/resources/numberpools.py | 4 +- .../fixtures/powerpackAddNumberResponse.json | 11 +++++ .../powerpackAddTollfreeResponse.json | 11 +++++ .../powerpackBuyAndNumberResponse.json | 11 +++++ .../powerpackCountNumbersResponse.json | 43 +++++++++++++++++++ .../powerpackCreatePowerpackResponse.json | 11 +++++ .../powerpackDeletePowerpackResponse.json | 10 +++++ .../powerpackFindShortcodeResponse.json | 20 +++++++++ .../powerpackFindTollfreeResponse.json | 20 +++++++++ .../powerpackGetPowerpackResponse.json | 10 +++++ .../powerpackListNumbersResponse.json | 38 ++++++++++++++++ .../powerpackListPowerpackResponse.json | 41 ++++++++++++++++++ .../powerpackListShortcodeResponse.json | 20 +++++++++ .../powerpackListTollfreeResponse.json | 20 +++++++++ .../powerpackRemoveNumberResponse.json | 10 +++++ .../powerpackRemoveShortcodeResponse.json | 10 +++++ .../powerpackRemoveTollfreeResponse.json | 10 +++++ .../powerpackUpdatePowerpackResponse.json | 12 ++++++ tests/resources/test_powerpacks.py | 42 ++++++++---------- 19 files changed, 327 insertions(+), 27 deletions(-) create mode 100644 tests/resources/fixtures/powerpackAddNumberResponse.json create mode 100644 tests/resources/fixtures/powerpackAddTollfreeResponse.json create mode 100644 tests/resources/fixtures/powerpackBuyAndNumberResponse.json create mode 100644 tests/resources/fixtures/powerpackCountNumbersResponse.json create mode 100644 tests/resources/fixtures/powerpackCreatePowerpackResponse.json create mode 100644 tests/resources/fixtures/powerpackDeletePowerpackResponse.json create mode 100644 tests/resources/fixtures/powerpackFindShortcodeResponse.json create mode 100644 tests/resources/fixtures/powerpackFindTollfreeResponse.json create mode 100644 tests/resources/fixtures/powerpackGetPowerpackResponse.json create mode 100644 tests/resources/fixtures/powerpackListNumbersResponse.json create mode 100644 tests/resources/fixtures/powerpackListPowerpackResponse.json create mode 100644 tests/resources/fixtures/powerpackListShortcodeResponse.json create mode 100644 tests/resources/fixtures/powerpackListTollfreeResponse.json create mode 100644 tests/resources/fixtures/powerpackRemoveNumberResponse.json create mode 100644 tests/resources/fixtures/powerpackRemoveShortcodeResponse.json create mode 100644 tests/resources/fixtures/powerpackRemoveTollfreeResponse.json create mode 100644 tests/resources/fixtures/powerpackUpdatePowerpackResponse.json diff --git a/plivo/resources/numberpools.py b/plivo/resources/numberpools.py index a20dd220..2bff52de 100644 --- a/plivo/resources/numberpools.py +++ b/plivo/resources/numberpools.py @@ -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, @@ -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) - \ No newline at end of file + diff --git a/tests/resources/fixtures/powerpackAddNumberResponse.json b/tests/resources/fixtures/powerpackAddNumberResponse.json new file mode 100644 index 00000000..2f9c1b3b --- /dev/null +++ b/tests/resources/fixtures/powerpackAddNumberResponse.json @@ -0,0 +1,11 @@ +{ + "account_phone_number_resource": "/v1/Account//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" +} diff --git a/tests/resources/fixtures/powerpackAddTollfreeResponse.json b/tests/resources/fixtures/powerpackAddTollfreeResponse.json new file mode 100644 index 00000000..2f9c1b3b --- /dev/null +++ b/tests/resources/fixtures/powerpackAddTollfreeResponse.json @@ -0,0 +1,11 @@ +{ + "account_phone_number_resource": "/v1/Account//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" +} diff --git a/tests/resources/fixtures/powerpackBuyAndNumberResponse.json b/tests/resources/fixtures/powerpackBuyAndNumberResponse.json new file mode 100644 index 00000000..dfd45e1a --- /dev/null +++ b/tests/resources/fixtures/powerpackBuyAndNumberResponse.json @@ -0,0 +1,11 @@ +{ + "account_phone_number_resource": "/v1/Account//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" +} diff --git a/tests/resources/fixtures/powerpackCountNumbersResponse.json b/tests/resources/fixtures/powerpackCountNumbersResponse.json new file mode 100644 index 00000000..6fd31e1c --- /dev/null +++ b/tests/resources/fixtures/powerpackCountNumbersResponse.json @@ -0,0 +1,43 @@ +{ + "account_phone_number_resource": "/v1/Account//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" + } + ] +} diff --git a/tests/resources/fixtures/powerpackCreatePowerpackResponse.json b/tests/resources/fixtures/powerpackCreatePowerpackResponse.json new file mode 100644 index 00000000..37e7cdf4 --- /dev/null +++ b/tests/resources/fixtures/powerpackCreatePowerpackResponse.json @@ -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//", + "sticky_sender": true, + "uuid": "" +} diff --git a/tests/resources/fixtures/powerpackDeletePowerpackResponse.json b/tests/resources/fixtures/powerpackDeletePowerpackResponse.json new file mode 100644 index 00000000..457c5237 --- /dev/null +++ b/tests/resources/fixtures/powerpackDeletePowerpackResponse.json @@ -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//", + "created_on": "2019-07-15T12:22:00Z" +} diff --git a/tests/resources/fixtures/powerpackFindShortcodeResponse.json b/tests/resources/fixtures/powerpackFindShortcodeResponse.json new file mode 100644 index 00000000..3addf56d --- /dev/null +++ b/tests/resources/fixtures/powerpackFindShortcodeResponse.json @@ -0,0 +1,20 @@ +{ + "api_id": "614b2776-0a88-11ea-b072-0242ac110007", + "number_pool": "/v1/Account/{auth_id}/NumberPool//", + "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" + } + ] +} diff --git a/tests/resources/fixtures/powerpackFindTollfreeResponse.json b/tests/resources/fixtures/powerpackFindTollfreeResponse.json new file mode 100644 index 00000000..fce5d6ca --- /dev/null +++ b/tests/resources/fixtures/powerpackFindTollfreeResponse.json @@ -0,0 +1,20 @@ +{ + "api_id": "614b2776-0a88-11ea-b072-0242ac110007", + "number_pool": "/v1/Account/{auth_id}/NumberPool//", + "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" + } + ] +} diff --git a/tests/resources/fixtures/powerpackGetPowerpackResponse.json b/tests/resources/fixtures/powerpackGetPowerpackResponse.json new file mode 100644 index 00000000..be2f36aa --- /dev/null +++ b/tests/resources/fixtures/powerpackGetPowerpackResponse.json @@ -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//", + "created_on": "2019-07-15T12:22:00Z" +} diff --git a/tests/resources/fixtures/powerpackListNumbersResponse.json b/tests/resources/fixtures/powerpackListNumbersResponse.json new file mode 100644 index 00000000..da52532e --- /dev/null +++ b/tests/resources/fixtures/powerpackListNumbersResponse.json @@ -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" + } + ] +} diff --git a/tests/resources/fixtures/powerpackListPowerpackResponse.json b/tests/resources/fixtures/powerpackListPowerpackResponse.json new file mode 100644 index 00000000..5d1572e7 --- /dev/null +++ b/tests/resources/fixtures/powerpackListPowerpackResponse.json @@ -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//", + "sticky_sender": true, + "uuid": "" + }, + { + "application_id": "", + "application_type": "", + "created_on": "2019-10-09T17:03:31.837944Z", + "local_connect": false, + "name": "p23", + "number_pool": "/v1/Account/xxxxxxxx/NumberPool//", + "sticky_sender": false, + "uuid": "" + }, + { + "application_id": "", + "application_type": "", + "created_on": "2019-10-09T16:54:34.0117Z", + "local_connect": false, + "name": "p22", + "number_pool": "/v1/Account/xxxxxxxx/NumberPool//", + "sticky_sender": false, + "uuid": "" + } + ] +} diff --git a/tests/resources/fixtures/powerpackListShortcodeResponse.json b/tests/resources/fixtures/powerpackListShortcodeResponse.json new file mode 100644 index 00000000..84829bdd --- /dev/null +++ b/tests/resources/fixtures/powerpackListShortcodeResponse.json @@ -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}" + } + ] +} diff --git a/tests/resources/fixtures/powerpackListTollfreeResponse.json b/tests/resources/fixtures/powerpackListTollfreeResponse.json new file mode 100644 index 00000000..a7cbc23e --- /dev/null +++ b/tests/resources/fixtures/powerpackListTollfreeResponse.json @@ -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}" + } + ] +} diff --git a/tests/resources/fixtures/powerpackRemoveNumberResponse.json b/tests/resources/fixtures/powerpackRemoveNumberResponse.json new file mode 100644 index 00000000..7ddd282b --- /dev/null +++ b/tests/resources/fixtures/powerpackRemoveNumberResponse.json @@ -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//", + "created_on": "2019-07-15T12:22:00Z" +} diff --git a/tests/resources/fixtures/powerpackRemoveShortcodeResponse.json b/tests/resources/fixtures/powerpackRemoveShortcodeResponse.json new file mode 100644 index 00000000..7ddd282b --- /dev/null +++ b/tests/resources/fixtures/powerpackRemoveShortcodeResponse.json @@ -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//", + "created_on": "2019-07-15T12:22:00Z" +} diff --git a/tests/resources/fixtures/powerpackRemoveTollfreeResponse.json b/tests/resources/fixtures/powerpackRemoveTollfreeResponse.json new file mode 100644 index 00000000..7ddd282b --- /dev/null +++ b/tests/resources/fixtures/powerpackRemoveTollfreeResponse.json @@ -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//", + "created_on": "2019-07-15T12:22:00Z" +} diff --git a/tests/resources/fixtures/powerpackUpdatePowerpackResponse.json b/tests/resources/fixtures/powerpackUpdatePowerpackResponse.json new file mode 100644 index 00000000..4249843c --- /dev/null +++ b/tests/resources/fixtures/powerpackUpdatePowerpackResponse.json @@ -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": "" +} diff --git a/tests/resources/test_powerpacks.py b/tests/resources/test_powerpacks.py index 9244189f..e8c1ced1 100644 --- a/tests/resources/test_powerpacks.py +++ b/tests/resources/test_powerpacks.py @@ -17,7 +17,7 @@ def test_get_powerpack(self): response = self.client.powerpacks.get(uuid='5ec4c8c9-cd74-42b5-9e41-0d7670d6bb46') # Verifying the endpoint hit self.assertUrlEqual( - 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/Powerpack/', + 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/Powerpack/5ec4c8c9-cd74-42b5-9e41-0d7670d6bb46/', self.client.current_request.url) # Verifying the method used @@ -38,7 +38,7 @@ def test_list_powerpack(self): @with_response(200) def test_update_powerpack(self): params = {} - params['name'] = 'test_sdk_ppk' + params['name'] = 'test' powerpack = self.client.powerpacks.get(uuid='d35f2e82-d387-427f-8594-6fa07613c43a') response= powerpack.update(params) self.assertEqual(params['name'], response['name']) @@ -48,8 +48,6 @@ def test_delete_powerpack(self): powerpack = self.client.powerpacks.get(uuid='d35f2e82-d387-427f-8594-6fa07613c43a') response = powerpack.delete() self.assertEqual('DELETE', self.client.current_request.method) - self.assertEqual('success', response['response']) - @with_response(200) def test_list_numbers(self): @@ -58,16 +56,13 @@ def test_list_numbers(self): #response= powerpack.numberpool.numbers.list( ) # Test if ListResponseObject's __iter__ is working correctly self.assertEqual(len(list(numberpoolnumber)), 3) - - print(self.client.current_request.url) - # Verifying the endpoint hit self.assertUrlEqual( - 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/NumberPool/ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f/Number/', + 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/NumberPool/d35f2e82-d387-427f-8594-6fa07613c43a/Number/', self.client.current_request.url) - # Verifying the method used self.assertEqual('GET', self.client.current_request.method) + @with_response(200) def test_count_numbers(self): powerpack = self.client.powerpacks.get(uuid='d35f2e82-d387-427f-8594-6fa07613c43a') @@ -75,11 +70,10 @@ def test_count_numbers(self): count = powerpack.count_numbers() self.assertEqual(6, count) - @with_response(200) def test_add_number(self): powerpack = self.client.powerpacks.get(uuid='d35f2e82-d387-427f-8594-6fa07613c43a') - response = powerpack.add_number( number='15799140336') + response = powerpack.add_number(number='15799140336') #response= powerpack.numberpool.numbers.add( number='15799140336') self.assertEqual('POST', self.client.current_request.method) self.assertUrlEqual( @@ -89,7 +83,7 @@ def test_add_number(self): @with_response(200) def test_add_tollfree(self): powerpack = self.client.powerpacks.get(uuid='d35f2e82-d387-427f-8594-6fa07613c43a') - response = powerpack.add_number( tollfree='18772209942') + response = powerpack.add_tollfree(tollfree='18772209942') #response= powerpack.numberpool.numbers.add( number='18772209942') self.assertEqual('POST', self.client.current_request.method) self.assertUrlEqual( @@ -101,21 +95,21 @@ def test_remove_number(self): powerpack = self.client.powerpacks.get(uuid='d35f2e82-d387-427f-8594-6fa07613c43a') response= powerpack.remove_number( number='15799140336') #response= powerpack.numberpool.numbers.remove( number='15799140336') - self.assertEqual(200, self.client.current_request.status_code) + self.assertEqual('DELETE', self.client.current_request.method) @with_response(200) def test_remove_tollfree(self): powerpack = self.client.powerpacks.get(uuid='d35f2e82-d387-427f-8594-6fa07613c43a') response= powerpack.remove_tollfree( tollfree='18772209942') #response= powerpack.numberpool.tollfree.remove( number='18772209942') - self.assertEqual(200, self.client.current_request.status_code) + self.assertEqual('DELETE', self.client.current_request.method) @with_response(200) def test_remove_shortcode(self): powerpack = self.client.powerpacks.get(uuid='d35f2e82-d387-427f-8594-6fa07613c43a') response= powerpack.remove_shortcode( shortcode='333333') #response= powerpack.numberpool.shortcode.remove( number='333333') - self.assertEqual(200, self.client.current_request.status_code) + self.assertEqual('DELETE', self.client.current_request.method) @with_response(200) def test_list_shortcode(self): @@ -123,13 +117,11 @@ def test_list_shortcode(self): shortcodes = powerpack.list_shortcodes() # shortcodes = powerpack.numberpool.shortcodes.list() # Test if ListResponseObject's __iter__ is working correctly - self.assertEqual(len(list(shortcodes)), 3) - - print(self.client.current_request.url) + self.assertEqual(len(list(shortcodes)), 1) # Verifying the endpoint hit self.assertUrlEqual( - 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/NumberPool/ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f/Shortcode/', + 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/NumberPool/ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f/Shortcode/?limit=20&offset=0', self.client.current_request.url) # Verifying the method used @@ -147,7 +139,7 @@ def test_list_tollfree(self): # Verifying the endpoint hit self.assertUrlEqual( - 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/NumberPool/ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f/Tollfree/', + 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/NumberPool/ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f/Tollfree/?limit=20&offset=0', self.client.current_request.url) # Verifying the method used @@ -156,21 +148,21 @@ def test_list_tollfree(self): def test_find_shortcode(self): powerpack = self.client.powerpacks.get(uuid='d35f2e82-d387-427f-8594-6fa07613c43a') # response = powerpack.numberpool.shortcodes.find( shortcode='444444') - response = powerpack.find_shortcode( shortcode='444444') - self.assertEqual('444444', response['shortcode']) + response = powerpack.find_shortcode(shortcode='444444') + self.assertEqual('444444', response['objects'][0]['shortcode']) @with_response(200) def test_find_tollfree(self): powerpack = self.client.powerpacks.get(uuid='d35f2e82-d387-427f-8594-6fa07613c43a') # response = powerpack.numberpool.shortcodes.find( shortcode='444444') - response = powerpack.find_shortcode( shortcode='18772209942') - self.assertEqual('18772209942', response['shortcode']) + response = powerpack.find_tollfree(tollfree='18772209942') + self.assertEqual('18772209942', response['objects'][0]['tollfree']) @with_response(200) def test_buy_and_number(self): powerpack = self.client.powerpacks.get(uuid='d35f2e82-d387-427f-8594-6fa07613c43a') # response = powerpack.numberpool.numbers.buy_add_number( number='14845071864') - response = powerpack.buy_add_number( number='14845071864') + response = powerpack.buy_add_number(number='14845071864') self.assertEqual('POST', self.client.current_request.method) self.assertEqual('14845071864', response['number'])