def test_update_credit_limit(self): """ unit test for updating the cutomer's credit limit to the database """ # set up self.add_customers() credit_limit_1 = 50000.00 credit_limit_2 = 150000.00 credit_limit_3 = 250000.00 basic_operations.update_customer_credit(1, credit_limit_1) basic_operations.update_customer_credit(2, credit_limit_2) basic_operations.update_customer_credit(3, credit_limit_3) db_customer_1 = Customer.get(Customer.customer_id == 1) db_customer_2 = Customer.get(Customer.customer_id == 2) db_customer_3 = Customer.get(Customer.customer_id == 3) self.assertEqual(db_customer_1.credit_limit, credit_limit_1) self.assertEqual(db_customer_2.credit_limit, credit_limit_2) self.assertEqual(db_customer_3.credit_limit, credit_limit_3) self.assertNotEqual(db_customer_1.credit_limit, CUSTOMER_1['credit_limit']) self.assertNotEqual(db_customer_2.credit_limit, CUSTOMER_2['credit_limit']) self.assertNotEqual(db_customer_3.credit_limit, CUSTOMER_3['credit_limit']) # clean up self.delete_customers()
def update_customer_credit(customer_id, credit_limit): """ search an existing customer by customer_id and update their credit limit or raise a ValueError exception if the customer does not exist """ try: with database.transaction(): a_customer = Customer.get(Customer.customer_id == customer_id) logger.info(f'Customer: {customer_id} credit limit is ' f'{a_customer.credit_limit}.') except (IndexError, ValueError, peewee.DoesNotExist): logger.info(f'Customer: {customer_id} not found.') database.close() return with database.transaction(): query = (Customer.update({ Customer.credit_limit: credit_limit }).where(Customer.customer_id == customer_id)) query.execute() a_customer = Customer.get(Customer.customer_id == customer_id) logger.info(f'Customer: {customer_id} credit limit is updated to ' f'{a_customer.credit_limit}.') database.close()
def update_customer_credit(id, credit): try: Customer.get(Customer.customer_id == id) credit_update = Customer.update(credit_limit=credit).where(Customer.customer_id == id) x = credit_update.execute() except Exception as e: raise ValueError
def update_customer_credit(customer_id, credit_limit): ''' This function searches existing customer by ID and updates credit_limit to new value A ValueError will be raised if customer does not exist in database. ''' try: retr_customer = Customer.get(Customer.customer_id == customer_id) retr_customer.credit_limit = credit_limit retr_customer.save() logging.info(f"customer credit changed {retr_customer.customer_id}\ to credit {retr_customer.credit_limit}") if credit_limit < 0: logging.warning('credit_limit parameter is ', 'less than 0: ', credit_limit) except ValueError as err: logging.error('error replacing customers credit limit: ,', err) error_statement = 'An error occured while replacing customers credit.\ Credit unchanged.' print(error_statement) return error_statement check_customer = Customer.get(Customer.customer_id == customer_id) print(check_customer.customer_id, ' has had their credit limit changed to:', check_customer.credit_limit) return 'operation successfully completed'
def test_delete_customer(self): '''Tests the delete_customer function.''' reset_db() LOGGER.info('Testing the delete_customer function') basic_operations.add_customer(*TEST_LIST[0]) basic_operations.add_customer(*TEST_LIST[1]) basic_operations.add_customer(*TEST_LIST[2]) cust_0 = Customer.get(Customer.cust_id == 101) cust_2 = Customer.get(Customer.cust_id == 53) try: basic_operations.delete_customer(123) self.assertEqual(cust_0.f_name, TEST_LIST[0][1]) self.assertEqual(cust_2.f_name, TEST_LIST[2][1]) try: Customer.get(Customer.cust_id == 123) assert False except peewee.DoesNotExist: assert True except peewee.IntegrityError: assert False LOGGER.info('Testing the delete_customer not in the database') with self.assertRaises(ValueError): basic_operations.delete_customer(55)
def test_add_customer(self): """Test the add customer method""" new_customer = (1, 'Benjamin', 'Thomson', '9x9 xyzxy Dr. Apt # 529D xxxxxx SC. 29403', '202-755-3xx1', '*****@*****.**', True, 244.20) add_customer(*new_customer) new_customer = (2, 'Lindsay', 'Huggy', '898 Bolian Dr. Myrtle Beach SC. 20909', '717-934-2243', '*****@*****.**', '', 244.20) add_customer(*new_customer) new_customer = (3, 'Ashley', 'Wiggins', '999 Virginia Dr. Richmond VA. 20000', '717-934-2243', '*****@*****.**', False, 725.00) add_customer(*new_customer) new_row = Customer.get(Customer.customer_id == 1) self.assertEqual(new_row.name, 'Benjamin') self.assertEqual(new_row.last_name, 'Thomson') self.assertEqual(new_row.home_address[-5:], '29403') self.assertEqual(new_row.phone_number, '202-755-3xx1') self.assertEqual(new_row.email_address, '*****@*****.**') self.assertEqual(new_row.status, True) self.assertEqual(new_row.credit_limit, decimal.Decimal('244.2')) new_row = Customer.get(Customer.customer_id == 2) self.assertFalse(new_row.status) with self.assertRaises(peewee.IntegrityError): add_customer(*new_customer)
def test_delete_customer(): delete_customer("000001") with pytest.raises(Exception) as e: logging.info(e) Customer.get(Customer.customer_id == "000001")
def test_update_customer_credit(self): '''test updating customer credit limit.''' add_customer(**self.customer4) self.assertEqual(Customer.get(Customer.customer_id == 'John').credit_limit, 155810) update_customer_credit('John', 200000) self.assertEqual(Customer.get(Customer.customer_id == 'John').credit_limit, 200000) with self.assertRaises(ValueError): update_customer_credit('John2', 1000)
def test_add_customer(self): """ unit test for adding cutomers to the database """ # set up self.add_customers() db_customer_1 = Customer.get(Customer.customer_id == 1) db_customer_2 = Customer.get(Customer.customer_id == 2) db_customer_3 = Customer.get(Customer.customer_id == 3) self.assertEqual(CUSTOMER_1['customer_name'], db_customer_1.customer_name) self.assertEqual(CUSTOMER_2['customer_name'], db_customer_2.customer_name) self.assertEqual(CUSTOMER_3['customer_name'], db_customer_3.customer_name) self.assertEqual(CUSTOMER_1['customer_lastname'], db_customer_1.customer_lastname) self.assertEqual(CUSTOMER_2['customer_lastname'], db_customer_2.customer_lastname) self.assertEqual(CUSTOMER_3['customer_lastname'], db_customer_3.customer_lastname) self.assertEqual(CUSTOMER_1['customer_address'], db_customer_1.customer_address) self.assertEqual(CUSTOMER_2['customer_address'], db_customer_2.customer_address) self.assertEqual(CUSTOMER_3['customer_address'], db_customer_3.customer_address) self.assertEqual(CUSTOMER_1['customer_phone_number'], db_customer_1.customer_phone_number) self.assertEqual(CUSTOMER_2['customer_phone_number'], db_customer_2.customer_phone_number) self.assertEqual(CUSTOMER_3['customer_phone_number'], db_customer_3.customer_phone_number) self.assertEqual(CUSTOMER_1['customer_email'], db_customer_1.customer_email) self.assertEqual(CUSTOMER_2['customer_email'], db_customer_2.customer_email) self.assertEqual(CUSTOMER_3['customer_email'], db_customer_3.customer_email) self.assertEqual(CUSTOMER_1['credit_limit'], db_customer_1.credit_limit) self.assertEqual(CUSTOMER_2['credit_limit'], db_customer_2.credit_limit) self.assertEqual(CUSTOMER_3['credit_limit'], db_customer_3.credit_limit) self.assertEqual(CUSTOMER_1['status'], db_customer_1.status) self.assertEqual(CUSTOMER_2['status'], db_customer_2.status) self.assertEqual(CUSTOMER_3['status'], db_customer_3.status) # clean up self.delete_customers()
def update_customer_credit(id, credit): logging.debug('Updating credit for customer %s', id) try: Customer.get(Customer.customer_id == id) credit_update = Customer.update(credit_limit=credit).where( Customer.customer_id == id) x = credit_update.execute() logging.info('Updated customer %s credit to %f', id, credit) except Exception as e: raise ValueError
def test_integration(self): '''Integrated test set''' cust_list = [(101, 'Bugs', 'Bunny', '123 NE 160th Ave, Kirkland, WA 98034', '425-123-4567', '*****@*****.**', 'Active', 100.00), (123, 'Donald', 'Duck', '456 SE 45th St, Bellevue, WA 98004', '425-234-5678', '*****@*****.**', 'Active', 500.00), (53, 'Elmer', 'Fudd', '789 W 52nd Pl, Bothell, WA 98077', '425-345-6789', '*****@*****.**', 'Inactive', 12000.00)] test_list = [{'f_name': 'Elmer', 'l_name': 'Fudd', 'email': '*****@*****.**', 'phone': '425-345-6789'}, {'f_name': 'Bugs', 'l_name': 'Bunny', 'email': '*****@*****.**', 'phone': '425-123-4567'}] # Test adding customers basic_operations.add_customers(cust_list) # Verify customers were added self.assertEqual(Customer.get(Customer.cust_id == 101).f_name, cust_list[0][1]) self.assertEqual(Customer.get(Customer.cust_id == 123).f_name, cust_list[1][1]) self.assertEqual(Customer.get(Customer.cust_id == 53).f_name, cust_list[2][1]) # Verify duplicate customers are not added with self.assertRaises(ValueError): basic_operations.add_customer(*cust_list[2]) # Verify able to search for customers customers = basic_operations.search_customers([53, 101, 33]) self.assertEqual(customers[0], test_list[0]) self.assertEqual(customers[1], test_list[1]) # Verify searching for a non-existant customer is empty self.assertEqual(customers[2], {}) # Verify able to update customer credit limit basic_operations.update_customer_credit(123, 100000) cust_1 = Customer.get(Customer.cust_id == 123) self.assertEqual(cust_1.credit, 100000) # Verify customer credit limit cannot be updated for non-customer with self.assertRaises(ValueError): basic_operations.update_customer_credit(42, 1000) # Verify active customers are counted self.assertEqual(basic_operations.list_active_customers(), 2) # Verify a customer can be deleted basic_operations.delete_customers([53, 123]) self.assertEqual(Customer.get(Customer.cust_id == 101).f_name, cust_list[0][1]) self.assertEqual(basic_operations.search_customer(123), {}) self.assertEqual(basic_operations.search_customer(53), {}) # Verify handling of deleting non-customers with self.assertRaises(ValueError): basic_operations.delete_customer(53)
def test_delete_customer(self): ''' Tests method to delete customer from database ''' # Add customer to database self.add_customer_to_database() # Delete customer from database basic_operations.delete_customer(self.new_customer['id']) # Verify that trying to retrive the customer yields a DoesNotExist Error with self.assertRaises(DoesNotExist): Customer.get(Customer.id == self.new_customer['id'])
def test_delete_customer(self): """ Test deleting customers """ # Add a user to ensure we have something to delete bo.add_customer(**TEST_USER2) # Delete the test user bo.delete_customer(TEST_USER2['customer_id']) # Search for an invalid user with self.assertRaises(DoesNotExist): Customer.get(Customer.customer_id == TEST_USER2['customer_id'])
def test_add_multiple_customers(): add_customer(**ok_customer) second_customer = add_second_customer() test_customer = Customer.get( Customer.customer_id == ok_customer['customer_id']) test_customer1 = Customer.get( Customer.customer_id == second_customer["customer_id"]) assert test_customer != test_customer1 assert test_customer.first_name == 'Suzie' assert test_customer1.first_name == 'Bob' clean_up(ok_customer["customer_id"]) clean_up(second_customer["customer_id"])
def test_add_customer(self): '''Testing add_customer function''' LOGGER.info('Testing add_customer function!') setup() add_customer(*self.CUSTOMER_LIST[0]) add_customer(*self.CUSTOMER_LIST[1]) add_customer(*self.CUSTOMER_LIST[2]) add_customer(*self.CUSTOMER_LIST[3]) test_customer_01 = Customer.get(Customer.c_id == '01') test_customer_02 = Customer.get(Customer.c_id == '02') test_customer_03 = Customer.get(Customer.c_id == '03') test_customer_04 = Customer.get(Customer.c_id == '04') # Testing customer 01 self.assertEqual(test_customer_01.c_firstname, self.CUSTOMER_LIST[0][1]) self.assertEqual(test_customer_01.c_lastname, self.CUSTOMER_LIST[0][2]) # Testing customer 02 self.assertEqual(test_customer_02.c_home_address, self.CUSTOMER_LIST[1][3]) self.assertEqual(test_customer_02.c_phone_number, self.CUSTOMER_LIST[1][4]) # Testing customer 03 self.assertEqual(test_customer_03.c_email_address, self.CUSTOMER_LIST[2][5]) self.assertEqual(test_customer_03.c_status, self.CUSTOMER_LIST[2][6]) # Testing customer 04 self.assertEqual(test_customer_04.c_id, self.CUSTOMER_LIST[3][0]) self.assertEqual(test_customer_04.c_firstname, self.CUSTOMER_LIST[3][1]) self.assertEqual(test_customer_04.c_lastname, self.CUSTOMER_LIST[3][2]) self.assertEqual(test_customer_04.c_home_address, self.CUSTOMER_LIST[3][3]) self.assertEqual(test_customer_04.c_phone_number, self.CUSTOMER_LIST[3][4]) self.assertEqual(test_customer_04.c_email_address, self.CUSTOMER_LIST[3][5]) self.assertEqual(test_customer_04.c_status, self.CUSTOMER_LIST[3][6]) self.assertEqual(test_customer_04.c_credit_limit, self.CUSTOMER_LIST[3][7]) with self.assertRaises(IndexError): add_customer(*self.CUSTOMER_LIST[6]) LOGGER.info('Finished testing add_customer function!')
def test_integration(self): """Test functionality of entire application.""" self.assertIsInstance(main.CUSTOMER_DB, SqliteDatabase) reset_database() test_db = [ (1, 'John', 'Smith', '123 Main Street', '2065551234', '*****@*****.**', 'Active', 10000), (2, 'Jane', 'Doe', '1000 Market Street', '2065555678', '*****@*****.**', 'Active', 5000), (3, 'Alice', 'Wonderland', '200 Cherry Street', '2065551357', '*****@*****.**', 'Active', 1000), (3, 'Mark', 'Allen', '555 Columbia Avenue', '2065552468', '*****@*****.**', 'Active', 8500) ] main.add_customer(*test_db[0]) main.add_customer(*test_db[1]) main.add_customer(*test_db[2]) customer_1 = Customer.get(Customer.customer_id == 1) customer_2 = Customer.get(Customer.customer_id == 2) customer_3 = Customer.get(Customer.customer_id == 3) self.assertEqual(test_db[0][1], customer_1.first_name) self.assertEqual(test_db[1][2], customer_2.last_name) self.assertEqual(test_db[2][3], customer_3.home_address) with self.assertRaises(ValueError): main.add_customer(*test_db[3]) search = main.search_customer(1) expected = { 'First Name': 'John', 'Last Name': 'Smith', 'Email Address': '*****@*****.**', 'Phone Number': '2065551234' } self.assertEqual(search, expected) self.assertEqual(main.search_customer(4), {}) main.delete_customer(2) search = main.delete_customer(2) self.assertEqual(search, None) main.update_customer_credit(1, 12000) customer = Customer.get(Customer.customer_id == 1) self.assertEqual(12000, customer.credit_limit) update = main.update_customer_credit(4, 2000) self.assertEqual(update, None)
def test_update_customer_credit(): ''' test update credit limit func ''' update_customer_credit(good_customer['customer_id'], 50) p = Customer.get(Customer.customer_id == good_customer['customer_id']) assert p.credit_limit == 50
def delete_customer(customer_id): try: person = Customer.get(Customer.customer_id == customer_id) person.delete_instance() except Exception as e: print('Customer wasn\'t found.') return 'customer deleted'
def test_add_customer(self): """ create an empty database for testing """ database.drop_tables([Customer]) database.create_tables([Customer]) logger.info('-- Testing adding new customer --') bo.add_customer(1, 'Emily', 'Yang', '121 Main street NewYork', '2062847320', '*****@*****.**', True, 10000) customer = Customer.get(Customer.customer_id == 1) self.assertEqual(customer.name, 'Emily') self.assertEqual(customer.lastname, 'Yang') self.assertEqual(customer.home_address, '121 Main street NewYork') self.assertEqual(customer.phone_number, '2062847320') self.assertEqual(customer.email_address, '*****@*****.**') self.assertEqual(customer.status, True) self.assertEqual(customer.credit_limit, 10000) bo.add_customer(2, 'Adam', 'Chilly', '233 Jone street LA', '4342941868', '*****@*****.**', True, 5000) bo.add_customer(3, 'Steve', 'Wagon', '4508 Lord Ave Seattle', '6879337640', '*****@*****.**', False, 0) bo.add_customer(4, 'Jone', 'Comba', '1129 Brand street Boise', '3745689770', '*****@*****.**', False, 100) bo.add_customer(5, 'Zaler', 'Danny', '29 Colb street Portland', '2323456787', '*****@*****.**', True, 1000) self.assertEqual(len(Customer), 5) for customer in Customer: logger.info(f'{customer.name} {customer.home_address} ' f'{customer.phone_number} {customer.email_address} ' f'{customer.status} {customer.credit_limit}') logger.info('-- End of Testing adding new customer --\n')
def test_integration(self): # Add customers 2 and 3 c2, c3 = next(self.def_tuples), next(self.def_tuples) # alice = self.definitions['Alice'] # bob2 = self.definitions['Bob2'] bo.add_customer(*c2) bo.add_customer(*c3) # bo.add_customer(alice['id'], alice['name'], alice['last_name'], alice['address'], # alice['phone'], alice['email'], alice['status'], alice['credit_limit']) # bo.add_customer(bob2['id'], bob2['name'], bob2['last_name'], bob2['address'], # bob2['phone'], bob2['email'], bob2['status'], bob2['credit_limit']) # Assert that all 3 are in the DB self.assertEqual(3, Customer.select().count()) # Modify c2's credit limit bo.update_customer_credit(c2[0], 12.32) self.assertEqual(12.32, float(Customer.get(Customer.name == c2[1]).credit_limit)) # Search for c3 res = bo.search_customer(c3[0]) for k in ['name', 'last_name', 'email', 'phone']: self.assertEqual(c3[self.labels.index(k)], res[k]) # Delete c3 bo.delete_customer(c3[0]) res = bo.search_customer(c3[0]) self.assertEqual({}, res)
def test_add_ok_customer(): """Adds two customers and tests one is saved in customer.db""" add_customer(**ok_customer) add_customer(**ok_customer2) test_customer = Customer.get( Customer.customer_id == ok_customer['customer_id']) assert test_customer.email_address == ok_customer['email_address']
def search_customer(customer_id): """ Searches customer by ID returns: dict; with name, lastname, email, phone (or) empty if no customer found """ logging.info("searching customer ID %s...", customer_id) try: with DB.transaction(): # query database for customer by ID searched_customer = Customer.get( Customer.customer_id == customer_id) logging.info("successfully found customer!") # return dict with name, lastname, email, phone number return { "name": searched_customer.name, "lastname": searched_customer.lastname, "email_address": searched_customer.email_address, "phone_number": searched_customer.phone_number } except DoesNotExist: LOGGER.error("DoesNotExisterror: customer ID %s not found!", customer_id) # return empty dict return {}
def show_custompizza(): if not 'MyWebsite_customer_id' in session.keys(): return redirect('/') if not Customer.is_logged_in(session['MyWebsite_customer_id'], session['login_session']): return redirect('/danger') # print('customer id',session['MyWebsite_customer_id']) customer_id = session['MyWebsite_customer_id'] # print('customer id',customer_id) customer = Customer.get(customer_id) # print(customer) order = Order.get_entering(customer.id) if not order: order = Order.new(customer_id) #new_pizza=Pizza.new(order.id,request.form) #print(order) sizes = Size.get_all() # print(sizes) styles = Style.get_all() order_types = OrderType.get_all() # print("order types:",order_types) toppings_menu = ToppingMenu.get_all() print(order.pizzas) return render_template('custompizza.html', sizes=sizes, styles=styles, toppings_menu=toppings_menu, order_types=order_types, order=order)
def test_update_customer_credit(self): """Test to check that updating a customer behaves properly""" main.update_customer_credit(1, 12000) customer = Customer.get(Customer.customer_id == 1) self.assertEqual(12000, customer.credit_limit) update = main.update_customer_credit(2, 2000) self.assertEqual(update, None)
def charge(): if not 'MyWebsite_customer_id' in session.keys(): return redirect('/') if not Customer.is_logged_in(session['MyWebsite_customer_id'], session['login_session']): return redirect('/danger') # Action route handler from Stripe customer_id = session['MyWebsite_customer_id'] customer = Customer.get(customer_id) order = Order.get_entering(customer.id) # Stripe token stripe_customer = stripe.Customer.create( email=customer.email, source=request.form['stripeToken']) # amount in cents, must be type int amount = int(order.total() * 100) # Process charge with stripe token stripe.Charge.create(customer=stripe_customer.id, amount=amount, currency='usd', description='OrderID:' + str(order.id)) # change order status so it shows up in kitchen dashboard order.submit() # socket io sends a message to any connected browser connections # socketio.emit('neworder',order.id, namespace='/restdash') socketio.emit('neworder', render_template('restpartial.html', order=order), namespace='/restdash') # show a response to the user. return render_template('charge.html', amount=amount, order=order)
def search_customer(customer_id): """ This function will return a dictionary object with name, lastname, email address and phone number of a customer or an empty dictionary object if no customer was found. """ ret_dict = {} try: database.connect() database.execute_sql('PRAGMA foreign_keys = ON;') # needed for sqlite with database.transaction(): cust = Customer.get(Customer.customer_id == customer_id) if cust is not None: ret_dict['name'] = cust.name ret_dict['lastname'] = cust.lastname ret_dict['email_address'] = cust.email_address ret_dict['phone_number'] = cust.phone_info logger.info('Database query successful') else: logger.error(f'Customer {customer_id} not found') raise ValueError except Exception as thrown_exception: logger.info(f'Error querying {customer_id}') logger.info(thrown_exception) logger.info('See how the database protects our data') finally: database.close() return ret_dict
def test_add_customers(self): '''Tests add a new customer to the database.''' reset_db() # Test Adding a list of customers customers = basic_operations.add_customers(TEST_LIST) # Test instances of added customers self.assertIsInstance(customers[0], Customer) self.assertIsInstance(customers[1], Customer) self.assertIsInstance(customers[2], Customer) # Verify added customers data self.assertEqual( Customer.get(Customer.cust_id == 101).f_name, TEST_LIST[0][1]) self.assertEqual( Customer.get(Customer.cust_id == 123).f_name, TEST_LIST[1][1]) self.assertEqual( Customer.get(Customer.cust_id == 53).f_name, TEST_LIST[2][1])
def test_integration(self): # Add Alice and Bob2 alice = self.definitions['Alice'] bob2 = self.definitions['Bob2'] bo.add_customer(alice['id'], alice['name'], alice['last_name'], alice['address'], alice['phone'], alice['email'], alice['status'], alice['credit_limit']) bo.add_customer(bob2['id'], bob2['name'], bob2['last_name'], bob2['address'], bob2['phone'], bob2['email'], bob2['status'], bob2['credit_limit']) # Assert that all 3 are in the DB self.assertEqual(3, Customer.select().count()) # Modify Alice's credit limit bo.update_customer_credit(alice['id'], 12.32) self.assertEqual( 12.32, float(Customer.get(Customer.name == 'Alice').credit_limit)) # Search for Bob2 res = bo.search_customer(bob2['id']) for k in ['name', 'last_name', 'email', 'phone']: self.assertEqual(bob2[k], res[k]) # Delete Bob2 bo.delete_customer(bob2['id']) res = bo.search_customer(bob2['id']) self.assertEqual({}, res)
def search_customer(customer_id): """ This function will return a dictionary object with name, lastname, email address and phone number of a customer or an empty dictionary object if nodebug customer was found. """ try: db.connect() db.execute_sql('PRAGMA foreign_keys = ON;') LOGGING.info('Try to search a customer record') with db.transaction(): customer = Customer.get(Customer.customer_id == customer_id) LOGGING.info(f'{customer_id} found.') return { 'first_name': customer.first_name, 'last_name': customer.last_name, 'email': customer.email_address, 'phone_number': customer.phone_number } except DoesNotExist: LOGGING.info(f'Customer {customer_id} does not exit') customer = dict() return customer # Empty dictionary if no customer was found finally: LOGGING.info('database closes') db.close()
def test_active_customers(self): ''' Tests method to return integer count of active customers ''' # Empty database should have no active customers num_active = basic_operations.list_active_customers() self.assertEqual(num_active, 0) # Add first customer and ensure that active count returns 0 self.add_customer_to_database() num_active = basic_operations.list_active_customers() self.assertEqual(num_active, 0) # Change customer status to active customer = Customer.get(Customer.id == self.new_customer['id']) customer.status = 1 customer.save() # Query number of active customers, should now be 1 num_active = basic_operations.list_active_customers() self.assertEqual(num_active, 1) # Change customer status back to inactive (for other tests) customer.status = 0 customer.save()