Exemplo n.º 1
0
def test_import_loan_returned(test_data_migration, patrons, es_clear):
    filepath = os.path.join(os.path.dirname(__file__), "data", "loans.json")
    with open(filepath) as fp:
        import_loans_from_json(fp)
    reindex_record(CIRCULATION_LOAN_PID_TYPE, Loan, LoanIndexer())
    current_search.flush_and_refresh(index="*")
    loan_search = current_circulation.loan_search_cls
    search = (loan_search().filter("term", document_pid="docid-1").filter(
        "term", state="ITEM_RETURNED"))
    results = search.execute()

    assert results.hits.total.value == 1
    assert results[0].start_date == "2010-09-29T00:00:00"

    search = (loan_search().filter("term", document_pid="docid-1").filter(
        "term", state="ITEM_ON_LOAN").filter("term",
                                             item_pid__value="itemid-1"))
    results = search.execute()
    assert results.hits.total.value == 1
    assert results[0].start_date == "2009-07-07T00:00:00"
Exemplo n.º 2
0
def loan_requests(source):
    """Migrate documents from CDS legacy."""
    import_loans_from_json(source)
    reindex_pidtype("loanid")
Exemplo n.º 3
0
def loans(source):
    """Migrate loans from CDS legacy."""
    import_loans_from_json(source)
    reindex_pidtype("loanid")
Exemplo n.º 4
0
def test_import_invalid_loan(testdata):
    filepath = os.path.join(os.path.dirname(__file__), "data",
                            "loan_ongoing_anonymous_user.json")
    with open(filepath) as fp:
        with pytest.raises(LoanMigrationError):
            import_loans_from_json(fp, raise_exceptions=True)
Exemplo n.º 5
0
def loan_requests(sources, fail_on_exceptions):
    """Migrate loan_requests from CDS legacy."""
    for idx, source in enumerate(sources, 1):
        import_loans_from_json(source,
                               fail_on_exceptions,
                               mint_legacy_pid=False)
Exemplo n.º 6
0
def loans(sources, fail_on_exceptions):
    """Migrate loans from CDS legacy."""
    for idx, source in enumerate(sources, 1):
        import_loans_from_json(source, fail_on_exceptions)