def test_options_no_borrower_with_many_reservers_by_other(): book = Book('TITLE', 'DESCRIPTION', 'ISBN') book.reserve('RESERVER') book.reserve('RESERVER 2') book.reserve('RESERVER 3') expected = { Book.CAN_RESERVE: True } assert_equals(expected, book.get_options('OTHER'))
def test_options_with_borrower_with_many_reservers_by_reserver(): book = Book('TITLE', 'DESCRIPTION', 'ISBN') book.check_out('BORROWER') book.reserve('RESERVER') book.reserve('RESERVER 2') book.reserve('RESERVER 3') expected = {} expected[Book.CAN_CANCEL] = True assert_equals(expected, book.get_options('RESERVER'))
def test_links_cancel(): book = Book('TITLE', 'DESCRIPTION', 'ISBN') book.get_options = mock.method_returning({ Book.CAN_CANCEL: True }) assert_equals(dict(rel='self', href='/books/ISBN'), book.links('RESERVER')[0]) assert_equals(dict(rel='/docs#cancel', href='/books/ISBN/reservations/RESERVER/cancel'), book.links('RESERVER')[1])
def test_links_return(): book = Book('TITLE', 'DESCRIPTION', 'ISBN') book.get_options = mock.method_returning({ Book.CAN_RETURN: True }) assert_equals(dict(rel='self', href='/books/ISBN'), book.links('BORROWER')[0]) assert_equals(dict(rel='/docs#return', href='/books/ISBN/return'), book.links('BORROWER')[1])
def test_links_borrow(): book = Book('TITLE', 'DESCRIPTION', 'ISBN') book.get_options = mock.method_returning({ Book.CAN_BORROW: True }) assert_equals(dict(rel='self', href='/books/ISBN'), book.links('SOMEONE')[0]) assert_equals(dict(rel='/docs#borrow', href='/books/ISBN/borrower'), book.links('SOMEONE')[1])
def test_options_for_borrower(): book = Book('TITLE', 'DESCRIPTION', 'ISBN') book.check_out('BORROWER') expected = { Book.CAN_RETURN: True } assert_equals(expected, book.get_options('BORROWER'))
def test_options_no_borrower_with_one_reserver_by_reserver(): book = Book('TITLE', 'DESCRIPTION', 'ISBN') book.reserve('RESERVER') expected = { Book.CAN_BORROW: True, Book.CAN_CANCEL: True } assert_equals(expected, book.get_options('RESERVER'))
def test_options_no_borrower(): book = Book('TITLE', 'DESCRIPTION', 'ISBN') expected = { Book.CAN_RESERVE: True, Book.CAN_BORROW: True } assert_equals(expected, book.get_options('SOMEONE'))