Skip to content

Commit eb16772

Browse files
committed
In order to uniformize field names, case_customer field is renamed case_customer_id for POST /api/v2/cases
1 parent 62604d5 commit eb16772

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

source/app/blueprints/rest/v2/cases/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ def create_case():
6363
"""
6464

6565
try:
66-
case = cases_create(request.get_json())
66+
# TODO this is a bit of a hack, so that we have everywhere case_customer_id.
67+
# Should be moved down into method cases_update. But careful with the legacy.
68+
request_data = request.get_json()
69+
request_data['case_customer'] = request_data['case_customer_id']
70+
71+
case = cases_create(request_data)
6772
return response_api_created(CaseSchemaForAPIV2().dump(case))
6873
except BusinessProcessingError as e:
6974
return response_api_error(e.get_message(), e.get_data())

tests/iris.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def create_dummy_case(self):
6868
body = {
6969
'case_name': 'case name',
7070
'case_description': 'description',
71-
'case_customer': 1,
71+
'case_customer_id': 1,
7272
'case_soc_id': ''
7373
}
7474
response = self._api.post('/api/v2/cases', body).json()

tests/tests_rest_cases.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_create_case_should_return_201(self):
4545
response = self._subject.create('/api/v2/cases', {
4646
'case_name': 'name',
4747
'case_description': 'description',
48-
'case_customer': 1,
48+
'case_customer_id': 1,
4949
'case_soc_id': ''
5050
})
5151
self.assertEqual(201, response.status_code)
@@ -54,15 +54,15 @@ def test_create_case_with_spurious_slash_should_return_404(self):
5454
response = self._subject.create('/api/v2/cases/', {
5555
'case_name': 'name',
5656
'case_description': 'description',
57-
'case_customer': 1,
57+
'case_customer_id': 1,
5858
'case_soc_id': ''
5959
})
6060
self.assertEqual(404, response.status_code)
6161

6262
def test_create_case_with_missing_name_should_return_400(self):
6363
response = self._subject.create('/api/v2/cases', {
6464
'case_description': 'description',
65-
'case_customer': 1,
65+
'case_customer_id': 1,
6666
'case_soc_id': ''
6767
})
6868
self.assertEqual(400, response.status_code)
@@ -71,7 +71,7 @@ def test_create_case_with_classification_id_should_set_classification_id(self):
7171
response = self._subject.create('/api/v2/cases', {
7272
'case_name': 'name',
7373
'case_description': 'description',
74-
'case_customer': 1,
74+
'case_customer_id': 1,
7575
'case_soc_id': '',
7676
'classification_id': 2
7777
}).json()
@@ -89,7 +89,7 @@ def test_get_case_should_return_case_data(self):
8989
response = self._subject.create('/api/v2/cases', {
9090
'case_name': 'name',
9191
'case_description': 'description',
92-
'case_customer': 1,
92+
'case_customer_id': 1,
9393
'case_soc_id': ''
9494
}).json()
9595
identifier = response['case_id']
@@ -100,7 +100,7 @@ def test_delete_case_should_return_204(self):
100100
response = self._subject.create('/api/v2/cases', {
101101
'case_name': 'name',
102102
'case_description': 'description',
103-
'case_customer': 1,
103+
'case_customer_id': 1,
104104
'case_soc_id': ''
105105
}).json()
106106
identifier = response['case_id']
@@ -111,7 +111,7 @@ def test_get_case_should_return_404_after_it_is_deleted(self):
111111
response = self._subject.create('/api/v2/cases', {
112112
'case_name': 'name',
113113
'case_description': 'description',
114-
'case_customer': 1,
114+
'case_customer_id': 1,
115115
'case_soc_id': ''
116116
}).json()
117117
identifier = response['case_id']
@@ -132,7 +132,7 @@ def test_get_cases_should_filter_on_case_name(self):
132132
response = self._subject.create('/api/v2/cases', {
133133
'case_name': 'test_get_cases_should_filter_on_case_name',
134134
'case_description': 'description',
135-
'case_customer': 1,
135+
'case_customer_id': 1,
136136
'case_soc_id': ''
137137
}).json()
138138
case_identifier = response['case_id']
@@ -179,10 +179,11 @@ def test_create_case_should_return_data_with_case_customer_when_case_customer_is
179179
body = {
180180
'case_name': 'case name',
181181
'case_description': 'description',
182-
'case_customer': '',
182+
'case_customer_id': '',
183183
'case_soc_id': ''
184184
}
185185
response = self._subject.create('/api/v2/cases', body).json()
186+
# FIXME: should really be case_customer_id here, rather than case_customer
186187
self.assertIn('case_customer', response['data'])
187188

188189
def test_update_case_should_not_fail(self):

0 commit comments

Comments
 (0)