# from unittest.mock import patch


import json
import unittest

from dacsspace.validator import Validator


class TestValidator(unittest.TestCase):
    def test_validator(self):
        valid_json = "fixtures/valid_resource.json"
        invalid_fixtures = [
            "fixtures/multiple_invalid.json",
            "fixtures/no_metadata_rights.json"]
        with open(valid_json, 'r') as v:
            valid_json = json.load(v)
            result = Validator().validate_data(valid_json)
        self.assertTrue(isinstance(result, dict))
        self.assertEqual(result["valid"], True)
        for f in invalid_fixtures:
            with open(f, 'r') as i:
                invalid_json = json.load(i)
                result = Validator().validate_data(invalid_json)
            self.assertTrue(isinstance(result, dict))
            self.assertEqual(result["valid"], False)

@@ -1,40 +1,4 @@
-# from unittest.mock import patch%0A%0A%0A
 impo
@@ -5,16 +5,26 @@
 rt json%0A
+import os%0A
 import u
@@ -32,16 +32,63 @@
 ittest%0A%0A
+from jsonschema.exceptions import SchemaError%0A%0A
 from dac
@@ -163,16 +163,1070 @@
 tCase):%0A
+    def test_schema(self):%0A        %22%22%22Asserts schema identifiers and filenames are handled correctly.%22%22%22%0A%0A        test_schema_filepath = %22test_schema.json%22%0A%0A        # handling for schema identifier%0A        validator = Validator('single_level_required', None)%0A        self.assertEqual(validator.schema%5B%22$id%22%5D, 'single_level_required.json')%0A%0A        validator = Validator('single_level_required.json', None)%0A        self.assertEqual(validator.schema%5B%22$id%22%5D, 'single_level_required.json')%0A%0A        # passing external filename%0A        with open(test_schema_filepath, %22w%22) as sf:%0A            json.dump(%7B%22$id%22: %22test_schema.json%22%7D, sf)%0A        validator = Validator(None, test_schema_filepath)%0A        self.assertEqual(validator.schema%5B%22$id%22%5D, test_schema_filepath)%0A%0A        # invalid external schema%0A        with open(test_schema_filepath, %22w%22) as sf:%0A            json.dump(%7B%22type%22: 12%7D, sf)%0A        with self.assertRaises(SchemaError):%0A            validator = Validator(None, test_schema_filepath)%0A%0A        # cleanup%0A        os.remove(test_schema_filepath)%0A%0A
     def 
@@ -1524,32 +1524,94 @@
 ult = Validator(
+%0A                'single_level_required',%0A                None
 ).validate_data(
@@ -1835,16 +1835,16 @@
 load(i)%0A
-
         
@@ -1870,16 +1870,86 @@
 lidator(
+%0A                    'single_level_required',%0A                    None
 ).valida

update tests