test_12_CheckAndFix_talk.py 1.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
# -*- coding: utf-8 -*-
"""test_12_CheckAndFix_thesis

    * Test CheckAndFix methods for thesis.
      Use the one talk in cds.cern.ch

        - is_thesis
        - submitted
        - format_universities
        - format_authors (already test with article)
        - get_my_authors (already test with article)

"""
import pytest
from harvest_tools.checkandfix import CheckAndFix
from invenio_tools import load_record


@pytest.fixture(scope="module")
def reccds():
    return load_record("cds.cern.ch", 1394605)


@pytest.fixture(scope="module")
def svc():
    return CheckAndFix()


def test_is_thesis(svc, reccds):
    assert svc.is_thesis(reccds) is None


def test_submitted(svc, reccds):

    assert reccds.these_defense() == "2011"
    assert reccds.submitted() == ""

    svc.submitted(reccds)
    assert reccds.submitted() == "2011-11"


def test_format_universities(svc, reccds):

    # Khanji en 2011 (Université de la Méditerrannée)
    assert reccds[u"dissertation_note"][u"university"] == \
        "Marseille U., Luminy"

    svc.format_universities(reccds)
    assert reccds[u"dissertation_note"][u"university"] == \
        u"Université de la Méditerrannée Aix-Marseille II"

    # Chen en 2013 (Aix marseille Université)
    reccds2 = load_record("cds.cern.ch", 1632177)

    assert reccds2[u"dissertation_note"][u"university"] == \
        u"Shandong U. & Marseille, CPPM"

    svc.format_universities(reccds2)
    assert reccds2[u"dissertation_note"][u"university"] == \
        u"Aix Marseille Université"