Skip to content

Commit

Permalink
VAN: Fix codes bugs. (move-coop#696)
Browse files Browse the repository at this point in the history
* Fix request name.

* Fix changed entities bugs.

* Added test.
  • Loading branch information
jburchard authored Jun 7, 2022
1 parent 4395479 commit 8411c21
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
6 changes: 3 additions & 3 deletions parsons/ngpvan/codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_code(self, code_id):
See :ref:`parsons-table` for output options.
"""

c = self.connection.request(f'codes/{code_id}')
c = self.connection.get_request(f'codes/{code_id}')
logger.debug(c)
logger.info(f'Found code {code_id}.')
return c
Expand Down Expand Up @@ -115,7 +115,7 @@ def create_code(self, name=None, parent_code_id=None, description=None,

se = [{'name': s['name'],
'isSearchable': s['is_searchable'],
'is_applicable': s['is_applicable']} for s in supported_entities]
'isApplicable': s['is_applicable']} for s in supported_entities]

json['supportedEntities'] = se

Expand Down Expand Up @@ -175,7 +175,7 @@ def update_code(self, code_id, name=None, parent_code_id=None, description=None,

se = [{'name': s['name'],
'isSearchable': s['is_searchable'],
'is_applicable': s['is_applicable']} for s in supported_entities]
'isApplicable': s['is_applicable']} for s in supported_entities]
post_data['supportedEntities'] = se

r = self.connection.put_request(f'codes/{code_id}', json=post_data)
Expand Down
18 changes: 18 additions & 0 deletions test/test_van/test_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@ def test_get_codes(self, m):
m.get(self.van.connection.uri + 'codes', json=json)
assert_matching_tables(json['items'], self.van.get_codes())

@requests_mock.Mocker()
def test_get_code(self, m):

json = {'codeId': 1004916,
'parentCodeId': None,
'name': 'Data Entry',
'description': 'for test.',
'codePath': 'Data Entry',
'createdByName': '',
'dateCreated': '2018-07-13T15:16:00Z',
'supportedEntities': None,
'codeType': 'Tag',
'campaign': None,
'contactType': None}

m.get(self.van.connection.uri + 'codes/1004916', json=json)
self.assertEqual(json, self.van.get_code(1004916))

@requests_mock.Mocker()
def test_get_code_types(self, m):

Expand Down

0 comments on commit 8411c21

Please sign in to comment.