Пример #1
0
def test_load_preprint_date():
    form = {**DEFAULT_DATA_TO_LOAD, "preprint_date": "2019-10-15"}

    expected = {**DEFAULT_LOAD, "preprint_date": "2019-10-15"}
    result = Literature().load(form).data

    assert result == expected
Пример #2
0
def test_load_language():
    form = {**DEFAULT_DATA_TO_LOAD, "language": "fr"}

    expected = {**DEFAULT_LOAD, "languages": ["fr"]}
    result = Literature().load(form).data

    assert result == expected
Пример #3
0
def test_load_document_type():
    form = {**DEFAULT_DATA_TO_LOAD, "document_type": "book"}

    expected = {**DEFAULT_LOAD, "document_type": ["book"]}
    result = Literature().load(form).data

    assert result == expected
Пример #4
0
def test_load_language_ignores_en():
    form = {**DEFAULT_DATA_TO_LOAD, "language": "en"}

    expected = {**DEFAULT_LOAD}
    result = Literature().load(form).data

    assert result == expected
Пример #5
0
def test_dump_authors():
    data = {
        **DEFAULT_DATA_TO_DUMP,
        "authors": [
            {
                "full_name": "Harun Urhan",
                "affiliations": [{
                    "value": "CERN"
                }]
            },
            {
                "full_name": "Ahmet Urhan"
            },
        ],
    }
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {
        **DEFAULT_DUMP,
        "authors": [
            {
                "full_name": "Harun Urhan",
                "affiliation": "CERN"
            },
            {
                "full_name": "Ahmet Urhan"
            },
        ],
    }

    assert result == expected
Пример #6
0
def test_dump_institution():
    data = {**DEFAULT_DATA_TO_DUMP, "thesis_info": {"institutions": [{"name": "CERN"}]}}
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {**DEFAULT_DUMP, "institution": "CERN"}

    assert result == expected
Пример #7
0
def test_dump_volume():
    data = {**DEFAULT_DATA_TO_DUMP, "publication_info": [{"journal_issue": "1"}]}
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {**DEFAULT_DUMP, "issue": "1"}

    assert result == expected
Пример #8
0
def test_dump_abstract():
    data = {**DEFAULT_DATA_TO_DUMP, "abstracts": [{"value": "An Abstract"}]}
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {**DEFAULT_DUMP, "abstract": "An Abstract"}

    assert result == expected
Пример #9
0
def test_dump_title():
    data = {**DEFAULT_DATA_TO_DUMP, "titles": [{"title": "A Title"}]}
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {**DEFAULT_DUMP, "title": "A Title"}

    assert result == expected
Пример #10
0
def test_dump_defense_date():
    data = {**DEFAULT_DATA_TO_DUMP, "thesis_info": {"defense_date": "1993"}}
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {**DEFAULT_DUMP, "defense_date": "1993"}

    assert result == expected
Пример #11
0
def test_dump_document_type():
    data = {**DEFAULT_DATA_TO_DUMP, "document_type": ["book"]}
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {**DEFAULT_DUMP, "document_type": "book"}

    assert result == expected
Пример #12
0
def test_dump_publisher():
    data = {**DEFAULT_DATA_TO_DUMP, "imprints": [{"publisher": "CERN"}]}
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {**DEFAULT_DUMP, "publisher": "CERN"}

    assert result == expected
Пример #13
0
def test_dump_page_range_with_artid():
    data = {**DEFAULT_DATA_TO_DUMP, "publication_info": [{"artid": "1"}]}
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {**DEFAULT_DUMP, "page_range": "1"}

    assert result == expected
Пример #14
0
def test_dump_prerint_date():
    data = {**DEFAULT_DATA_TO_DUMP, "preprint_date": "2019-10-15"}
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {**DEFAULT_DUMP, "preprint_date": "2019-10-15"}

    assert result == expected
Пример #15
0
def test_dump_volume():
    data = {**DEFAULT_DATA_TO_DUMP, "publication_info": [{"year": 2000}]}
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {**DEFAULT_DUMP, "year": 2000}

    assert result == expected
Пример #16
0
def test_dump_language():
    data = {**DEFAULT_DATA_TO_DUMP, "languages": ["fr"]}
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {**DEFAULT_DUMP, "language": "fr"}

    assert result == expected
Пример #17
0
def test_dump_publication_place():
    data = {**DEFAULT_DATA_TO_DUMP, "imprints": [{"place": "Switzerland"}]}
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {**DEFAULT_DUMP, "publication_place": "Switzerland"}

    assert result == expected
Пример #18
0
def test_dump_doi():
    doi = faker.doi()
    data = {**DEFAULT_DATA_TO_DUMP, "dois": [{"value": doi}]}
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {**DEFAULT_DUMP, "doi": doi}

    assert result == expected
Пример #19
0
def test_dump_arxiv_id():
    arxiv_id = faker.arxiv()
    data = {**DEFAULT_DATA_TO_DUMP, "arxiv_eprints": [{"value": arxiv_id}]}
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {**DEFAULT_DUMP, "arxiv_id": arxiv_id}

    assert result == expected
Пример #20
0
def test_dump_journal_title():
    data = {
        **DEFAULT_DATA_TO_DUMP,
        "publication_info": [{"journal_title": "A Journal"}],
    }
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {**DEFAULT_DUMP, "journal_title": "A Journal"}

    assert result == expected
Пример #21
0
def test_dump_report_numbers():
    data = {
        **DEFAULT_DATA_TO_DUMP,
        "report_numbers": [{"value": "Report1"}, {"value": "Report2"}],
    }
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {**DEFAULT_DUMP, "report_numbers": ["Report1", "Report2"]}

    assert result == expected
Пример #22
0
def test_dump_subjects():
    data = {
        **DEFAULT_DATA_TO_DUMP,
        "inspire_categories": [{"term": "Accelerators"}, {"term": "Computing"}],
    }
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {**DEFAULT_DUMP, "subjects": ["Accelerators", "Computing"]}

    assert result == expected
Пример #23
0
def test_load_authors():
    form = {
        **DEFAULT_DATA_TO_LOAD,
        "authors": [{"full_name": "Urhan, Harun", "affiliation": "CERN"}],
    }

    expected = {
        **DEFAULT_LOAD,
        "authors": [{"full_name": "Urhan, Harun", "affiliations": [{"value": "CERN"}]}],
    }
    result = Literature().load(form).data

    assert result == expected
Пример #24
0
def test_load_parent_book_record():
    form = {
        **DEFAULT_DATA_TO_LOAD,
        "parent_book_record": {"$ref": "http://api/literature/123"},
    }

    expected = {
        **DEFAULT_LOAD,
        "publication_info": [{"parent_record": {"$ref": "http://api/literature/123"}}],
    }
    result = Literature().load(form).data

    assert result == expected
Пример #25
0
def test_dump_page_range_and_start_end_pages():
    data = {
        **DEFAULT_DATA_TO_DUMP,
        "publication_info": [{"page_start": "1", "page_end": "100"}],
    }
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {
        **DEFAULT_DUMP,
        "page_range": "1-100",
        "start_page": "1",
        "end_page": "100",
    }

    assert result == expected
Пример #26
0
def test_dump_experiment():
    data = {
        **DEFAULT_DATA_TO_DUMP,
        "accelerator_experiments": [
            {"legacy_name": "CMS", "record": {"$ref": "http://api/experiments/123"}}
        ],
    }
    record = faker.record("lit", data=data)

    result = Literature().dump(record).data
    expected = {
        **DEFAULT_DUMP,
        "experiment": "CMS",
        "experiment_record": {"$ref": "http://api/experiments/123"},
    }

    assert result == expected