def test_parse_iglu_uri(self):
     assert (SchemaKey.parse_key(
         "iglu:com.snowplowanalytics.snowplow/event/jsonschema/1-0-1").
             as_uri() == SchemaKey(
                 "com.snowplowanalytics.snowplow",
                 "event",
                 "jsonschema",
                 SchemaVer(1, 0, 1),
             ).as_uri())
 def test_can_lookup_schema_in_bootstrap_resolver(self, json_config):
     schema_key = SchemaKey(
         "com.snowplowanalytics.iglu",
         "resolver-config",
         "jsonschema",
         SchemaVer(1, 0, 0),
     )
     schema = get_bootstrap_registry().lookup_schema(schema_key)
     expected = '{ "$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#", "description": "Schema for an Iglu resolver\'s configuration", "self": { "vendor": "com.snowplowanalytics.iglu", "name": "resolver-config", "format": "jsonschema", "version": "1-0-0" }, "type": "object", "properties": { "cacheSize": { "type": "number" }, "repositories": { "type": "array", "items": { "type": "object", "properties": { "name": { "type": "string" }, "priority": { "type": "number" }, "vendorPrefixes": { "type": "array", "items": { "type": "string" } }, "connection": { "type": "object", "oneOf": [ { "properties": { "embedded": { "type": "object", "properties": { "path": { "type": "string" } }, "required": ["path"], "additionalProperties": false } }, "required": ["embedded"], "additionalProperties": false }, { "properties": { "http": { "type": "object", "properties": { "uri": { "type": "string", "format": "uri" } }, "required": ["uri"], "additionalProperties": false } }, "required": ["http"], "additionalProperties": false } ] } }, "required": ["name", "priority", "vendorPrefixes", "connection"], "additionalProperties": false } } }, "required": ["cacheSize", "repositories"], "additionalProperties": false }'
     assert schema == json.loads(expected)
    def test_stores_schemas_in_cache(self, json_config):
        ref_config = RegistryRefConfig("Test registry ref", 5, [])
        registry = HttpRegistryRef(ref_config, "http://iglucentral.com")
        resolver = Resolver([registry])
        key1 = SchemaKey(
            "com.snowplowanalytics.snowplow.enrichments",
            "api_request_enrichment_config",
            "jsonschema",
            SchemaVer(1, 0, 0),
        )
        key2 = SchemaKey(
            "com.snowplowanalytics.snowplow",
            "duplicate",
            "jsonschema",
            SchemaVer(1, 0, 0),
        )
        key3 = SchemaKey(
            "com.snowplowanalytics.iglu",
            "resolver-config",
            "jsonschema",
            SchemaVer(1, 0, 0),
        )
        key4 = SchemaKey(
            "com.snowplowanalytics.iglu",
            "resolver-config",
            "jsonschema",
            SchemaVer(1, 0, 0),
        )

        resolver.lookup_schema(key1)
        resolver.lookup_schema(key2)
        resolver.lookup_schema(key2)
        resolver.lookup_schema(key3)
        resolver.lookup_schema(key4)

        assert len(resolver.cache) == 3
 def test_parse_invalid_schemaver_upper_case_letters(self):
     with pytest.raises(IgluError):
         SchemaVer.parse_schemaver("A-B-C")
 def test_parse_invalid_schemaver_dot_formatted(self):
     with pytest.raises(IgluError):
         SchemaVer.parse_schemaver("2.0.3")
 def test_parse_invalid_schemaver_lower_case_letters(self):
     with pytest.raises(IgluError):
         SchemaVer.parse_schemaver("a-b-c")
 def test_parse_invalid_schemaver_0_based_versioning(self):
     with pytest.raises(IgluError):
         SchemaVer.parse_schemaver("0-1-2")
 def test_parse_invalid_schemaver_has_letters_and_numers(self):
     with pytest.raises(IgluError):
         SchemaVer.parse_schemaver("10-a-1")
 def test_parse_schemaver_multi_digits(self):
     assert (SchemaVer.parse_schemaver("10-0-112").as_string() == SchemaVer(
         10, 0, 112).as_string())
 def test_parse_schemaver(self):
     assert (SchemaVer.parse_schemaver("2-0-3").as_string() == SchemaVer(
         2, 0, 3).as_string())