Skip to content

Commit 943ae32

Browse files
More tests
1 parent 2bfb95e commit 943ae32

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

tests/response_tier_config_request.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"id": "TA-1-000-000-000"
1111
},
1212
"product": {
13-
"id": "PRD-000-000-000",
13+
"id": "CN-631-322-000",
1414
"name": "Product"
1515
},
1616
"tier_level": 1,

tests/test_tier_config_request.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import os
88
from collections import namedtuple
99

10+
import pytest
1011
from mock import MagicMock, patch
1112

1213
from connect import TierConfigAutomation
@@ -29,6 +30,13 @@ def _get_response_ok():
2930
return Response(ok=True, content=content)
3031

3132

33+
def _get_response_ok_invalid_product():
34+
with open(os.path.join(os.path.dirname(__file__), 'response_tier_config_request.json'))\
35+
as file_handle:
36+
content = file_handle.read()
37+
return Response(ok=True, content=content.replace('CN-631-322-000', 'PRD-000-000-000'))
38+
39+
3240
@patch('requests.get', MagicMock(return_value=_get_response_ok()))
3341
def test_create_resource():
3442
requests = TierConfigAutomation().list
@@ -53,7 +61,7 @@ def test_create_resource():
5361

5462
product = configuration.product
5563
assert isinstance(product, Product)
56-
assert product.id == 'PRD-000-000-000'
64+
assert product.id == 'CN-631-322-000'
5765
assert product.name == 'Product'
5866

5967
connection = configuration.connection
@@ -148,7 +156,20 @@ def test_create_resource():
148156

149157
@patch('requests.get', MagicMock(return_value=_get_response_ok()))
150158
def test_process():
151-
automation = TierConfigAutomation()
159+
automation = TierConfigAutomationHelper()
160+
automation.process()
161+
162+
163+
@patch('requests.get', MagicMock(return_value=_get_response_ok()))
164+
def test_process_not_implemented():
165+
with pytest.raises(NotImplementedError):
166+
automation = TierConfigAutomation()
167+
automation.process()
168+
169+
170+
@patch('requests.get', MagicMock(return_value=_get_response_ok_invalid_product()))
171+
def test_process_invalid_product():
172+
automation = TierConfigAutomationHelper()
152173
automation.process()
153174

154175

@@ -171,3 +192,8 @@ def test_get_tier_config_param():
171192
assert isinstance(param, Param)
172193
assert param.id == 'param_a'
173194
assert param.value == 'param_a_value'
195+
196+
197+
class TierConfigAutomationHelper(TierConfigAutomation):
198+
def process_request(self, request):
199+
pass

0 commit comments

Comments
 (0)