Ejemplo n.º 1
0
def test_tc12_search_for_books_with_keywords():
    reload_db()
    state = tc4_inside()
    search_results = Document._search_in_fields('Algorithms', array_fields=['keywords'])
    assert ['Thomas H. Cormen', 'Charles E. Leiserson', 'Ronald L. Rivest', 'Clifford Stein'] == search_results[0].authors
    assert ["Niklaus Wirth"] == search_results[1].authors
    assert ['Donald E. Knuth'] == search_results[2].authors
Ejemplo n.º 2
0
def test_tc4_l2_creates_lots_of_thigns_and_that_works_wow():
    reload_db()
    inf = tc4_inside()
    flags = inf[len(inf) - 1]
    docs_created = flags[0]
    patrons_created = flags[1]
    assert docs_created and patrons_created
Ejemplo n.º 3
0
def test_tc14_patron_searchs_by_keywords_OR():
    reload_db()
    state = tc4_inside()
    first_clause = Document._search_in_fields_query('Algorithms', array_fields=['keywords'])
    second_clause = Document._search_in_fields_query("Programming", array_fields=['keywords'])

    results = first_clause.union(second_clause).all()

    assert results[0].authors == ['Thomas H. Cormen', 'Charles E. Leiserson', 'Ronald L. Rivest', 'Clifford Stein']
    assert results[1].authors == ["Niklaus Wirth"]
    assert results[2].authors == ['Donald E. Knuth']
Ejemplo n.º 4
0
def test_visiting_prof_can_checkout_a_book_for_1_week():
    reload_db()
    b3 = create_instance(Book, title='The Mythical Man-month', authors=['Brooks,Jr', 'Frederick P'],
                         publisher='Addison-Wesley Longman Publishing Co., Inc.', publishment_year=1995, edition=2,
                         reference=False)
    copies_b3 = [create_instance(DocumentCopy, document=b3)]
    p1 = register_test_account(VisitingProfessorPatron, name='Sergey Afonso', address='Via Margutta, 3', phone='30001',
                               card_number=1010)
    loan_p1_b3 = p1.checkout(copies_b3[0])
    today = datetime.date.today()
    give_back_date = loan_p1_b3.due_date

    date_delta = give_back_date - today

    assert date_delta.days == 7
Ejemplo n.º 5
0
def state_of_system_librarians():
    reload_db()
    l1 = register_test_account(Librarian, login='******', password='******') l1.access_level = 1 log('admin', 'created', 'librarian1')
    l2 = register_test_account(Librarian, login='******', password='******')
    l2.access_level = 2
    log('admin', 'created', 'librarian2')
    l3 = register_test_account(Librarian, login='******', password='******')
    l3.access_level = 3
    log('admin', 'created', 'librarian3')

    db.session.add(l1)
    db.session.add(l2)
    db.session.add(l3)
    db.session.commit()

    sys_librarians = Librarian.query

    return sys_librarians
Ejemplo n.º 6
0
def test_tc3_l1_creates_l1_checks_and_nothing():
    reload_db()
    librs = state_of_system_librarians()
    l1 = librs.filter(Librarian.login == 'librarian1').first()

    assert not l1.has_permission(Permission.create_document)
Ejemplo n.º 7
0
def test_tc2_admin_creates_3_librarians():
    reload_db()
    libr = state_of_system_librarians()
    assert libr.count() == 3
Ejemplo n.º 8
0
def test_tc13_patron_searchs_by_keywords_AND():
    reload_db()
    state = tc4_inside()
    first_clause = Document._search_in_fields_query('Algorithms', array_fields=['keywords'])
    results = Document._search_in_fields_query('Programming', array_fields=['keywords'], apply_to_query=first_clause).all()
    assert results == []
Ejemplo n.º 9
0
def test_tc11_search_for_a_book_by_title_word():
    reload_db()
    state = tc4_inside()
    search_results = Document._search_in_fields("Algorithms", ['title'])
    assert ['Thomas H. Cormen', 'Charles E. Leiserson', 'Ronald L. Rivest', 'Clifford Stein'] == search_results[0].authors
    assert ['Niklaus Wirth'] == search_results[1].authors
Ejemplo n.º 10
0
def test_tc10_search_for_a_book_by_full_title():
    reload_db()
    state = tc4_inside()
    doc = Document._search_in_fields("Introduction to Algorithms", ['title'])
    assert doc is not None
Ejemplo n.º 11
0
def test_tc7_checkout_outstanding_request_and_sys_is_empty_changes():
    reload_db()
    inf = tc7_inside()
    assert inf[6]
Ejemplo n.º 12
0
def test_tc6_p1_p2_p3_s_v_has_no_permission_to_checkout_and_l1_cant_place_outstanding_request():
    reload_db()
    inf = tc6_inside()
    flags = inf[6]
    assert flags
Ejemplo n.º 13
0
def test_tc5_l3_works_with_docs():
    reload_db()
    inf = tc5_inside()
    docs = inf[1]
    l2 = inf[0][1]
    assert len(docs[0].copies) == 2