def test_load_remote_schema(self, m_urlopen, m_yaml):

        sample_dict = {"key": "content"}
        m_yaml.load.return_value = sample_dict

        # Ensure that urlopen is accessing the same address of the argument
        load_remote_schema("url")
        self.assertEqual(m_urlopen.call_args, mock.call("url"))

        # Ensure it raises error on loading an invalid schema
        m_yaml.load.return_value = "not a dict"
        self.assertRaises(AssertionError, load_remote_schema, "url")

        # Ensure that a dictionary is allowed to be returned
        m_yaml.load.return_value = sample_dict
        return_dict = load_remote_schema("url")
        self.assertEqual(sample_dict, return_dict)
示例#2
0
 def test_load_valid_remote_schema(self):
     """
     Test if the load_remote_schema is
     retrieving and loading the templates correctly.
     """
     schema = load_remote_schema(
         "https://raw.githubusercontent.com/"
         "sonata-nfv/son-schema/master/package-descriptor/pd-schema.yml")
     self.assertIsInstance(schema, dict)
示例#3
0
 def test_load_valid_remote_schema(self):
     """
     Test if the load_remote_schema is
     retrieving and loading the templates correctly.
     """
     schema = load_remote_schema(
         "https://raw.githubusercontent.com/"
         "sonata-nfv/son-schema/master/package-descriptor/pd-schema.yml")
     self.assertIsInstance(schema, dict)