Пример #1
0
def test_template_es_mapping(es_clear, db, templ_doc_public_martigny_data,
                             templ_doc_private_martigny_data, org_martigny,
                             system_librarian_martigny, librarian_martigny):
    """Test template elasticsearch mapping."""
    search = TemplatesSearch()
    mapping = get_mapping(search.Meta.index)
    assert mapping
    Template.create(templ_doc_public_martigny_data,
                    dbcommit=True,
                    reindex=True,
                    delete_pid=True)
    new_mapping = get_mapping(search.Meta.index)
    assert mapping == new_mapping
Пример #2
0
def templ_doc_public_sion(app, org_sion, templ_doc_public_sion_data,
                          system_librarian_sion_no_email):
    """Create template for a public document sion."""
    template = Template.create(data=templ_doc_public_sion_data,
                               delete_pid=False,
                               dbcommit=True,
                               reindex=True)
    flush_index(TemplatesSearch.Meta.index)
    return template
Пример #3
0
def templ_patron_public_martigny(app, org_martigny,
                                 templ_patron_public_martigny_data,
                                 system_librarian_martigny_no_email):
    """Load template for a public item martigny."""
    template = Template.create(data=templ_patron_public_martigny_data,
                               delete_pid=False,
                               dbcommit=True,
                               reindex=True)
    flush_index(TemplatesSearch.Meta.index)
    return template
Пример #4
0
def templ_doc_private_martigny(app, org_martigny,
                               templ_doc_private_martigny_data,
                               librarian_martigny_no_email):
    """Create template for a private document martigny."""
    template = Template.create(data=templ_doc_private_martigny_data,
                               delete_pid=False,
                               dbcommit=True,
                               reindex=True)
    flush_index(TemplatesSearch.Meta.index)
    return template
Пример #5
0
def test_template_create(db, es_clear, templ_doc_public_martigny_data,
                         org_martigny, system_librarian_martigny_no_email):
    """Test template creation."""
    templ_doc_public_martigny_data['toto'] = 'toto'
    with pytest.raises(ValidationError):
        temp = Template.create(templ_doc_public_martigny_data, delete_pid=True)

    db.session.rollback()

    del templ_doc_public_martigny_data['toto']
    temp = Template.create(templ_doc_public_martigny_data, delete_pid=True)
    assert temp == templ_doc_public_martigny_data
    assert temp.get('pid') == '1'

    temp = Template.get_record_by_pid('1')
    assert temp == templ_doc_public_martigny_data

    fetched_pid = fetcher(temp.id, temp)
    assert fetched_pid.pid_value == '1'
    assert fetched_pid.pid_type == 'tmpl'
Пример #6
0
def test_template_create(db, es, templ_doc_public_martigny_data,
                         org_martigny, system_librarian_martigny):
    """Test template creation."""
    templ_doc_public_martigny_data['toto'] = 'toto'
    with pytest.raises(ValidationError):
        Template.create(templ_doc_public_martigny_data, delete_pid=True)
    db.session.rollback()

    next_pid = Template.provider.identifier.next()
    del templ_doc_public_martigny_data['toto']
    temp = Template.create(templ_doc_public_martigny_data, delete_pid=True)
    next_pid += 1
    assert temp == templ_doc_public_martigny_data
    assert temp.get('pid') == str(next_pid)

    temp = Template.get_record_by_pid(str(next_pid))
    assert temp == templ_doc_public_martigny_data

    fetched_pid = fetcher(temp.id, temp)
    assert fetched_pid.pid_value == str(next_pid)
    assert fetched_pid.pid_type == 'tmpl'