def test_drop_collections(self): """test building a table, check if it exists, then drop it and make sure it reuturns nothing""" database = database_setup() test_dicts = [{ 'person': 'Maveric' }, { 'person': 'Charlie' }, { 'person': 'Iceman' }, { 'person': 'Goose' }, { 'person': 'Viper' }, { 'person': 'Jester' }, { 'person': 'Couger' }, { 'person': 'Wolfman' }, { 'person': 'Slider' }] insert_into_table('test', test_dicts) for test_value in test_dicts: query = database.test.find(filter={"person": test_value['person']}, projection={'_id': False}) self.assertEqual([values["person"] for values in query][0], test_value['person']) drop_collections() query = database.test.find() self.assertEqual([values for values in query], [])
def test_show_rentals(self): """Function to test the return of user details for a product that is rented""" database.import_data(directory_name, "products.csv", "customers.csv", "rentals.csv") expected_data = {'UID103': {'*****@*****.**', '3 Seattle Dr', 'Dom'}, 'UID105': {'5 Vincent dr', 'Dan', '*****@*****.**'}, 'UID101': {'1 Redmond dr', 'Sam', '*****@*****.**'}} actual_data = database.show_rentals("p101") database.drop_collections() self.assertEqual(expected_data, actual_data)
def test_show_rentals(self): """Function to test the return of user details for a product that is rented""" directory_name = "/Users/guntur/PycharmProjects/uw/" \ "p220/SP_Python220B_2019/students/g_rama/lesson05/src/data" database.import_data(directory_name, "products.csv", "customers.csv", "rentals.csv") expected_data = { 'UID103': {'*****@*****.**', '3 Seattle Dr', 'Dom'}, 'UID105': {'5 Vincent dr', 'Dan', '*****@*****.**'}, 'UID101': {'1 Redmond dr', 'Sam', '*****@*****.**'} } actual_data = database.show_rentals("p101") database.drop_collections() self.assertEqual(expected_data, actual_data)
def test_show_available_products(self): """Testing the available products function""" database.import_data(directory_name, "products.csv", "customers.csv", "rentals.csv") expected_output = {'p101': {'Electronics', '5', 'TV'}, 'p102': {'Lamp', 'Livingroom', '5'}, 'p103': {'Dining Table', 'Diningroom', '5'}, 'p104': {'5', 'bedroom', 'Queen bed'}, 'p105': {'bedroom', '5', 'Kung bed'}, 'p106': {'studyroom', 'Study Table', '5'}, 'p107': {'kidsroom', 'Bunk Bed', '5'}, 'p108': {'Microwave', 'Electronics', '5'}, 'p109': {'Fan', 'livingroom', '5'}, 'p110': {'5', 'livingroom', 'Heater'}} actual_data = database.show_available_products() database.drop_collections() self.assertEqual(expected_output, actual_data)