def test_table_can_be_booked(): tables = core.all_tables() table = tables[0] assert table, 'Mesa' assert not table.is_booked, 'Libre' core.book_table(table.table_id), 'No more' assert table.is_booked
def book_event(): print("*********************************************") print("* TABLE OPEN: Find your dinner reservation! *") print("*********************************************") print() print("What type of food are you in the mood for?") print("1. Thai") print("2. Burgers") print("3. Seafood") print("4. Other") choice = input("Choose a number: ") choice = int(choice) options = core.find_available(choice) print() if not options: print("Whoops, no tables for that food type. Try another.") return print("Here are the open tables:") for idx, o in enumerate(options): print("{}. Restaurant: {}, table: {}.".format(idx + 1, o.restaurant, o.table_id)) print() num = int(input("Enter a number of the table to book: ")) - 1 to_book = options[num] booked = core.book_table(to_book.table_id) print("Booked you a table at {} in table {}".format( booked.restaurant, booked.table_id))
def book_event(): print("*********************************************") print("* TABLE OPEN: Find your dinner reservation! *") print("*********************************************") print() print("What type of food are you in the mood for?") print("1. Thai") print("2. Burgers") print("3. Seafood") print("4. Other") choice = input("Choose a number: ") choice = int(choice) options = core.find_available(choice) print() if not options: print("Whoops, no tables for that food type. Try another.") return print("Here are the open tables:") for idx, o in enumerate(options): print("{}. Restaurant: {}, table: {}.".format(idx + 1, o.restaurant, o.table_id)) print() num = int(input("Enter a number of the table to book: ")) - 1 to_book = options[num] booked = core.book_table(to_book.table_id) print("Booked you a table at {} in table {}".format(booked.restaurant, booked.table_id))
def test_table_can_be_booked(): tables = core.all_tables() table = tables[0] booked = core.book_table(table.table_id) assert booked assert booked.is_booked assert booked.table_id == table.table_id
def test_cannot_book_a_booked_table(): with pytest.raises(core.TableUnavailableError): # TODO: verify you cannot book a table that is already booked table = core.find_available(1)[0] table.is_booked = True core.book_table(table.table_id)
def test_cannot_book_a_nonexistant_table(): with pytest.raises(core.EntityNotFoundError): # TODO: verify you cannot book a nonexistant table core.book_table('i')
def test_cannot_book_a_booked_table(): tables = core.all_tables() core.book_table(tables[1].table_id) with pytest.raises(core.TableUnavailableError): core.book_table(tables[1].table_id)
def test_cannot_book_a_nonexistant_table(): with pytest.raises(core.EntityNotFoundError): core.book_table('not an ID!')