예제 #1
0
 def test0000(self):
     """Check testcase arguments."""
     self.assertArgs(["xpath", "json_value", "model"])
     self.assertXpath(self.xpath)
     self.assertIsInstance(self.json_value, dict,
                           "The value is not a valid JSON object")
     self.assertModelXpath(self.model, self.xpath)
     model = schema.ocContainerFromPath(self.model, self.xpath)
     self.assertJsonModel(json.dumps(self.json_value), model,
                          "JSON value to Set does not match the model")
예제 #2
0
 def test0200(self):
     """"""
     resp = self.gNMIGet(self.xpath)
     self.assertIsNotNone(resp, "No gNMI GET response")
     self.resp_val = resp.json_ietf_val
     self.assertIsNotNone(self.resp_val,
                          "The gNMI GET response is not JSON IETF")
     model = schema.ocContainerFromPath(self.model, self.xpath)
     self.assertJsonModel(self.resp_val, model,
                          "Get response JSON does not match the model")
예제 #3
0
파일: testbase.py 프로젝트: jihaix/gnxi
    def assertModelXpath(self, model: str, xpath: str):
        """Assert that the model and xpath correspond to a valid OC container.

        Args:
            model: the OC model class name in the oc_config_validate.models
              package, as `module.class`.
            xpath: the xpath to the OC container to create.

        Raises: AssertionError.
        """
        match, error = True, None
        try:
            schema.ocContainerFromPath(model, xpath)
        except (AttributeError, target.XpathError, schema.Error) as err:
            match, error = False, err
        self.assertTrue(
            match,
            "xpath %s does not point to a container in model %s: %s" % (
                xpath, model, error))
예제 #4
0
파일: config_state.py 프로젝트: jihaix/gnxi
 def test0200(self):
     """gNMI Get on /config"""
     self.assertArgs(["xpath", "model", "json_value"])
     xpath = self.xpath.rstrip("/") + "/config"
     resp_val = self.gNMIGetJson(xpath)
     model = schema.ocContainerFromPath(self.model, xpath)
     self.assertJsonModel(resp_val, model,
                          "Get /config does not match the model")
     got = json.loads(resp_val)
     cmp, diff = target.intersectCmp(self.json_value, got)
     self.assertTrue(cmp, diff)
예제 #5
0
파일: config_state.py 프로젝트: jihaix/gnxi
 def test0100(self):
     """gNMI Set on /config"""
     self.assertArgs(["xpath", "model", "json_value"])
     xpath = self.xpath.rstrip("/") + "/config"
     self.assertXpath(xpath)
     self.assertModelXpath(self.model, xpath)
     self.assertIsInstance(self.json_value, dict,
                           "The value is not a valid JSON object")
     model = schema.ocContainerFromPath(self.model, xpath)
     self.assertJsonModel(json.dumps(self.json_value), model,
                          "JSON value to Set does not match the model")
     self.assertTrue(
         self.gNMISetUpdate(xpath, self.json_value),
         "gNMI Set did not succeed.")
예제 #6
0
파일: config_state.py 프로젝트: jihaix/gnxi
 def test0300(self):
     """gNMI Get on /state"""
     self.assertArgs(["xpath", "model", "json_value"])
     xpath = self.xpath.rstrip("/") + "/state"
     resp = self.gNMIGet(xpath)
     self.assertIsNotNone(resp, "No gNMI GET response")
     resp_val = resp.json_ietf_val
     self.assertIsNotNone(resp_val,
                          "The gNMI GET response is not JSON IETF")
     model = schema.ocContainerFromPath(self.model, xpath)
     self.assertJsonModel(resp_val, model,
                          "Get /state does not match the model")
     got = json.loads(resp_val)
     cmp, diff = target.intersectCmp(self.json_value, got)
     self.assertTrue(cmp, diff)
예제 #7
0
 def test0200(self):
     """"""
     self.assertArgs(["xpath", "want_json", "model"])
     self.assertXpath(self.xpath)
     self.assertModelXpath(self.model, self.xpath)
     self.assertIsInstance(self.want_json, dict,
                           "'want_json' is not a valid JSON object")
     resp = self.gNMIGet(self.xpath)
     self.assertIsNotNone(resp, "No gNMI GET response")
     resp_val = resp.json_ietf_val
     self.assertIsNotNone(resp_val,
                          "The gNMI GET response is not JSON IETF")
     model = schema.ocContainerFromPath(self.model, self.xpath)
     self.assertJsonModel(resp_val, model,
                          "Get response does not match the model")
     got = json.loads(resp_val)
     cmp, diff = target.intersectCmp(self.want_json, got)
     self.assertTrue(cmp, diff)