Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IS-07-02] Check Device controls #807

Open
garethsb opened this issue May 1, 2023 · 1 comment
Open

[IS-07-02] Check Device controls #807

garethsb opened this issue May 1, 2023 · 1 comment

Comments

@garethsb
Copy link
Contributor

garethsb commented May 1, 2023

Check Device.controls has an entry with "type": "urn:x-nmos:control:events/{version}" (i.e. api["version"]) and the appropriate "href" based on the api["url"] under test.

Originally posted by @garethsb in #431 (comment)

@garethsb
Copy link
Contributor Author

garethsb commented May 1, 2023

def test_xx(self, test):
        """At least one Device is showing an IS-07 control advertisement matching the API under test"""

        valid, devices = self.do_request("GET", self.node_url + "devices")
        if not valid:
            return test.FAIL("Node API did not respond as expected: {}".format(devices))

        is07_devices = []
        found_api_match = False
        try:
            device_type = "urn:x-nmos:control:events/" + self.apis[EVENTS_API_KEY]["version"]
            for device in devices.json():
                controls = device["controls"]
                for control in controls:
                    if control["type"] == device_type:
                        is07_devices.append(control["href"])
                        if self.is07_utils.compare_urls(self.events_url, control["href"]) and \
                                self.authorization is control.get("authorization", False):
                            found_api_match = True
        except json.JSONDecodeError:
            return test.FAIL("Non-JSON response returned from Node API")
        except KeyError:
            return test.FAIL("One or more Devices were missing the 'controls' attribute")

        if len(is07_devices) > 0 and found_api_match:
            return test.PASS()
        elif len(is07_devices) > 0:
            return test.FAIL("Found one or more Device controls, but no href and authorization mode matched the "
                             "Events API under test")
        else:
            return test.FAIL("Unable to find any Devices which expose the control type '{}'".format(device_type))

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

No branches or pull requests

1 participant