From 0322f6c9b17e2f34b50dc6f08fcf0e800b0c9b62 Mon Sep 17 00:00:00 2001 From: Alexey Averikhin Date: Sun, 14 Jun 2020 16:12:26 +0200 Subject: [PATCH] - add delete licensee method - extend test cases --- netlicensing/netlicensing.py | 4 ++++ tests/test_licensee.py | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/netlicensing/netlicensing.py b/netlicensing/netlicensing.py index 938c081..d1f8555 100644 --- a/netlicensing/netlicensing.py +++ b/netlicensing/netlicensing.py @@ -73,3 +73,7 @@ def validate(self, licensee_number): def get_licensee(self, licensee_number): url = f'{self.nlic_baseurl}licensee/{licensee_number}' return self._get(url) + + def delete_licensee(self, licensee_number): + url = f'{self.nlic_baseurl}licensee/{licensee_number}' + return self._delete(url) diff --git a/tests/test_licensee.py b/tests/test_licensee.py index 1f65e80..45240e5 100644 --- a/tests/test_licensee.py +++ b/tests/test_licensee.py @@ -5,8 +5,31 @@ def test_get_licensee(netlicensing): result = netlicensing.get_licensee(customer_number) assert customer_number in json.dumps(result) +def test_get_licensee_not_exiting(netlicensing): + customer_number = 'CUST-NOT-EXITING' + with pytest.raises(netlicensing.HttpError): + netlicensing.get_licensee(customer_number) + def test_validate(netlicensing): customer_number = 'CUST-11' result = netlicensing.validate(customer_number) assert 'ProductModuleValidation' in json.dumps(result) assert 'true' in json.dumps(result) + +def test_validate_not_exiting(netlicensing): + customer_number = 'CUST-NOT-EXITING' + with pytest.raises(netlicensing.HttpError): + netlicensing.validate(customer_number) + +def test_delete_not_exiting(netlicensing): + customer_number = 'CUST-NOT-EXITING' + with pytest.raises(netlicensing.HttpError): + netlicensing.delete_licensee(customer_number) + +def test_delete_not_exiting_try(netlicensing): + customer_number = 'CUST-NOT-EXITING' + try: + netlicensing.delete_licensee(customer_number) + except netlicensing.HttpError as e: + assert e.code == 400 + assert u'' == e.reason