Skip to content

Commit

Permalink
chore: implement a test for tenant creation
Browse files Browse the repository at this point in the history
  • Loading branch information
djs0109 committed Oct 30, 2024
1 parent 0ab3900 commit 80fa980
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions filip/clients/ngsi_ld/cb.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self,
#base_http_client overwrites empty header with FiwareHeader instead of FiwareLD
init_header = FiwareLDHeader()
if fiware_header:
init_header=fiware_header
init_header = fiware_header

super().__init__(url=url,
session=session,
Expand All @@ -71,7 +71,7 @@ def __init__(self,
# set the version specific url-pattern
self._url_version = NgsiURLVersion.ld_url
# init Content-Type header , account for @context field further down
self.headers.update({'Content-Type':'application/json'})
self.headers.update({'Content-Type': 'application/json'})
if init_header.ngsild_tenant is not None:
self.__make_tenant()

Expand Down
16 changes: 16 additions & 0 deletions tests/clients/test_ngsi_ld_cb.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ def test_management_endpoints(self):
self.assertIsNotNone(self.client.get_version())
# TODO: check whether there are other "management" endpoints

@unittest.skip("Only for local testing environment")
def test_not_existing_tenant(self):
"""
Test the expected behavior of the client when the tenant does not exist
This test will not be included in the CI/CD pipeline. For local testing please
comment out the decorator.
"""
# create uuid for the tenant
import uuid
tenant = str(uuid.uuid4()).split('-')[0]
fiware_header = FiwareLDHeader(ngsild_tenant=tenant)
client = ContextBrokerLDClient(fiware_header=fiware_header,
url=settings.LD_CB_URL)
entities = client.get_entity_list()
self.assertEqual(len(entities), 0)

def test_statistics(self):
"""
Test statistics of context broker client
Expand Down

0 comments on commit 80fa980

Please sign in to comment.