test_acti_ins1276938_fix.py 1.86 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# -*- coding: utf-8 -*-
"""PROCEEDING

    http://inspirehep.net/record/1276938

    ATLAS studies on Higgs to diboson states
    F Hubaut for the Atlas collaboration
    48th Rencontres de Moriond on Electroweak Interactions and Unified Theories
    La Thuile, Italy, 2-9 Mar 2013

No corrections are applied to the record.
Allow to test the brute force decoding with its mistakes.

Note:
    * Only first author is defined
    * Collaboration is not well formed ATLAS
    * First author affiliation is not defined
    * Submitted date is not defined
    * Year is not defined

"""
22
import copy
23 24 25
import pytest


LE GAC Renaud's avatar
LE GAC Renaud committed
26 27 28 29
from harvest_tools import (CheckAndFix,
                           CheckException,
                           format_author_fr,
                           ToolException)
30
from invenio_tools import load_record
31 32 33 34 35 36 37 38


@pytest.fixture(scope="module")
def record():
    rec = load_record('inspirehep.net', 1276938)
    return rec


39 40 41 42
@pytest.fixture(scope="module")
def recordfix(record):
    rec = copy.deepcopy(record)

43
    svc = CheckAndFix()
44
    svc.authors(rec)
45 46
    svc.country(rec)
    svc.conference_date(rec)
47 48 49 50 51 52 53 54 55
    svc.format_authors(rec, format_author_fr)
    svc.format_editor(rec)
    svc.submitted(rec)
    svc.year(rec)

    return rec


def test_authors(record, recordfix):
56
    assert record.authors() == "Hubaut, F."
57
    assert recordfix.authors() == "F. Hubaut"
58 59


60 61
def test_collaboration_exception(recordfix):
    svc = CheckAndFix()
LE GAC Renaud's avatar
LE GAC Renaud committed
62
    with pytest.raises(ToolException):
63
        svc.collaboration(recordfix)
64 65


66 67 68
def test_my_authors_exception(recordfix):
    svc = CheckAndFix()
    with pytest.raises(CheckException):
69
        svc.get_my_authors(recordfix)
70 71 72 73 74 75 76 77


def test_submitted(record, recordfix):
    assert record.submitted() == []
    assert recordfix.submitted() == ["2013-03-02"]


def test_year(record, recordfix):
78
    assert record.year() == ""
79 80
    assert recordfix.year() == "2013"