def test_integration(self): """ Tests integration of modules """ database = cm.DATABASE database.drop_tables([cm.Customer]) database.create_tables([cm.Customer]) bo.add_customer('1150', 'Mark', 'Rollins', '46 Hawthorne Lane, Great Falls, MT 59404', '406-604-4060', '*****@*****.**', True, 575.00) bo.add_customer('5102', 'Parker', 'Phan', '8811 Kingston Road, Boynton Beach, FL 33435', '786-115-5125', '*****@*****.**', True, 250.00) bo.update_customer('1150', 175.75) a_customer = cm.Customer.get(cm.Customer.customer_id == '1150') self.assertEqual(a_customer.customer_credit, 175.75) bo.add_customer('3030', 'Joseph', 'Tribbiani', '43 Foster Avenue, New York, NY 10003', '212-013-7564', '*****@*****.**', False, 1000.00) self.assertEqual(bo.list_active_customers(), 2) a_customer2 = bo.search_customer('3030') a_customer2_dict = {'first_name': 'Joseph', 'last_name': 'Tribbiani', 'email_address': '43 Foster Avenue, New York, NY 10003', 'phone_number': '212-013-7564'} self.assertEqual(a_customer2, a_customer2_dict) bo.delete_customer('3030') self.assertEqual(bo.search_customer('3030'), {}) all_customers = [{'1150': ('Mark', 'Rollins')}, {'5102': ('Parker', 'Phan')}] self.assertEqual(bo.return_all_customers(), all_customers)
def test_update_customer_credit_no_match(): add_customer(**ok_customer) second_customer = add_second_customer() with pytest.raises(ValueError): update_customer(customer_id="12345", credit_limit=100.0) clean_up(ok_customer['customer_id']) clean_up(second_customer['customer_id'])
def test_update_customer_credit(): add_customer(**ok_customer) second_customer = add_second_customer() update_customer(customer_id=second_customer["customer_id"], credit_limit=100.0) customer_dict = search_customer(second_customer["customer_id"]) assert customer_dict["credit_limit"] == 100.0 clean_up(ok_customer['customer_id']) clean_up(second_customer['customer_id'])
def test_update_customer_fail(self): """ Testing updating a customer fail """ setup() bo.add_customer('1150', 'Mark', 'Rollins', '46 Hawthorne Lane, Great Falls, MT 59404', '406-604-4060', '*****@*****.**', True, 575.00) with self.assertRaises(ValueError): bo.update_customer('2050', 175.75)
def test_update_customer(self): """ Testing updating customer """ setup() bo.add_customer('1150', 'Mark', 'Rollins', '46 Hawthorne Lane, Great Falls, MT 59404', '406-604-4060', '*****@*****.**', True, 575.00) bo.update_customer('1150', 175.75) a_customer = cm.Customer.get(cm.Customer.customer_id == '1150') self.assertEqual(a_customer.customer_credit, 175.75)
def test_update_customer(self): """Test the ability to ability to update a customer""" database_setup() add_customer(1, 'Guy', 'Dudeman', '1139 Bro Street', '800-123-4567', '*****@*****.**', True, 1000000) update_customer(1, 1000) self.assertAlmostEqual( Customer.get(Customer.customer_id == 1).customer_credit_limit, 1000) with self.assertRaises(pw.DoesNotExist): update_customer(0, 1000)
def test_update_customer(self): """Test the ability to ability to update a customer""" database_setup() # add in all the customers for customer in TEST_CUSTOMERS: add_customer(customer['id'], customer['first_name'], customer['last_name'], customer['address'], customer['phone_number'], customer['email'], customer['status'], customer['credit_limit']) cust_id = None # so pylint doesnt yell at me for cust_id in [customer['id'] for customer in TEST_CUSTOMERS]: test_value = random.randint(0, 100000000) update_customer(cust_id, test_value) self.assertAlmostEqual(Customer.get(Customer.customer_id == cust_id).customer_credit_limit, test_value) with self.assertRaises(pw.DoesNotExist): update_customer(0, 1000)
def test_invalid_update_customer(self): '''Tests an invalid update of a credit change''' try: update = bas.update_customer(9, 399) except: self.assertRaises(ValueError)
def test_update_customer(self): '''Tests a valid update of a credit change''' update = bas.update_customer(2, 399) assert update == updated_record