def test_integration(self):
        """Testing integration of the modules"""
        bo.add_customer('100', 'Peter', 'Parker',
                        '135 W. 50th Street, New York City, NY 10011',
                        '212-576-4000', '*****@*****.**', True, 1000)
        bo.add_customer('200', 'Iron', 'Man',
                        '17801 International Blvd, Seattle, WA 98101',
                        '206-787-5388', '*****@*****.**', True, 5000)

        bo.update_customer_credit('200', 9000)
        a_customer = cm.Customer.get(cm.Customer.customer_id == '200')
        self.assertEqual(a_customer.credit_limit, 9000)

        bo.add_customer('300', 'Ramkumar', 'Rajanbabu',
                        '7525 166th Ave NE, Redmond, WA 98052', '425-556-2900',
                        '*****@*****.**', False, 7078)

        self.assertEqual(bo.list_active_customers(), 2)

        a_customer_2 = bo.search_customer('100')
        a_customer_2_dict = {
            'first_name': 'Peter',
            'last_name': 'Parker',
            'email_address': '*****@*****.**',
            'phone_number': '212-576-4000'
        }
        self.assertEqual(a_customer_2, a_customer_2_dict)

        bo.delete_customer('100')
        self.assertEqual(bo.search_customer('100'), {})
예제 #2
0
def test_search_customer(_search_customers):
    """ search """
    for customer in _search_customers[0]:
        l.add_customer(customer[0],
                       customer[1],
                       customer[2],
                       customer[3],
                       customer[4],
                       customer[5],
                       customer[6],
                       customer[7]
                       )

    result = l.search_customer(_search_customers[1][1])
    assert result == {}

    result = l.search_customer(_search_customers[1][0])
    assert result["name"] == _search_customers[0][1][1]
    assert result["lastname"] == _search_customers[0][1][2]
    assert result["email"] == _search_customers[0][1][5]
    assert result["phone_number"] == _search_customers[0][1][4]

    # delete the customer ids, not sets
    for customer in _search_customers[0]:
        l.delete_customer(customer[0])
 def test_search_customer(self):
     """tests search"""
     TEST_DB.bind(MODELS, bind_refs=False, bind_backrefs=False)
     TEST_DB.create_tables(MODELS)
     add_customer(*CUSTOMERS[0])
     test_c2 = search_customer('00001')
     self.assertEqual(
         {
             'Customer ID': '00001',
             'First Name': 'Dorothy',
             'Last Name': 'Zbornak',
             'Home Address': 'Miami',
             'Phone Number': '5551234567',
             'Email Address': '*****@*****.**',
             'Status': 'Active',
             'Credit Limit': 1000
         }, test_c2)
     add_customer(*CUSTOMERS[3])
     test_c2 = search_customer('00004')
     self.assertEqual(
         {
             'Customer ID': '00004',
             'First Name': 'Rose',
             'Last Name': 'Nylund',
             'Home Address': 'Miami',
             'Phone Number': '5551234570',
             'Email Address': '*****@*****.**',
             'Status': 'Inactive',
             'Credit Limit': 2000
         }, test_c2)
     search_customer('00009')
     self.assertRaises(Exception)
예제 #4
0
    def test_integration(self):
        """Test the entire application functionality."""
        self.assertIsInstance(basic_operations.CUSTOMER_DB,
                              peewee.SqliteDatabase)
        cust_1 = {
            'customer_id': 1,
            'first_name': 'George',
            'last_name': 'Washington',
            'home_address': '4 Bowling Green',
            'phone_number': 2125555555,
            'email_address': '*****@*****.**',
            'is_active': False,
            'credit_limit': 5.00
        }

        cust_2 = {
            'customer_id': 2,
            'first_name': 'John',
            'last_name': 'Adams',
            'home_address': '524-30 Market St',
            'phone_number': 2675551212,
            'email_address': '*****@*****.**',
            'is_active': False,
            'credit_limit': 100.00
        }

        cust_3 = {
            'customer_id': 3,
            'first_name': 'Thoams',
            'last_name': 'Jefferson',
            'home_address': '1600 Pennsylvania Ave',
            'phone_number': 2029999999,
            'email_address': '*****@*****.**',
            'is_active': True,
            'credit_limit': 10000.00
        }

        self.assertEqual(basic_operations.list_active_customers(), 0)

        self.assertEqual(basic_operations.add_customer(**cust_1), True)
        self.assertEqual(basic_operations.add_customer(**cust_2), True)
        self.assertEqual(basic_operations.add_customer(**cust_3), True)

        self.assertEqual(basic_operations.list_active_customers(), 1)

        self.assertEqual(basic_operations.update_customer_credit(1, 10000),
                         True)
        self.assertEqual(basic_operations.update_customer_credit(3, 15000),
                         True)

        self.assertEqual(
            basic_operations.search_customer(1)['credit_limit'], 10000)
        self.assertEqual(
            basic_operations.search_customer(3)['credit_limit'], 15000)

        self.assertEqual(basic_operations.delete_customer(1), True)
        self.assertEqual(basic_operations.delete_customer(2), True)
        self.assertEqual(basic_operations.delete_customer(3), True)

        self.assertEqual(basic_operations.list_active_customers(), 0)
    def test_whole_system(self):
        '''make sure the database is exist'''
        self.assertIsNotNone(basic_operations.DATABASE)
        '''make sure the Customer table exist'''
        self.assertIsNotNone(basic_operations.Customer)
        '''start with an empty database'''
        basic_operations.delete_all_customers()
        '''add a new customer'''
        basic_operations.add_customer(1, 'Michael', 'Jordan',
                                      '3421 S Bull Street \
North Carolina', '203-231-3223', '*****@*****.**', 'Active', 212109)

        customer = basic_operations.search_customer(1)
        self.assertDictEqual(gold, customer)
        '''add another customer'''
        basic_operations.add_customer(2, 'Shawn', 'Kemp', '3423 Green Lake \
Street Seattle WA', '206-240-4023', '*****@*****.**', 'Active', 212109)

        count = basic_operations.list_active_customers()
        self.assertEqual(2, count)
        '''update customer 1 credit'''
        basic_operations.update_customer_credit(1, 200)
        customer = basic_operations.search_customer(1)
        self.assertEqual(200, customer['credit_limit'])
        '''update non-exist customer and catch the error'''
        try:
            basic_operations.update_customer_credit(10, 300)
        except ValueError:
            self.assertRaises(ValueError)
        '''delete customer 1'''
        basic_operations.delete_customer(1)
        customer = basic_operations.search_customer(1)
        self.assertIsNone(customer)
    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)
예제 #7
0
 def test_delete_customers(self):
     """ Tests function to delete multiple customers """
     setup_db()
     to_delete_list = [2, 3]
     delete_customers(to_delete_list)
     self.assertEqual(search_customer(2), {})
     self.assertEqual(search_customer(3), {})
    def test_delete_customer(self):
        create_empty_db()

        customer_1 = {
            'customer_id': '0000',
            'name': 'Victor',
            'last_name': 'Medina',
            'home_address': '809 Newton ave',
            'phone_number': '5165996074',
            'email_address': '*****@*****.**',
            'status': True,
            'credit_limit': 800
        }
        customer_2 = {
            'customer_id': '9860',
            'name': 'Roger',
            'last_name': 'Fortune',
            'home_address': '676 Grand ave',
            'phone_number': '5165946824',
            'email_address': '*****@*****.**',
            'status': True,
            'credit_limit': 750
        }
        add_customer(**customer_1)
        add_customer(**customer_2)
        delete_customer(customer_1['customer_id'])
        search_customer(customer_1['customer_id'])
        self.assertEqual({}, search_customer(customer_1['customer_id']))
예제 #9
0
    def test_basic_operations(self):
        """" Integration test for the basic operations """

        DATABASE.drop_tables([Customer])
        DATABASE.close()
        DATABASE.create_tables([Customer])
        DATABASE.close()

        # Add customers to the db
        add_customers(self.test_customer)

        cust_found = search_customer(2)
        self.assertEqual(self.test_customer[1][5], cust_found.get("email"))

        update_customer_credit(1, 500.00)
        self.assertEqual(500.00, Customer.get_by_id(1).credit_limit)

        # Find out how many customers are active
        active_cust = list_active_customers()
        self.assertEqual(2, active_cust)

        # Delete a customer then try to find it
        delete_customer(2)
        self.assertDictEqual({}, search_customer(2))

        # Find out how many customers are active and list their names
        self.assertEqual(1, list_active_customers())
        self.assertEqual(["Reed Richards"], list_active_customer_names())
예제 #10
0
    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)
예제 #11
0
    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)
예제 #12
0
 def test_integration(self):
     '''
     This fucntion tests the model and basic_fuctions classes
     '''
     add_customer(300, 'John', 'Doe', '100 Main St', '123-456-6789',
                  '*****@*****.**', 'active', 10000)
     add_customer(400, 'Jane', 'Doe', '200 Main St', '123-456-6789',
                  '*****@*****.**', 'inactive', 20000)
     searched_dict = search_customer(300)
     self.assertEqual(search_customer(500), {})
     self.assertEqual(
         searched_dict, {
             'name': 'John',
             'lastname': 'Doe',
             'email_address': '*****@*****.**',
             'phone_number': '123-456-6789'
         })
     self.assertEqual(list_active_customers(), 1)
     update_customer_credit(300, 40000)
     updated_customer = Customer.select().where(
         Customer.customer_id == 300).get()
     self.assertEqual(updated_customer.credit_limit, 40000)
     with self.assertRaises(ValueError):
         update_customer_credit(500, 20000)
     delete_customer(300)
     number = delete_customer(400)
     self.assertEqual(number, 1)
     number = delete_customer(500)
     self.assertEqual(number, 0)
     self.assertEqual(list_active_customers(), 0)
     add_customer('abc', 'John', 'Doe', '100 Main St', '123-456-6789',
                  '*****@*****.**', 'active', 10000)
     customer = Customer.get_or_none()
     self.assertIsNone(customer)
def test_delete_customer():
    """
    sets up a new db, adds customer, runs assertions and tears down db
    """
    setup_test_db()

    # Add and assert to confirm record exists before deleting
    add_customer(**OK_CUSTOMER)
    valid_customer = search_customer(OK_CUSTOMER['customer_id'], stage='dev')

    assert valid_customer.first_name == OK_CUSTOMER['name']
    assert valid_customer.customer_id == OK_CUSTOMER['customer_id']
    assert valid_customer.last_name == OK_CUSTOMER['lastname']
    assert valid_customer.home_address == OK_CUSTOMER['home_address']
    assert valid_customer.phone_number == OK_CUSTOMER['phone_number']
    assert valid_customer.email_address == OK_CUSTOMER['email_address']
    assert valid_customer.status == OK_CUSTOMER['status']
    assert valid_customer.credit_limit == OK_CUSTOMER['credit_limit']

    delete_customer(OK_CUSTOMER['customer_id'], stage='dev')
    valid_customer = search_customer(OK_CUSTOMER['customer_id'], stage='dev')

    assert valid_customer is False

    teardown_test_db()
예제 #14
0
    def test_basic_operations(self):
        for test_customer in customers:
            basic_operations.add_customer(test_customer[CUSTOMER_ID],
                                          test_customer[CUSTOMER_NAME],
                                          test_customer[CUSTOMER_LASTNAME],
                                          test_customer[CUSTOMER_HOME_ADDRESS],
                                          test_customer[CUSTOMER_PHONE_NUMBER],
                                          test_customer[CUSTOMER_EMAIL_ADDRESS],
                                          test_customer[CUSTOMER_STATUS],
                                          test_customer[CUSTOMER_CREDIT_LIMIT])

        customer = basic_operations.search_customer('1')
        self.assertEqual(customer.lastname, 'Lillard')

        basic_operations.update_customer_credit('2', 250.99)
        customer = basic_operations.search_customer('2')
        self.assertEqual(float(customer.credit_limit), 250.99)

        self.assertEqual(basic_operations.list_active_customers(), 2)

        index = 0
        for customer in basic_operations.list_all_customers():
            self.assertEqual(customer, pp_customers[index])
            index = index + 1

        self.assertEqual(basic_operations.delete_customer('3'), 1)
    def test_integration(self):
        """
            Test the following all together
            -add new customers to the database
            -search customers in the database
            -delete existing customers from the database
            -update customers credit
            -list the number of active customers in the database
        """

        # add a couple users all active
        ba.add_customer(1, 'Fran', 'K', '100 New York Ave, NYC, 98109',
                        '248-331-6243', '*****@*****.**', 'Active', 1000)

        ba.add_customer(2, 'Emily', 'H', '200 New York Ave, MA, 98109',
                        '248-331-6243', '*****@*****.**', 'Active', 2000)

        ba.add_customer(3, 'John', 'H', '300 New York Ave, MA, 98109',
                        '248-331-6243', '*****@*****.**', 'Active', 3000)

        # check the credit limit for an added user
        customer_1 = Customer.get(Customer.customer_id == 1)
        self.assertEqual(customer_1.credit_limit, 1000)

        # update the credit limit for a user and search for that user
        customer_3 = ba.search_customer(3)
        self.assertEqual(customer_3['credit_limit'], 3000)

        ba.update_customer_credit(3, 3333)
        customer_3 = ba.search_customer(3)
        self.assertEqual(customer_3['credit_limit'], 3333)

        # add a couple more users some active some not
        ba.add_customer(4, 'John', 'H', '300 New York Ave, MA, 98109',
                        '248-331-6243', '*****@*****.**', 'Inative', 4000)

        ba.add_customer(5, 'John', 'H', '300 New York Ave, MA, 98109',
                        '248-331-6243', '*****@*****.**', 'Inactive', 5000)

        ba.add_customer(6, 'John', 'H', '300 New York Ave, MA, 98109',
                        '248-331-6243', '*****@*****.**', 'Active', 6000)

        # add an existing customer, should throw out a warning
        ba.add_customer(3, 'John', 'H', '300 New York Ave, MA, 98109',
                        '248-331-6243', '*****@*****.**', 'Active', 3000)

        # check how many active users we have
        active_users = ba.list_active_customers()
        self.assertEqual(active_users, 4)

        # delete all our active users
        ba.delete_customer(1)
        ba.delete_customer(2)
        ba.delete_customer(3)
        ba.delete_customer(6)

        # ensure we don't have any active users left
        active_users_2 = ba.list_active_customers()
        self.assertEqual(active_users_2, 0)
예제 #16
0
 def test_search_customer(self):
     '''Tests search_customer function.'''
     reset_db()
     basic_operations.add_customers(TEST_LIST)
     # Testing the search_customer function
     self.assertEqual(
         basic_operations.search_customer(101)['f_name'], TEST_LIST[0][1])
     # Test searching for a non-existing customer
     self.assertEqual(basic_operations.search_customer(3), {})
예제 #17
0
def test_search_customer_null():
    add_customer(**ok_customer)
    customer_dict = search_customer("12345")
    assert customer_dict == {}
    customer_dict = search_customer(7)
    assert customer_dict == {}
    customer_dict = search_customer()
    assert customer_dict == {}
    clean_up(ok_customer["customer_id"])
예제 #18
0
def test_delete_customer():
    add_customer(**ok_customer)
    second_customer = add_second_customer()
    delete_customer(second_customer["customer_id"])
    customer_dict = search_customer(second_customer["customer_id"])
    assert customer_dict == {}
    ok_customer["credit_limit"] = float(ok_customer["credit_limit"])
    customer_dict = search_customer(ok_customer["customer_id"])
    assert customer_dict == ok_customer
    clean_up(ok_customer['customer_id'])
예제 #19
0
 def test_delete_customers(self):
     '''Tests delete_customers function.'''
     reset_db()
     basic_operations.add_customers(TEST_LIST)
     # Testing the delete_customers function
     basic_operations.delete_customers([101, 53])
     self.assertEqual(basic_operations.search_customer(101), {})
     self.assertEqual(basic_operations.search_customer(53), {})
     self.assertEqual(
         basic_operations.search_customer(123)['f_name'], TEST_LIST[1][1])
예제 #20
0
    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)
예제 #21
0
    def test_search_customer(self):
        # Get Bob
        res = bo.search_customer(1)
        for key, val in res.items():
            self.assertEqual(self.definitions['Bob'][key], val)
        self.assertListEqual(list(res.keys()),
                             ['name', 'last_name', 'email', 'phone'])

        # Get non-existent ID
        res = bo.search_customer(6)
        self.assertEqual({}, res)
예제 #22
0
 def test_search_customer(self):
     """Test to check that customer search outputs properly"""
     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), {})
예제 #23
0
 def test_search_customer(self, mock_database):
     """Testing searching a customer to the database via search_customer function."""
     basic_operations.DATABASE_NAME = TEST_DATABASE
     exp_dict = {
         'name': 'Wilson',
         'lastname': 'Volleyball',
         'email_address': '*****@*****.**',
         'phone_number': '0000000000'
         }
     self.assertDictEqual(search_customer(5), exp_dict)
     self.assertDictEqual(search_customer(3), {})
 def test_delete_customer(self):
     """ tests delete customer"""
     TEST_DB.bind(MODELS, bind_refs=False, bind_backrefs=False)
     TEST_DB.create_tables(MODELS)
     add_customer(*CUSTOMERS[0])
     add_customer(*CUSTOMERS[1])
     delete_customer('00001')
     search_customer('00001')
     self.assertRaises(Exception)
     delete_customer('00009')
     self.assertRaises(Exception)
def test_search_customer(_add_customers):
    """Tests customer search function"""
    create_empty_db()
    for customer in _add_customers:
        bo.add_customer(*customer)
        result = bo.search_customer(_add_customers[0])
        assert result == {}
        result = bo.search_customer(customer[0])
        assert result["name"] == customer[1]
        assert result["lastname"] == customer[2]
        assert result["email"] == customer[5]
        assert result["phone_number"] == customer[4]
    def test_search_customer(self):
        # Get first customer
        res = bo.search_customer(1)

        correct_labels = ['name', 'last_name', 'email', 'phone']
        for key in correct_labels:
            self.assertEqual(self.first_cust[key], res[key])
        self.assertListEqual(correct_labels, list(res.keys()))

        # Get non-existent ID
        res = bo.search_customer(-1)
        self.assertEqual({}, res)
예제 #27
0
    def test_search_customer(self):
        """ test search_customer function """
        logger.info('Test search_customer')
        customer_info = op.search_customer('5')

        self.assertEqual(customer_info['name'], 'Jane Goodall')
        self.assertEqual(customer_info['last name'], 'Goodall')
        self.assertEqual(customer_info['email address'],
                         '*****@*****.**')
        self.assertEqual(customer_info['phone number'], '970-555-0171')

        # test exception
        customer_info = op.search_customer('50')
예제 #28
0
    def test_search_customer(self):
        """ test search_customer function """
        customer_info = op.search_customer('5')

        self.assertEqual(customer_info['name'], 'Jane Goodall')
        self.assertEqual(customer_info['last name'], 'Goodall')
        self.assertEqual(customer_info['email address'],
                         '*****@*****.**')
        self.assertEqual(customer_info['phone number'], '970-555-0171')

        # test exception
        customer_info = op.search_customer('50')
        self.assertRaises(peewee.DoesNotExist)
예제 #29
0
    def test_2_update_record(self):
        """Test that a record is updated when the credit_limit is <=7 digits."""

        # This will fail
        self.assertEqual(basic_operations.update_customer_credit(3, 1000.00),
                         False)

        self.assertEqual(
            basic_operations.search_customer(2)['credit_limit'], 9999999.00)
        self.assertEqual(basic_operations.update_customer_credit(2, 1000.00),
                         True)
        self.assertEqual(
            basic_operations.search_customer(2)['credit_limit'], 1000.00)
예제 #30
0
    def test_search_customer(self):
        """ Tests function to search customer """
        setup_db()
        expected0 = {}
        expected1 = {
            "name": "Leo",
            "lastname": "Messi",
            "email_address": "*****@*****.**",
            "phone_number": 1234567890
        }

        self.assertEqual(search_customer(0), expected0)
        self.assertEqual(search_customer(1), expected1)