コード例 #1
0
    def test_load_local_schema(self, m_os_path, m_open, m_yaml):
        # Ensure that a FileNotFoundError is raised
        # when the file does not exist
        m_os_path.isfile.return_value = False
        self.assertRaises(
            FileNotFoundError, load_local_schema, "/some/file/path")

        # Ensure a correct schema format and
        # a correct opening of the schema file
        m_os_path.isfile.return_value = True
        m_open.return_value = None
        m_yaml.load.return_value = "not a dict"
        self.assertRaises(
            AssertionError, load_local_schema, "/some/file/path")

        self.assertEqual(m_open.call_args,
                         mock.call('/some/file/path', 'r'))

        # Ensure that a dictionary is allowed to be returned
        sample_dict = {'dict_key': 'this is a dict'}
        m_os_path.isfile.return_value = True
        m_open.return_value = None
        m_yaml.load.return_value = sample_dict
        return_dict = load_local_schema("/some/file/path")
        self.assertEqual(sample_dict, return_dict)
コード例 #2
0
    def test_load_valid_local_schema(self):
        """ Test if the load schema is correctly loading the templates """
        # Access to local stored schemas for this test
        schema_f = pkg_resources.resource_filename(
            __name__, os.path.join("son-schema", 'pd-schema.yml'))

        schema = load_local_schema(schema_f)
        self.assertIsInstance(schema, dict)

        schema_f = pkg_resources.resource_filename(
            __name__, os.path.join("son-schema", 'nsd-schema.yml'))

        schema = load_local_schema(schema_f)
        self.assertIsInstance(schema, dict)

        schema_f = pkg_resources.resource_filename(
            __name__, os.path.join("son-schema", 'vnfd-schema.yml'))

        schema = load_local_schema(schema_f)
        self.assertIsInstance(schema, dict)
コード例 #3
0
    def test_load_valid_local_schema(self):
        """ Test if the load schema is correctly loading the templates """
        # Access to local stored schemas for this test
        schema_f = pkg_resources.resource_filename(
            __name__, os.path.join("son-schema", 'pd-schema.yml'))

        schema = load_local_schema(schema_f)
        self.assertIsInstance(schema, dict)

        schema_f = pkg_resources.resource_filename(
            __name__, os.path.join("son-schema", 'nsd-schema.yml'))

        schema = load_local_schema(schema_f)
        self.assertIsInstance(schema, dict)

        schema_f = pkg_resources.resource_filename(
            __name__, os.path.join("son-schema", 'vnfd-schema.yml'))

        schema = load_local_schema(schema_f)
        self.assertIsInstance(schema, dict)