def test_bad_show_rentals(self): ''' Test method to ensure bad mongo DB connection is properly handled ''' mongo = create_mongo_connection(host='127.0.0.1', port=27018) rentals_dict = show_rentals('prd001', mongo) self.assertEqual(rentals_dict, {})
def test_bad_connection(self): ''' Test method to ensure bad mongo DB connection is properly handled ''' mongo = create_mongo_connection(host='127.0.0.1', port=27018) item_counts = add_json_to_mongodb([{'test':'test'}], 'zzz', mongo) self.assertEqual(item_counts, (0, 1))
def test_bad_show_available(self): ''' Test method to ensure bad mongo DB connection is properly handled ''' mongo = create_mongo_connection(host='127.0.0.1', port=27018) product_dict = show_available_products(mongo) self.assertEqual(product_dict, {})
def tearDown(cls): ''' Drop mongo collections after each test to ensure a fresh start ''' mongo = create_mongo_connection() with mongo as db: db['product'].drop() db['customer'].drop() db['rentals'].drop()