Exemplo n.º 1
0
 def test_list_active_customers(self):
     """tests the list_active_customers functionality"""
     added_customer = {
         'customer_id': 'EJ9ER',
         'first_name': 'Jennifer',
         'last_name': 'Robot',
         'home_address': '2324 Main Street',
         'phone_number': '6197602020',
         'email_address': '*****@*****.**',
         'status': 'Active',
         'credit_limit': 15000.00
     }
     add_customer(**added_customer)
     added_customer_2 = {
         'customer_id': 'CS194',
         'first_name': 'Cloud',
         'last_name': 'Strife',
         'home_address': '2324 Acorn Avenue',
         'phone_number': '4257774659',
         'email_address': '*****@*****.**',
         'status': 'Active',
         'credit_limit': 15000.00
     }
     add_customer(**added_customer_2)
     result = list_active_customers()
     self.assertEqual(result, 2)
Exemplo n.º 2
0
 def test_add_customer_fail(self):
     """tests the add_customer functionality"""
     added_customer = {
         'customer_id': 'EJ9ER',
         'first_name': 'Jennifer',
         'last_name': 'Robot',
         'home_address': '2324 Main Street',
         'phone_number': '6197602020',
         'email_address': '*****@*****.**',
         'status': 'Active',
         'credit_limit': 15000.00
     }
     dupli_customer = {
         'customer_id': 'EJ9ER',
         'first_name': 'Jennifer',
         'last_name': 'Robot',
         'home_address': '2324 Main Street',
         'phone_number': '6197602020',
         'email_address': '*****@*****.**',
         'status': 'Active',
         'credit_limit': 15000.00
     }
     add_customer(**added_customer)
     with self.assertRaises(ValueError):
         add_customer(**dupli_customer)
def test_add_customer_bad_status():
    ''' Add a customer with an invalid status '''
    bad_customer = dict(customer_data)
    bad_customer['customer_id'] = "bad_status"
    bad_customer['status'] = "not a bool"

    with raises(ValueError):
        bo.add_customer(**bad_customer)
def test_add_customer_credit_limit_float():
    ''' Add customer with an invalid credit limit '''
    bad_customer = dict(customer_data)
    bad_customer['customer_id'] = "cred_float"
    bad_customer['credit_limit'] = '$40'

    with raises(ValueError):
        bo.add_customer(**bad_customer)
Exemplo n.º 5
0
 def test_delete_customer(self):
     """tests the delete_customer functionality"""
     added_customer = {
         'customer_id': 'EJ9ER',
         'first_name': 'Jennifer',
         'last_name': 'Robot',
         'home_address': '2324 Main Street',
         'phone_number': '6197602020',
         'email_address': '*****@*****.**',
         'status': 'Active',
         'credit_limit': 15000.00
     }
     add_customer(**added_customer)
     self.assertEqual(delete_customer(added_customer['customer_id']), None)
def test_search_customer():
    ''' Search for an expected customer '''
    search_good = dict(customer_data)
    customer_id = "search"
    search_good['customer_id'] = customer_id

    bo.add_customer(**search_good)
    result = bo.search_customer(customer_id)

    assert isinstance(result, dict)
    assert result["name"] == search_good["name"]
    assert result["lastname"] == search_good["lastname"]
    assert result["email_address"] == search_good["email_address"]
    assert result["phone_number"] == search_good["phone_number"]
Exemplo n.º 7
0
 def test_search_customer_fail(self):
     """tests the search_customer functionality"""
     added_customer = {
         'customer_id': 'EJ9ER',
         'first_name': 'Jennifer',
         'last_name': 'Robot',
         'home_address': '2324 Main Street',
         'phone_number': '6197602020',
         'email_address': '*****@*****.**',
         'status': 'Active',
         'credit_limit': 15000.00
     }
     add_customer(**added_customer)
     compare = {}
     self.assertEqual(compare, search_customer('LS123'))
def test_add_customer_ok():
    ''' Add a new valid customer '''
    customer_id = "add_ok"
    ok_customer = dict(customer_data)
    ok_customer['customer_id'] = customer_id
    bo.add_customer(**ok_customer)

    result = Customer.get(Customer.customer_id == customer_id)
    assert result.first_name == ok_customer["name"]
    assert result.last_name == ok_customer["lastname"]
    assert result.home_address == ok_customer["home_address"]
    assert result.phone_number == ok_customer["phone_number"]
    assert result.email_address == ok_customer["email_address"]
    assert result.status == ok_customer["status"]
    assert result.credit_limit == float(ok_customer["credit_limit"])
Exemplo n.º 9
0
 def test_update_customer_credit(self):
     """tests the update_customer_credit functionality"""
     added_customer = {
         'customer_id': 'EJ9ER',
         'first_name': 'Jennifer',
         'last_name': 'Robot',
         'home_address': '2324 Main Street',
         'phone_number': '6197602020',
         'email_address': '*****@*****.**',
         'status': 'Active',
         'credit_limit': 15000.00
     }
     add_customer(**added_customer)
     update_customer_credit(added_customer['customer_id'], 25000.00)
     customer_lu = Customer.get(
         Customer.customer_id == added_customer['customer_id'])
     self.assertEqual(float(customer_lu.credit_limit), 25000.00)
Exemplo n.º 10
0
 def test_integration(self):
     """tests the integration of the functions"""
     added_customer_1 = {
         'customer_id': 'LUX65',
         'first_name': 'Lucifer',
         'last_name': 'Morningstar',
         'home_address': '4578 Main Street',
         'phone_number': '6197602022',
         'email_address': '*****@*****.**',
         'status': 'Active',
         'credit_limit': 12000.00
     }
     add_customer(**added_customer_1)
     added_customer_2 = {
         'customer_id': 'JJ77',
         'first_name': 'Jax',
         'last_name': 'Linx',
         'home_address': '333 Acorn Avenue',
         'phone_number': '4257602145',
         'email_address': '*****@*****.**',
         'status': 'Active',
         'credit_limit': 17000.00
     }
     add_customer(**added_customer_2)
     added_customer_3 = {
         'customer_id': 'JKL456',
         'first_name': 'Luke',
         'last_name': 'Josety',
         'home_address': '1547 Acorn Avenue',
         'phone_number': '7477371916',
         'email_address': '*****@*****.**',
         'status': 'Inactive',
         'credit_limit': 1000.00
     }
     add_customer(**added_customer_3)
     delete_customer(added_customer_2['customer_id'])
     result = list_active_customers()
     self.assertEqual(result, 1)