def test_valid_unkown(): valid_unknown = { "name": "Entity One", "identifiers": { "unknown": "12345abcde" } } assert valid_unknown == AffiliationSchema().load(valid_unknown)
def test_invalid_no_name(): invalid_no_name = { "identifiers": [{ "identifier": "03yrm5c26", "scheme": "ror" }] } with pytest.raises(ValidationError): data = AffiliationSchema().load(invalid_no_name)
def test_valid(): valid_full = { "name": "Entity One", "identifiers": [{ "identifier": "03yrm5c26", "scheme": "ror" }] } assert valid_full == AffiliationSchema().load(valid_full)
def test_invalid_unkown(): invalid_unknown = { "name": "Entity One", "identifiers": [{ "identifier": "12345abcde", "scheme": "unknown" }] } with pytest.raises(ValidationError): data = AffiliationSchema().load(invalid_unknown)
def test_invalid_value(): invalid_no_value = { "name": "Entity One", "identifiers": [{ "identifier": "inv", "scheme": "ror" }] } with pytest.raises(ValidationError): data = AffiliationSchema().load(invalid_no_value)
def test_valid_empty_scheme(): valid_affiliation = { "name": "Entity One", "identifiers": [{ "identifier": "03yrm5c26", "scheme": "" }] } loaded = AffiliationSchema().load(valid_affiliation) valid_affiliation["identifiers"][0]["scheme"] = "ror" assert valid_affiliation == loaded
def test_invalid_empty(): invalid_empty = {} with pytest.raises(ValidationError): data = AffiliationSchema().load(invalid_empty)
def test_invalid_both_id_name(): invalid_id_name = {"id": "test", "name": "Entity One"} with pytest.raises(ValidationError): data = AffiliationSchema().load(invalid_id_name)
def test_valid_name(): valid_name = {"name": "Entity One"} assert valid_name == AffiliationSchema().load(valid_name)
def test_valid_id(): valid_id = { "id": "test", } assert valid_id == AffiliationSchema().load(valid_id)
def test_invalid_empty(): invalid_empty = {"name": "Entity One", "identifiers": [{}]} with pytest.raises(ValidationError): data = AffiliationSchema().load(invalid_empty)
def test_valid_empty_identifiers(): valid_affiliation = {"name": "Entity One", "identifiers": []} assert valid_affiliation == AffiliationSchema().load(valid_affiliation)
def test_valid_no_identifiers(): valid_affiliation = { "name": "Entity One", } assert valid_affiliation == AffiliationSchema().load(valid_affiliation)
def test_invalid_empty_key(): invalid_key = {"name": "Entity One", "identifiers": {"": "03yrm5c26"}} with pytest.raises(ValidationError): data = AffiliationSchema().load(invalid_key)
def test_invalid_empty_value(): invalid_value = {"name": "Entity One", "identifiers": {"ror": ""}} with pytest.raises(ValidationError): data = AffiliationSchema().load(invalid_value)