Example #1
0
def test_load_contacts():
    data_to_load = {
        **DEFAULT_DATA_DUMP,
        "contacts": [
            {
                "name": "Some name",
                "email": "some@email"
            },
            {
                "name": "other name",
                "email": "other@email"
            },
        ],
    }

    loaded_data = Job().load(data_to_load).data

    expected_data = {
        **DEFAULT_EXPECTED_DATA_AFTER_LOAD,
        "contact_details": [
            {
                "name": "Some name",
                "email": "some@email"
            },
            {
                "name": "other name",
                "email": "other@email"
            },
        ],
    }
    assert loaded_data == expected_data
Example #2
0
def test_load_required_data():
    data_to_load = {**DEFAULT_DATA_DUMP}

    loaded_data = Job().load(data_to_load).data

    expected_data = {**DEFAULT_EXPECTED_DATA_AFTER_LOAD}
    assert loaded_data == expected_data
Example #3
0
def test_dump_ref_letter_contact():
    data_to_load = {
        **DEFAULT_DATA_TO_DUMP,
        "reference_letters": {
            "emails": ["one@email", "second@email"],
            "urls": [
                {
                    "description": "Description of url",
                    "value": "http://url1"
                },
                {
                    "value": "http://url2"
                },
            ],
        },
    }

    record = JobsRecord(data_to_load)
    result = Job().dump(record).data

    expected_data = {
        **DEFAULT_EXPECTED_DATA_AFTER_DUMP,
        "reference_letters": [
            "one@email",
            "second@email",
            "http://url1",
            "http://url2",
        ],
    }
    assert result == expected_data
Example #4
0
def test_dump_required_data():
    data_to_load = {**DEFAULT_DATA_TO_DUMP}
    record = JobsRecord(data_to_load)
    result = Job().dump(record).data

    expected_data = {**DEFAULT_EXPECTED_DATA_AFTER_DUMP}

    assert result == expected_data
Example #5
0
def test_load_description():
    data_to_load = {**DEFAULT_DATA_DUMP, "description": "Test 1234"}

    loaded_data = Job().load(data_to_load).data

    expected_data = {
        **DEFAULT_EXPECTED_DATA_AFTER_LOAD, "description": "Test 1234"
    }
    assert loaded_data == expected_data
Example #6
0
def test_load_external_job_identifier():
    data_to_load = {**DEFAULT_DATA_DUMP, "external_job_identifier": "12345678"}

    loaded_data = Job().load(data_to_load).data

    expected_data = {
        **DEFAULT_EXPECTED_DATA_AFTER_LOAD,
        "external_job_identifier": "12345678",
    }
    assert loaded_data == expected_data
Example #7
0
def test_dump_external_job_identifier():
    data_to_load = {**DEFAULT_DATA_TO_DUMP, "description": "Test 1234"}

    record = JobsRecord(data_to_load)
    result = Job().dump(record).data

    expected_data = {
        **DEFAULT_EXPECTED_DATA_AFTER_DUMP, "description": "Test 1234"
    }

    assert result == expected_data
Example #8
0
def test_load_url():
    data_to_load = {**DEFAULT_DATA_DUMP, "url": "http://url"}

    loaded_data = Job().load(data_to_load).data

    expected_data = {
        **DEFAULT_EXPECTED_DATA_AFTER_LOAD,
        "urls": [{
            "value": "http://url"
        }],
    }
    assert loaded_data == expected_data
Example #9
0
def test_load_field_of_interest():
    data_to_load = {
        **DEFAULT_DATA_DUMP,
        "field_of_interest": ["cond-mat.dis-nn", "nlin.SI"],
    }

    loaded_data = Job().load(data_to_load).data

    expected_data = {
        **DEFAULT_EXPECTED_DATA_AFTER_LOAD,
        "arxiv_categories": ["cond-mat.dis-nn", "nlin.SI"],
    }
    assert loaded_data == expected_data
Example #10
0
def test_dump_field_of_interest():
    data_to_load = {
        **DEFAULT_DATA_TO_DUMP,
        "arxiv_categories": ["cond-mat.dis-nn", "nlin.SI"],
    }

    record = JobsRecord(data_to_load)
    result = Job().dump(record).data

    expected_data = {
        **DEFAULT_EXPECTED_DATA_AFTER_DUMP,
        "field_of_interest": ["cond-mat.dis-nn", "nlin.SI"],
    }

    assert result == expected_data
Example #11
0
def test_load_ref_letter_contact():
    data_to_load = {
        **DEFAULT_DATA_DUMP,
        "reference_letters": ["one@email", "http://url1"],
    }

    loaded_data = Job().load(data_to_load).data

    expected_data = {
        **DEFAULT_EXPECTED_DATA_AFTER_LOAD,
        "reference_letters": {
            "emails": ["one@email"],
            "urls": [{
                "value": "http://url1"
            }],
        },
    }
    assert loaded_data == expected_data
Example #12
0
def test_dump_url():
    data_to_load = {
        **DEFAULT_DATA_TO_DUMP,
        "urls": [
            {
                "value": "http://url",
                "description": "some description"
            },
            {
                "value": "httpL//url2"
            },
        ],
    }

    record = JobsRecord(data_to_load)
    result = Job().dump(record).data

    expected_data = {**DEFAULT_EXPECTED_DATA_AFTER_DUMP, "url": "http://url"}

    assert result == expected_data
Example #13
0
def test_dump_contacts():
    data_to_load = {
        **DEFAULT_DATA_TO_DUMP,
        "contact_details": [
            {
                "name": "Some name",
                "email": "some@email",
                "record": {
                    "$ref": "http://"
                }
            },
            {
                "name": "other name",
                "email": "other@email",
                "curated_relation": False
            },
        ],
    }

    record = JobsRecord(data_to_load)
    result = Job().dump(record).data

    expected_data = {
        **DEFAULT_EXPECTED_DATA_AFTER_DUMP,
        "contacts": [
            {
                "name": "Some name",
                "email": "some@email",
                "record": {
                    "$ref": "http://"
                }
            },
            {
                "name": "other name",
                "email": "other@email",
                "curated_relation": False
            },
        ],
    }

    assert result == expected_data
Example #14
0
def test_dump_experiments():
    data_to_load = {
        **DEFAULT_DATA_TO_DUMP,
        "accelerator_experiments": [
            {
                "legacy_name": "Experiment Name",
                "record": {
                    "$ref": "http://ref"
                }
            },
            {
                "legacy_name": "Another Experiment Name",
                "record": {
                    "$ref": "http://ref2"
                },
            },
        ],
    }

    record = JobsRecord(data_to_load)
    result = Job().dump(record).data

    expected_data = {
        **DEFAULT_EXPECTED_DATA_AFTER_DUMP,
        "experiments": [
            {
                "legacy_name": "Experiment Name",
                "record": {
                    "$ref": "http://ref"
                }
            },
            {
                "legacy_name": "Another Experiment Name",
                "record": {
                    "$ref": "http://ref2"
                },
            },
        ],
    }

    assert result == expected_data
Example #15
0
def test_load_experiments():
    data_to_load = {
        **DEFAULT_DATA_DUMP,
        "experiments": [
            {
                "legacy_name": "Experiment Name",
                "record": {
                    "$ref": "http://ref"
                }
            },
            {
                "legacy_name": "Another Experiment Name",
                "record": {
                    "$ref": "http://ref2"
                },
            },
        ],
    }

    loaded_data = Job().load(data_to_load).data

    expected_data = {
        **DEFAULT_EXPECTED_DATA_AFTER_LOAD,
        "accelerator_experiments": [
            {
                "legacy_name": "Experiment Name",
                "record": {
                    "$ref": "http://ref"
                }
            },
            {
                "legacy_name": "Another Experiment Name",
                "record": {
                    "$ref": "http://ref2"
                },
            },
        ],
    }
    assert loaded_data == expected_data