Example #1
0
 def test0300(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")
     got = json.loads(self.resp_val)
     cmp, diff = target.intersectCmp(self.json_value, got)
     self.assertTrue(cmp, diff)
Example #2
0
 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)
Example #3
0
 def test0300(self):
     xpath = ("/local-routes/static-routes/static[prefix=%s]/"
              "next-hops/next-hop[index=%d]/state") % (self.prefix,
                                                       self.index)
     resp_val = self.gNMIGetJson(xpath)
     self.assertJsonModel(
         resp_val, 'local_routes.static_routes.static.next_hops.'
         'next_hop.state.state',
         'gNMI Get on the /state container does not match model')
     got = json.loads(resp_val)
     cmp, diff = target.intersectCmp(got, self.want)
     self.assertTrue(cmp, diff)
Example #4
0
 def test0200(self):
     """"""
     self.assertArgs(["xpath", "want"])
     self.assertXpath(self.xpath)
     resp_val = self.gNMIGet(self.xpath)
     self.assertIsNotNone(resp_val, "No gNMI GET response")
     got = target.typedValueToPython(resp_val, type(self.want))
     self.assertEqual(type(got), type(self.want),
                      "Values of different types")
     if isinstance(self.want, dict):
         cmp, diff = target.intersectCmp(self.want, got)
         self.assertTrue(cmp, diff)
     else:
         self.assertEqual(self.want, got)
Example #5
0
    def assertJsonCmp(self, json_value: Union[str, bytes], want: dict):
        """Assert that the JSON response matches the wanted values..

        Args:
            json_value: JSON-IETF gNMI response to check.
            want: Dictionary of wanted values.

        Raises:
          AssertionError if unable to compare, of the the wanted values are not
            present in the response.
        """
        got = json.loads(json_value)
        cmp, diff = target.intersectCmp(
            json.loads(pybindJSON.dumps(want, mode='ietf')), got)
        self.assertTrue(cmp, diff)
Example #6
0
 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)
Example #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)
Example #8
0
 def test_intersectCmp(self, name, a, b, want_cmp, want_diff):
     self.assertEqual(target.intersectCmp(a, b), (want_cmp, want_diff),
                      name)