|
4 | 4 | from pytest import raises
|
5 | 5 | from vonage_account.account import Account
|
6 | 6 | from vonage_account.errors import InvalidSecretError
|
| 7 | +from vonage_account.requests import ( |
| 8 | + GetCountryPricingRequest, |
| 9 | + GetPrefixPricingRequest, |
| 10 | + ServiceType, |
| 11 | +) |
7 | 12 | from vonage_http_client.errors import ForbiddenError
|
8 | 13 | from vonage_http_client.http_client import HttpClient
|
9 | 14 |
|
@@ -70,6 +75,66 @@ def test_update_default_sms_webhook():
|
70 | 75 | assert settings_response.max_calls_per_second == 30
|
71 | 76 |
|
72 | 77 |
|
| 78 | +@responses.activate |
| 79 | +def test_get_country_pricing(): |
| 80 | + build_response( |
| 81 | + path, |
| 82 | + 'GET', |
| 83 | + 'https://rest.nexmo.com/account/get-pricing/outbound/sms', |
| 84 | + 'get_country_pricing.json', |
| 85 | + ) |
| 86 | + |
| 87 | + response = account.get_country_pricing( |
| 88 | + GetCountryPricingRequest(country_code='ZM', type=ServiceType.SMS) |
| 89 | + ) |
| 90 | + |
| 91 | + assert response.dialing_prefix == '260' |
| 92 | + assert response.country_name == 'Zambia' |
| 93 | + assert response.default_price == '0.28725000' |
| 94 | + assert response.networks[0].network_name == 'Zambia Premium' |
| 95 | + assert response.networks[1].mcc == '645' |
| 96 | + |
| 97 | + |
| 98 | +@responses.activate |
| 99 | +def test_get_all_countries_pricing(): |
| 100 | + build_response( |
| 101 | + path, |
| 102 | + 'GET', |
| 103 | + 'https://rest.nexmo.com/account/get-full-pricing/outbound/sms', |
| 104 | + 'get_multiple_countries_pricing.json', |
| 105 | + ) |
| 106 | + |
| 107 | + response = account.get_all_countries_pricing(ServiceType.SMS) |
| 108 | + |
| 109 | + assert response.count == 2 |
| 110 | + assert response.countries[0].country_name == 'Italy' |
| 111 | + assert response.countries[1].country_name == 'Vatican City' |
| 112 | + assert response.countries[0].networks[0].network_name == 'Noverca Italia S.r.l.' |
| 113 | + assert response.countries[0].networks[0].price == '0.08270000' |
| 114 | + |
| 115 | + |
| 116 | +@responses.activate |
| 117 | +def test_get_prefix_pricing(): |
| 118 | + build_response( |
| 119 | + path, |
| 120 | + 'GET', |
| 121 | + 'https://rest.nexmo.com/account/get-prefix-pricing/outbound/sms', |
| 122 | + 'get_multiple_countries_pricing.json', |
| 123 | + ) |
| 124 | + |
| 125 | + response = account.get_prefix_pricing( |
| 126 | + GetPrefixPricingRequest(prefix='39', type=ServiceType.SMS) |
| 127 | + ) |
| 128 | + |
| 129 | + assert response.count == 2 |
| 130 | + assert response.countries[0].country_name == 'Italy' |
| 131 | + assert response.countries[0].dialing_prefix == '39' |
| 132 | + assert response.countries[1].country_name == 'Vatican City' |
| 133 | + assert response.countries[1].dialing_prefix == '39' |
| 134 | + assert response.countries[0].networks[0].network_name == 'Noverca Italia S.r.l.' |
| 135 | + assert response.countries[0].networks[0].price == '0.08270000' |
| 136 | + |
| 137 | + |
73 | 138 | @responses.activate
|
74 | 139 | def test_list_secrets():
|
75 | 140 | build_response(
|
|
0 commit comments