diff options
Diffstat (limited to 'tests')
3 files changed, 18 insertions, 6 deletions
diff --git a/tests/dcaegen2/prh-testcases/assets/json_events/event_without_IPV6_field.json b/tests/dcaegen2/prh-testcases/assets/json_events/event_without_IPV6_field.json new file mode 100644 index 00000000..0aa0372c --- /dev/null +++ b/tests/dcaegen2/prh-testcases/assets/json_events/event_without_IPV6_field.json @@ -0,0 +1,10 @@ +{ + "event": { + "commonEventHeader": { + "sourceName":"NOK6061ZW9" + }, + "pnfRegistrationFields": { + "oamV4IpAddress":"10.17.123.24" + } + } +} diff --git a/tests/dcaegen2/prh-testcases/prh_tests.robot b/tests/dcaegen2/prh-testcases/prh_tests.robot index 55f484fa..62698455 100644 --- a/tests/dcaegen2/prh-testcases/prh_tests.robot +++ b/tests/dcaegen2/prh-testcases/prh_tests.robot @@ -18,6 +18,7 @@ ${EVENT_WITH_MISSING_SOURCENAME} %{WORKSPACE}/tests/dcaegen2/prh-testcases/as ${EVENT_WITH_MISSING_SOURCENAME_AND_IPV4} %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV4.json ${EVENT_WITH_MISSING_SOURCENAME_AND_IPV6} %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_and_IPV6.json ${EVENT_WITH_MISSING_SOURCENAME_IPV4_AND_IPV6} %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/event_with_missing_sourceName_IPV4_and_IPV6.json +${EVENT_WITHOUT_IPV6_FILED} %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/event_without_IPV6_field.json ${Not_json_format} %{WORKSPACE}/tests/dcaegen2/prh-testcases/assets/json_events/not_json_format.json *** Test Cases *** @@ -28,6 +29,7 @@ Valid DMaaP event can be converted to PNF_READY notification ${EVENT_WITH_ALL_VALID_REQUIRED_FIELDS} ${EVENT_WITH_IPV4} ${EVENT_WITH_IPV6} + ${EVENT_WITHOUT_IPV6_FILED} Invalid DMaaP event cannot be converted to PNF_READY notification [Documentation] PRH get invalid event from DMaaP with missing required fields - PRH does not produce PNF_READY notification diff --git a/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py b/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py index 6a95c71e..656f6fc3 100644 --- a/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py +++ b/tests/dcaegen2/prh-testcases/resources/PrhLibrary.py @@ -21,18 +21,18 @@ class PrhLibrary(object): @staticmethod def create_pnf_ready_notification(json_file): json_to_python = json.loads(json_file) - ipv4 = json_to_python["event"]["pnfRegistrationFields"]["oamV4IpAddress"] - ipv6 = json_to_python["event"]["pnfRegistrationFields"]["oamV6IpAddress"] - correlationId = json_to_python["event"]["commonEventHeader"]["sourceName"] - str_json = '{"correlationId":"' + correlationId + '","ipaddress-v4-oam":"' + ipv4 + '","ipaddress-v6-oam":"' + ipv6 + '"}' + ipv4 = json_to_python.get("event").get("pnfRegistrationFields").get("oamV4IpAddress") + ipv6 = json_to_python.get("event").get("pnfRegistrationFields").get("oamV6IpAddress") if "oamV6IpAddress" in json_to_python["event"]["pnfRegistrationFields"] else "" + correlation_id = json_to_python.get("event").get("commonEventHeader").get("sourceName") + str_json = '{"correlationId":"' + correlation_id + '","ipaddress-v4-oam":"' + ipv4 + '","ipaddress-v6-oam":"' + ipv6 + '"}' python_to_json = json.dumps(str_json) return python_to_json.replace("\\", "")[1:-1] @staticmethod def create_pnf_name(json_file): json_to_python = json.loads(json_file) - correlationId = json_to_python["event"]["commonEventHeader"]["sourceName"] - return correlationId + correlation_id = json_to_python.get("sourceName") + return correlation_id @staticmethod def stop_aai(): |