Skip to content

Commit

Permalink
- add delete licensee method
Browse files Browse the repository at this point in the history
- extend test cases
  • Loading branch information
r-brown committed Jun 14, 2020
1 parent 763aad3 commit 0322f6c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions netlicensing/netlicensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
23 changes: 23 additions & 0 deletions tests/test_licensee.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0322f6c

Please sign in to comment.