def setUp(self):
        self.sample = tools.sample_data()
        self.sample.post_sample_data(versions=defines.VERSIONS,
                                     resources=defines._RESOURCES)
        self.validator = tools.JsonSchemaValidator()

        for version in defines.VERSIONS:
            # Delete parent node
            self.delete_request(url="{}/{}/resource/nodes/{}".format(
                defines._BASE_REGISTRATION_URL, version,
                self.sample.get_sample_data(resource="node",
                                            version=version)["data"]["id"]),
                                expected_status_code=204)

        self.test_arr = list()
        for version in defines.VERSIONS:
            for resource in defines._RESOURCES:
                self.test_arr.append({
                    "version":
                    version,
                    "url":
                    "{}/{}/{}s/{}".format(
                        defines._BASE_QUERY_URL, version, resource,
                        self.sample.get_sample_data(
                            resource=resource, version=version)["data"]["id"])
                })
    def setUp(self):
        # -----------------------------------------------------------------------------
        # Test root: <server_proto>://<server_ip>:<server_port>/x-nmos/query/vX.X/
        #            [nodes|devices|senders|receivers|flows|sources]/<id>/?
        # -----------------------------------------------------------------------------

        self.sample = tools.sample_data()
        self.sample.post_sample_data(versions=defines.VERSIONS, resources=defines._RESOURCES)

        self.test_arr = list()
        for version in defines.VERSIONS:
            for resource in defines._RESOURCES:
                self.test_arr.append({"url": "{}/{}/{}s/{}".format(defines._BASE_QUERY_URL,
                                                                   version,
                                                                   resource,
                                                                   self.sample.get_sample_data(resource=resource,
                                                                                               version=version)[
                                                                       "data"][
                                                                       "id"]),
                                      "version": version,
                                      "resource": resource})
                self.test_arr.append({"url": "{}/{}/{}s/{}/".format(defines._BASE_QUERY_URL,
                                                                    version,
                                                                    resource,
                                                                    self.sample.get_sample_data(resource=resource,
                                                                                                version=version)[
                                                                        "data"][
                                                                        "id"]),
                                      "version": version,
                                      "resource": resource})
        self.validator = tools.JsonSchemaValidator()
    def setUp(self):
        self.sample = tools.sample_data()
        self.validator = tools.JsonSchemaValidator()

        self.test_arr = [{
            "version":
            v,
            "url":
            "{}/{}/resource".format(defines._BASE_REGISTRATION_URL, v)
        } for v in defines.VERSIONS]
 def setUp(self):
     self.test_arr = [{
         "version":
         v,
         "resource_url":
         "{}/{}/resource".format(defines._BASE_REGISTRATION_URL, v),
         "health_url":
         "{}/{}/health/nodes/".format(defines._BASE_REGISTRATION_URL, v)
     } for v in defines.VERSIONS]
     self.sample = tools.sample_data()
     self.random_id = str(uuid.uuid4())
     self.validator = tools.JsonSchemaValidator()
    def setUp(self):
        self.sample = tools.sample_data()
        self.json_validator = tools.JsonSchemaValidator()

        # Request Data for Sub / Nodes
        sub_data_base = {
            "max_update_rate_ms": 100,
            "resource_path": "",
            "params": {},
            "persist": False,
            "secure": False
        }
        self.test_items = list()

        for curr_version in defines.VERSIONS:
            for curr_resource in ["/{}s".format(v) for v in defines._RESOURCES]:
                sub_data = sub_data_base
                sub_data["resource_path"] = curr_resource

                # Request ws_href
                response = self.post_request(url="{}/{}/subscriptions".format(defines._BASE_QUERY_URL,
                                                                              curr_version),
                                             request_headers={"accept": "application/json"},
                                             request_data=sub_data)

                try:
                    self.json_validator.validate_subscription(curr_version, response)
                except tools.jsonschema.ValidationError as e:
                    self.fail(str(e))

                # Setup WS Client worker
                ws_client = tools.WSWorker(response["ws_href"])

                expected_data = self.sample.get_sample_data(resource=curr_resource.replace("/", "")[:-1],
                                                            version=curr_version)
                expected_data_updated = copy.deepcopy(expected_data)
                expected_data_updated["data"]["label"] = expected_data_updated["data"]["label"] + "_updated"
                self.sample.bump_resource_version(expected_data_updated)

                test_item = {
                    "ws_href": response["ws_href"],
                    "expected_data": expected_data,
                    "expected_data_updated": expected_data_updated,
                    "version": curr_version,
                    "resource": curr_resource,
                    "ws_client": ws_client
                }
                self.test_items.append(test_item)
 def setUp(self):
     # -----------------------------------------------------------------------------
     # Test root: <server_proto>://<server_ip>:<server_port>/x-nmos/query/vX.X/
     #            [subscriptions]/?
     # -----------------------------------------------------------------------------
     self.test_arr = list()
     for version in defines.VERSIONS:
         self.test_arr.append({
             "url": "{}/{}/subscriptions".format(defines._BASE_QUERY_URL, version),
             "version": version
         })
         self.test_arr.append({
             "url": "{}/{}/subscriptions/".format(defines._BASE_QUERY_URL, version),
             "version": version
         })
     self.validator = tools.JsonSchemaValidator()
 def setUp(self):
     self.sample = tools.sample_data()
     self.sample.post_sample_data(versions=defines.VERSIONS,
                                  resources=defines._RESOURCES)
     self.validator = tools.JsonSchemaValidator()
     self.test_arr = list()
     for version in defines.VERSIONS:
         for resource in defines._RESOURCES:
             self.test_arr.append({
                 "version":
                 version,
                 "url":
                 "{}/{}/{}s/{}".format(
                     defines._BASE_QUERY_URL, version, resource,
                     self.sample.get_sample_data(
                         resource=resource, version=version)["data"]["id"])
             })
    def setUp(self):
        random_id = str(uuid.uuid4())
        self.validator = tools.JsonSchemaValidator()

        self.invalid_test_arr = [
            {"version": "v1.0", "url": "{}a".format(defines._BASE_QUERY_URL)},
            {"version": "v1.0", "url": "{}/x1.0".format(defines._BASE_QUERY_URL)}
        ]
        res = copy.deepcopy(defines._RESOURCES)
        res.append("subscription")
        for v in defines.VERSIONS:
            for r in res:
                self.invalid_test_arr.append({"version": v, "url": "{}/{}/{}".format(defines._BASE_QUERY_URL, v, r)})
                self.invalid_test_arr.append(
                    {"version": v, "url": "{}/{}/{}s/{}".format(defines._BASE_QUERY_URL, v, r, random_id)})
                self.invalid_test_arr.append(
                    {"version": v, "url": "{}/{}/{}s/{}/".format(defines._BASE_QUERY_URL, v, r, random_id)})
    def setUp(self):
        """Post subscription"""

        self.test_arr = list()
        for version in defines.VERSIONS:
            self.test_arr.append({
                "url": "{}/{}/subscriptions".format(defines._BASE_QUERY_URL, version),
                "version": version
            })
        self.sample = tools.sample_data()
        self.valid_sub_request_data = self.sample._get_valid_subscription_data()
        self.valid_sub_request_data_persist = copy.deepcopy(self.sample._get_valid_subscription_data())
        self.valid_sub_request_data_persist["persist"] = True

        self.invalid_sub_request_data = copy.deepcopy(self.valid_sub_request_data)
        del self.invalid_sub_request_data["resource_path"]

        self.validator = tools.JsonSchemaValidator()
 def setUp(self):
     # -----------------------------------------------------------------------------
     # Test root: <server_proto>://<server_ip>:<server_port>/x-nmos/query/vX.X/
     #            [nodes|devices|senders|receivers|flows|sources]/?
     # -----------------------------------------------------------------------------
     self.test_arr = list()
     for curr_version in defines.VERSIONS:
         for curr_resource in defines._RESOURCES:
             self.test_arr.append({
                 "url": "{}/{}/{}s".format(defines._BASE_QUERY_URL, curr_version, curr_resource),
                 "resource": curr_resource,
                 "version": curr_version
             })
             self.test_arr.append({
                 "url": "{}/{}/{}s/".format(defines._BASE_QUERY_URL, curr_version, curr_resource),
                 "resource": curr_resource,
                 "version": curr_version
             })
     self.validator = tools.JsonSchemaValidator()