def test_validate_context_pass_context_single_name_value(): input_dict = { "@context": { "favoriteColor": "https://example.com/vocab#favoriteColor" } } ContextHandler._validate_context(input_dict)
def test_validate_context_fail_context_not_dict_or_list(): input_dict = { "@context": "Thing" } with pytest.raises(Exception) as e: ContextHandler._validate_context(input_dict) assert "'@context' value must be list or dict" in str(e.value)
def test_validate_context_fail_no_context_property(): input_dict = { "name": "Thing" } with pytest.raises(Exception) as e: ContextHandler._validate_context(input_dict) assert "Context missing '@context' property" in str(e.value)
def test_validate_context_pass_context_w3c_example_15(): input_dict = { "@context": { "referenceNumber": "https://example.com/vocab#referenceNumber", "favoriteFood": "https://example.com/vocab#favoriteFood" } } ContextHandler._validate_context(input_dict)
def test_validate_context_pass_context_w3c_examples_v1(): # test for https://www.w3.org/2018/credentials/examples/v1 ContextHandler._validate_context(w3c_example_v1)
def test_validate_context_fail_on_empty(): with pytest.raises(Exception) as e: ContextHandler._validate_context({}) assert "Context missing '@context' property" in str(e.value)
def test_validate_context_pass_context_w3c_base(): # pasted directly out of the reference file, without any format changes # change true to True to correct for python # Sample from specification: https://w3c.github.io/vc-data-model/#base-context # Actual file contents from: https://www.w3.org/2018/credentials/v1 ContextHandler._validate_context(w3c_base)