Skip to content

Test Suite for BCP-004-02#874

Open
alabou wants to merge 22 commits intomasterfrom
bcp-004-02
Open

Test Suite for BCP-004-02#874
alabou wants to merge 22 commits intomasterfrom
bcp-004-02

Conversation

@alabou
Copy link
Collaborator

@alabou alabou commented May 14, 2025

Test Suite for BCP-004-02

Notes:

  • nmos-parameter-registers must be directed to the official repo once accepted.
  • patch to support non-AMWA repo should be removed.

Comment on lines +399 to +402
"url": "https://github.com/alabou/",
"branch": "bcp-004-02",
"versions": ["bcp-004-02"],
"default_version": "bcp-004-02",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed once AMWA-TV/nmos-parameter-registers#65 has been merged.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference, these parameters can be overridden in your UserConfig.py so you don't need to touch the Config.py when using development config, like this:

CONFIG.SPECIFICATIONS["nmos-parameter-registers"]["url"] = "https://github.com/alabou/"
CONFIG.SPECIFICATIONS["nmos-parameter-registers"]["versions"] = ["bcp-004-02"]
CONFIG.SPECIFICATIONS["nmos-parameter-registers"]["default_version"] = "bcp-004-02"

alabou and others added 7 commits May 30, 2025 14:09
Co-authored-by: jonathan-r-thorpe <64410119+jonathan-r-thorpe@users.noreply.github.com>
Co-authored-by: jonathan-r-thorpe <64410119+jonathan-r-thorpe@users.noreply.github.com>
Co-authored-by: jonathan-r-thorpe <64410119+jonathan-r-thorpe@users.noreply.github.com>
Co-authored-by: jonathan-r-thorpe <64410119+jonathan-r-thorpe@users.noreply.github.com>
Co-authored-by: jonathan-r-thorpe <64410119+jonathan-r-thorpe@users.noreply.github.com>
Co-authored-by: jonathan-r-thorpe <64410119+jonathan-r-thorpe@users.noreply.github.com>
Co-authored-by: jonathan-r-thorpe <64410119+jonathan-r-thorpe@users.noreply.github.com>
@@ -0,0 +1,319 @@
# Copyright (C) 2025 Matrox Graphics Inc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Copyright (C) 2025 Matrox Graphics Inc.
# Copyright (C) 2022 Advanced Media Workflow Association

Comment on lines +102 to +141
def get_is05_partial_resources(self, resource_type):
"""Retrieve all Senders or Receivers from a Connection API, keeping hold of the returned IDs"""
assert resource_type in ["senders", "receivers"]

# Prevent this being executed twice in one test run
if resource_type in self.is05_resources["_requested"]:
return True, ""

path_url = "single/" + resource_type
full_url = self.connection_url + path_url
valid, resources = self.do_request("GET", full_url)
if not valid:
return False, "Connection API did not respond as expected: {}".format(resources)

schema = self.get_schema(CONNECTION_API_KEY, "GET", "/" + path_url, resources.status_code)
valid, message = self.check_response(schema, "GET", resources)
if not valid:
raise NMOSTestException(message)

# The following call to is05_utils.get_transporttype does not validate against the IS-05 schemas,
# which is good for allowing extended transport. The transporttype-response-schema.json schema is
# broken as it does not allow additional transport, nor x-nmos ones, nor vendor specific ones.
try:
for resource in resources.json():
resource_id = resource.rstrip("/")
self.is05_resources[resource_type].append(resource_id)
if self.is05_utils.compare_api_version(self.apis[CONNECTION_API_KEY]["version"], "v1.1") >= 0:
transport_type = self.is05_utils.get_transporttype(resource_id, resource_type.rstrip("s"))
self.is05_resources["transport_types"][resource_id] = transport_type
else:
self.is05_resources["transport_types"][resource_id] = "urn:x-nmos:transport:rtp"
if resource_type == "senders":
transport_file = self.is05_utils.get_transportfile(resource_id)
self.is05_resources["transport_files"][resource_id] = transport_file
self.is05_resources["_requested"].append(resource_type)
except json.JSONDecodeError:
return False, "Non-JSON response returned from Node API"

return True, ""

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is unused by the tests, so can be removed.

Suggested change
def get_is05_partial_resources(self, resource_type):
"""Retrieve all Senders or Receivers from a Connection API, keeping hold of the returned IDs"""
assert resource_type in ["senders", "receivers"]
# Prevent this being executed twice in one test run
if resource_type in self.is05_resources["_requested"]:
return True, ""
path_url = "single/" + resource_type
full_url = self.connection_url + path_url
valid, resources = self.do_request("GET", full_url)
if not valid:
return False, "Connection API did not respond as expected: {}".format(resources)
schema = self.get_schema(CONNECTION_API_KEY, "GET", "/" + path_url, resources.status_code)
valid, message = self.check_response(schema, "GET", resources)
if not valid:
raise NMOSTestException(message)
# The following call to is05_utils.get_transporttype does not validate against the IS-05 schemas,
# which is good for allowing extended transport. The transporttype-response-schema.json schema is
# broken as it does not allow additional transport, nor x-nmos ones, nor vendor specific ones.
try:
for resource in resources.json():
resource_id = resource.rstrip("/")
self.is05_resources[resource_type].append(resource_id)
if self.is05_utils.compare_api_version(self.apis[CONNECTION_API_KEY]["version"], "v1.1") >= 0:
transport_type = self.is05_utils.get_transporttype(resource_id, resource_type.rstrip("s"))
self.is05_resources["transport_types"][resource_id] = transport_type
else:
self.is05_resources["transport_types"][resource_id] = "urn:x-nmos:transport:rtp"
if resource_type == "senders":
transport_file = self.is05_utils.get_transportfile(resource_id)
self.is05_resources["transport_files"][resource_id] = transport_file
self.is05_resources["_requested"].append(resource_type)
except json.JSONDecodeError:
return False, "Non-JSON response returned from Node API"
return True, ""

Comment on lines +65 to +70
self.is05_resources = {
"senders": [],
"receivers": [],
"_requested": [],
"transport_types": {},
"transport_files": {}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only used by get_is05_partial_resources which is itself unused, so can be removed

Suggested change
self.is05_resources = {
"senders": [],
"receivers": [],
"_requested": [],
"transport_types": {},
"transport_files": {}}

"transport_types": {},
"transport_files": {}}
self.is04_utils = IS04Utils(self.node_url)
self.is05_utils = IS05Utils(self.connection_url)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only used by get_is05_partial_resources which is itself unused, so can be removed

Suggested change
self.is05_utils = IS05Utils(self.connection_url)

Comment on lines +142 to +169
def check_response_without_transport_params(self, schema, method, response):
"""Confirm that a given Requests response conforms to the expected schema and has any expected headers
without considering the 'transport_params' attribute"""
ctype_valid, ctype_message = check_content_type(response.headers)
if not ctype_valid:
return False, ctype_message

cors_valid, cors_message = self.check_CORS(method, response.headers)
if not cors_valid:
return False, cors_message

fields_to_ignore = ["transport_params"]

data = response.json()

filtered_data = {k: v for k, v in data.items() if k not in fields_to_ignore}

filtered_data["transport_params"] = []

try:
self.validate_schema(filtered_data, schema)
except ValidationError as e:
return False, "Response schema validation error {}".format(e)
except json.JSONDecodeError:
return False, "Invalid JSON received"

return True, ctype_message

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is unused by the tests, so can be removed.

Alain Bouchard and others added 4 commits June 3, 2025 12:42
Co-authored-by: jonathan-r-thorpe <64410119+jonathan-r-thorpe@users.noreply.github.com>
- fix test suite name to add -01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants