Skip to content

Commit

Permalink
fix tests to correctly delete entities with service paths
Browse files Browse the repository at this point in the history
  • Loading branch information
chicco785 committed Sep 22, 2020
1 parent b80d3da commit 7f18d53
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/reporter/tests/test_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def test_integration_multiple_entities(diffEntityWithDifferentAttrs, orion_clien
assert r.status_code == 200
entities = r.json()
assert len(entities) == 3
delete_entity_type("service", diffEntityWithDifferentAttrs[0]['type'])
delete_entity_type("service", diffEntityWithDifferentAttrs[0]['type'], "/Root")

@pytest.mark.skip(reason="See issue #105")
@pytest.mark.parametrize("service", services)
Expand Down Expand Up @@ -327,7 +327,7 @@ def test_multiple_data_elements(service, notification, diffEntityWithDifferentAt
r = requests.get(entities_url, params=None, headers=query_header(service))
entities = r.json()
assert len(entities) == 3
delete_entity_type(None, diffEntityWithDifferentAttrs[0]['type'])
delete_entity_type(service, diffEntityWithDifferentAttrs[0]['type'])


@pytest.mark.parametrize("service", services)
Expand Down Expand Up @@ -376,7 +376,7 @@ def test_multiple_data_elements_different_servicepath(service, notification, dif
r = requests.get(entities_url, params=None, headers=query_headers)
entities = r.json()
assert len(entities) == 3
delete_entity_type(service, diffEntityWithDifferentAttrs[0]['type'])
delete_entity_type(service, diffEntityWithDifferentAttrs[0]['type'], '/Test')


@pytest.mark.parametrize("service", services)
Expand Down
7 changes: 5 additions & 2 deletions src/reporter/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,13 @@ def insert_test_data(service, entity_types, n_entities=1, index_size=30,
time.sleep(1)


def delete_entity_type(service, entity_type):
def delete_entity_type(service, entity_type, service_path=None):
h = {}
if service:
h = {'Fiware-Service': service}
h['Fiware-Service'] = service
if service_path:
h['Fiware-ServicePath'] = service_path

url = '{}/types/{}'.format(QL_URL, entity_type)

r = requests.delete(url, headers=h)
Expand Down

0 comments on commit 7f18d53

Please sign in to comment.