Skip to content

Commit

Permalink
fix for issue #667 (#668)
Browse files Browse the repository at this point in the history
* fix for issue 667

* Update RELEASE_NOTES.md

* Fix for issue #667

* Resolved TODO in test_timescale_types.py

* Update RELEASE_NOTES.md
  • Loading branch information
NEC-Vishal authored Sep 8, 2022
1 parent 1c3ce68 commit af8877c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- Added logs in src/wq/core/task.py (#662)
- Replaced entity with getter (#652)
- Resolved TODO in Dockerfile (#680)
- Resolved TODO at src/reporter/tests/test_timescale_types.py (#667)

### Bug fixes

Expand Down
21 changes: 1 addition & 20 deletions src/reporter/tests/test_timescale_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from utils.kvt import merge_dicts

from .geo_queries_fixture import query_1t1ena
from .utils import notify_url
from .utils import notify_url, insert_entities
from src.utils.tests.tenant import gen_tenant_id


Expand Down Expand Up @@ -109,25 +109,6 @@ def gen_entity(entity_id: int,
# Similar to gen_entity in test_timescale_insert module in translators.tests.


def insert_entities(entities: Union[List[dict], dict],
service: str = None, service_path: str = None,
expected_status_code=200) -> Response:
headers = {
'Content-Type': 'application/json',
'fiware-Service': service,
'fiware-ServicePath': service_path
}
body = json.dumps({
'data': entities if isinstance(entities, List) else [entities]
})
response = requests.post(notify_url(), data=body, headers=headers)
assert response.status_code == expected_status_code
return response
# TODO: factor out?
# This function could sit in a separate module and be shared across all
# reporter tests.


def entity_name_value_pairs(entity: dict) -> dict:
"""
Transform an NGSI entity ``e`` into the format::
Expand Down
17 changes: 17 additions & 0 deletions src/reporter/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Callable, Iterable, List, Optional, Tuple, Union
import re
import random
from requests import Response

from translators.factory import translator_for
from translators.sql_translator import ENTITY_ID_COL, TENANT_PREFIX, \
Expand Down Expand Up @@ -96,6 +97,22 @@ def get_notification_different_types(
}


def insert_entities(entities: Union[List[dict], dict],
service: str = None, service_path: str = None,
expected_status_code=200) -> Response:
headers = {
'Content-Type': 'application/json',
'fiware-Service': service,
'fiware-ServicePath': service_path
}
body = json.dumps({
'data': entities if isinstance(entities, List) else [entities]
})
response = requests.post(notify_url(), data=body, headers=headers)
assert response.status_code == expected_status_code
return response


def send_notifications(service, notifications, service_path='/'):
assert isinstance(notifications, list)
h = {'Content-Type': 'application/json'}
Expand Down

0 comments on commit af8877c

Please sign in to comment.