コード例 #1
0
ファイル: test_daemon.py プロジェクト: fschwenn/inspire-next
def test_check_if_daemon_has_cleaned_the_queue(small_app):
    """Check if the daemon has cleaned up the queue."""
    from inspirehep.modules.disambiguation.tasks import disambiguation_daemon

    disambiguation_daemon()

    assert DisambiguationRecord.query.count() == 0
コード例 #2
0
def test_check_if_daemon_has_cleaned_the_queue(small_app):
    """Check if the daemon has cleaned up the queue."""
    from inspirehep.modules.disambiguation.tasks import disambiguation_daemon

    disambiguation_daemon()

    assert DisambiguationRecord.query.count() == 0
コード例 #3
0
def test_count_phonetic_block_dispatched(small_app):
    """Count if two phonetic blocks were dispatched."""
    from inspirehep.modules.disambiguation.tasks import (
        disambiguation_daemon, )

    # Check if the queue has three records.
    assert DisambiguationRecord.query.count() == 3

    # Signature #1.
    glashow_record_id = str(
        PersistentIdentifier.get("literature", 4328).object_uuid)
    glashow_record = get_es_record_by_uuid(glashow_record_id)

    # Add phonetic block to the record.
    glashow_record['authors'][0]['signature_block'] = "GLASs"
    es.index(index='records-hep',
             doc_type='hep',
             id=glashow_record_id,
             body=glashow_record)
    es.indices.refresh('records-hep')

    # Signature #2.
    higgs_record_id_first = str(
        PersistentIdentifier.get("literature", 1358492).object_uuid)
    higgs_record_first = get_es_record_by_uuid(higgs_record_id_first)

    # Add phonetic block to the record.
    higgs_record_first['authors'][0]['signature_block'] = "HAGp"
    es.index(index='records-hep',
             doc_type='hep',
             id=higgs_record_id_first,
             body=higgs_record_first)
    es.indices.refresh('records-hep')

    # Signature #3.
    higgs_record_id_second = str(
        PersistentIdentifier.get("literature", 11883).object_uuid)
    higgs_record_second = get_es_record_by_uuid(higgs_record_id_second)

    # Add phonetic block to the record.
    higgs_record_second['authors'][0]['signature_block'] = "HAGp"
    es.index(index='records-hep',
             doc_type='hep',
             id=higgs_record_id_second,
             body=higgs_record_second)
    es.indices.refresh('records-hep')

    with patch("celery.current_app.send_task") as send_to_clustering:
        disambiguation_daemon()

        assert send_to_clustering.call_count == 2
コード例 #4
0
ファイル: test_daemon.py プロジェクト: jacenkow/inspire-next
def test_count_phonetic_block_dispatched(small_app):
    """Count if two phonetic blocks were dispatched."""
    from inspirehep.modules.disambiguation.tasks import (
        disambiguation_daemon,
    )

    # Check if the queue has three records.
    assert DisambiguationRecord.query.count() == 3

    # Signature #1.
    glashow_record_id = str(PersistentIdentifier.get(
        "literature", 4328).object_uuid)
    glashow_record = get_es_record_by_uuid(glashow_record_id)

    # Add phonetic block to the record.
    glashow_record['authors'][0]['signature_block'] = "GLASs"
    es.index(index='records-hep', doc_type='hep',
             id=glashow_record_id, body=glashow_record)
    es.indices.refresh('records-hep')

    # Signature #2.
    higgs_record_id_first = str(PersistentIdentifier.get(
        "literature", 1358492).object_uuid)
    higgs_record_first = get_es_record_by_uuid(higgs_record_id_first)

    # Add phonetic block to the record.
    higgs_record_first['authors'][0]['signature_block'] = "HAGp"
    es.index(index='records-hep', doc_type='hep',
             id=higgs_record_id_first, body=higgs_record_first)
    es.indices.refresh('records-hep')

    # Signature #3.
    higgs_record_id_second = str(PersistentIdentifier.get(
        "literature", 11883).object_uuid)
    higgs_record_second = get_es_record_by_uuid(higgs_record_id_second)

    # Add phonetic block to the record.
    higgs_record_second['authors'][0]['signature_block'] = "HAGp"
    es.index(index='records-hep', doc_type='hep',
             id=higgs_record_id_second, body=higgs_record_second)
    es.indices.refresh('records-hep')

    with patch("celery.current_app.send_task") as send_to_clustering:
        disambiguation_daemon()

        assert send_to_clustering.call_count == 2