Example #1
0
def test_author_without_last_name():
    schema = AuthorSchemaV1()

    dump = {"full_name": "Frank Castle"}
    expected = {"full_name": "Frank Castle", "first_name": "Frank Castle"}
    result = schema.dumps(dump).data

    assert expected == orjson.loads(result)
Example #2
0
def test_author_with_with_inspire_roles():
    schema = AuthorSchemaV1()
    dump = {"full_name": "Smith, John", "inspire_roles": ["author"]}
    expected = {
        "full_name": "Smith, John",
        "first_name": "John",
        "last_name": "Smith",
        "inspire_roles": ["author"],
    }
    result = schema.dumps(dump).data

    assert expected == orjson.loads(result)
Example #3
0
def test_author():
    schema = AuthorSchemaV1()

    dump = {"full_name": "Castle, Frank"}
    expected = {
        "full_name": "Castle, Frank",
        "first_name": "Frank",
        "last_name": "Castle",
    }
    result = schema.dumps(dump).data

    assert expected == json.loads(result)
Example #4
0
def test_author_with_bai():
    schema = AuthorSchemaV1()

    dump = {
        "full_name": "Frank Castle",
        "ids": [{
            "schema": "INSPIRE BAI",
            "value": "Frank.Castle.1"
        }],
    }
    expected = {
        "full_name": "Frank Castle",
        "first_name": "Frank Castle",
        "bai": "Frank.Castle.1",
        "ids": [{
            "schema": "INSPIRE BAI",
            "value": "Frank.Castle.1"
        }],
    }
    result = schema.dumps(dump).data

    assert expected == orjson.loads(result)
Example #5
0
def test_author_schema_returns_empty_for_supervisor():
    schema = AuthorSchemaV1()
    dump = {"full_name": "Smith, John", "inspire_roles": ["supervisor"]}
    result = schema.dumps(dump).data

    assert orjson.loads(result) == {}