Skip to content

Commit

Permalink
Merge pull request #132 from Crown-Commercial-Service/feature/DMP-117…
Browse files Browse the repository at this point in the history
…7-add-route-to-update-sharecode

DMP-1177 - Add `update_supplier_sharecode` method
  • Loading branch information
tim-s-ccs authored Aug 29, 2024
2 parents 2b6a906 + 18af65b commit 350af4f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dmapiclient/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '26.6.1'
__version__ = '26.7.0'

from .errors import APIError, HTTPError, InvalidResponse # noqa
from .errors import REQUEST_ERROR_STATUS_CODE, REQUEST_ERROR_MESSAGE # noqa
Expand Down
11 changes: 11 additions & 0 deletions dmapiclient/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,17 @@ def update_supplier(self, supplier_id, supplier, user=None):
user=user,
)

def update_supplier_sharecode(self, supplier_id, sharecode, user=None):
return self._post_with_updated_by(
"/suppliers/{}/sharecode".format(supplier_id),
data={
"suppliers": {
"sharecode": sharecode
},
},
user=user,
)

def update_contact_information(self, supplier_id, contact_id,
contact, user=None):
return self._post_with_updated_by(
Expand Down
15 changes: 15 additions & 0 deletions tests/test_data_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,21 @@ def test_update_supplier(self, data_client, rmock):
'suppliers': {'foo': 'bar'}, 'updated_by': 'supplier'
}

def test_update_supplier_sharecode(self, data_client, rmock):
rmock.post(
"http://baseurl/suppliers/123/sharecode",
json={"suppliers": "result"},
status_code=200,
)

result = data_client.update_supplier_sharecode(123, "123456789", 'supplier')

assert result == {"suppliers": "result"}
assert rmock.called
assert rmock.request_history[0].json() == {
'suppliers': {'sharecode': '123456789'}, 'updated_by': 'supplier'
}

def test_update_contact_information(self, data_client, rmock):
rmock.post(
"http://baseurl/suppliers/123/contact-information/2",
Expand Down

0 comments on commit 350af4f

Please sign in to comment.