def test6_fetching_rounds_table_should_not_cause_exception(self): # Arrange database = db._connect_to_database() exception_raised = False # Act try: db._fetch_table('rounds') except: exception_raised = True # Assert self.assertFalse(exception_raised) db._close_database(database)
def test4_fetching_a_table_in_the_database_does_not_cause_exception(self): # Arrange exception_raised = False database = db._connect_to_database() create_test_table() # Act try: db._fetch_table(test_table_name) except: exception_raised = True # Assert self.assertFalse(exception_raised) delete_test_table() database.close()
def fetch_rounds(): rounds = [] try: results = db._fetch_table('rounds') for result in results: new_round = _parse_round_row(result) rounds.append(new_round) except: print("Connection Error.") return rounds
def fetch_orders(): orders = [] try: results = db._fetch_table('orders') for result in results: order = _parse_order_row(result) orders.append(order) except: print("Connection Error.") return orders
def get_people(): people = [] try: results = db._fetch_table('people') for row in results: person = _parse_person_row(row) people.append(person) except: print("Connection Error.") return people
def get_drinks(): drinks = [] try: results = db._fetch_table('drinks') for row in results: drink = _parse_drink_row(row) drinks.append(drink) except: print("Connection Error.") return drinks
def get_preferences(): preferences = {} try: results = db._fetch_table('preferences') for row in results: person_id = row[0] drink_name = row[1] preferences[person_id] = drink_name except: print("Connection Error.") return preferences
def test6_fetching_a_table_with_an_entry_in_the_database_returns_correct_value(self): # Arrange database = db._connect_to_database() create_test_table() test_value = 'hello' db._insert_row(f'INSERT INTO {test_table_name} ({test_table_field}) VALUES ("{test_value}")') # Act try: table = db._fetch_table(test_table_name) except: print('error fetching table') self.assertFalse(True) # Assert self.assertTrue(len(table) == 1 and table[0][0] == test_value) delete_test_table() database.close()