def test_end_to_end(cls):
        """ Lifecyle End To End Test """
        basic_operations.create_database()
        assert os.path.exists(basic_operations.DATABASE_NAME)
        basic_operations.add_customer(0,
                                     'jaimes',
                                     'hernandez',
                                     '101 Elliot Ave. SE',
                                     '205-222-1111',
                                     '*****@*****.**',
                                     True,
                                     2000)
        assert basic_operations.search_customer(1)

        assert basic_operations.update_customer_credit(1, 2000)
        results = basic_operations.search_customer_status(1)
        for result in results:
            assert int(result['customer_id']) == 1
            assert result['status']
            assert int(result['credit_limit']) == 2000

        assert basic_operations.update_customer_credit(1, 3000)
        results = basic_operations.search_customer_status(1)
        for result in results:
            assert int(result['customer_id']) == 1
            assert result['status']
            assert int(result['credit_limit']) == 3000

        assert int(basic_operations.list_active_customers()) > 0
        assert basic_operations.delete_customer(1)
        assert int(basic_operations.list_active_customers()) == 0

        basic_operations.delete_database()
        assert not os.path.exists(basic_operations.DATABASE_NAME)
Exemplo n.º 2
0
 def test_list_active_customer(cls):
     """ Ensure can list all active customers from the database """
     assert basic_operations.create_database()
     basic_operations.add_customer(0, 'jaimes', 'hernandez',
                                   '101 Elliot Ave. SE', '205-222-1111',
                                   '*****@*****.**', True, 2000)
     assert int(basic_operations.get_active_customer_count()) == 1
     basic_operations.delete_customers()
Exemplo n.º 3
0
 def test_search_customer_valid(cls):
     """ Ensure can search a customer to the database """
     assert basic_operations.create_database()
     basic_operations.add_customer(0, 'jaimes', 'hernandez',
                                   '101 Elliot Ave. SE', '205-222-1111',
                                   '*****@*****.**', True, 2000)
     assert basic_operations.search_customer(1)
     basic_operations.delete_customers()
Exemplo n.º 4
0
 def test_update_customer_credit_invalid(cls):
     """
     Ensure can update an invalid customer's credit in the database  fails
     """
     assert basic_operations.create_database()
     basic_operations.add_customer(0, 'jaimes', 'hernandez',
                                   '101 Elliot Ave. SE', '205-222-1111',
                                   '*****@*****.**', True, 2000)
     assert not basic_operations.update_customer_credit(10, 3000)
     result = basic_operations.search_customer_status(10)
     assert len(result) == 0
     basic_operations.delete_customers()
Exemplo n.º 5
0
 def test_delete_customer_invalid(cls):
     """ Ensure can delete a customer from the database """
     assert basic_operations.create_database()
     basic_operations.add_customer(0, 'jaimes', 'hernandez',
                                   '101 Elliot Ave. SE', '205-222-1111',
                                   '*****@*****.**', True, 2000)
     before = basic_operations.get_active_customer_count()
     assert before > 0
     basic_operations.delete_customer(10)
     after = basic_operations.get_active_customer_count()
     assert before == after
     basic_operations.delete_customers()
Exemplo n.º 6
0
    def test_update_customer_credit_valid(cls):
        """ Ensure can update an active customer's credit in the database """
        assert basic_operations.create_database()
        basic_operations.add_customer(0, 'jaimes', 'hernandez',
                                      '101 Elliot Ave. SE', '205-222-1111',
                                      '*****@*****.**', True, 2000)
        assert basic_operations.update_customer_credit(1, 3000)
        results = basic_operations.search_customer_status(1)
        for result in results:
            assert int(result['customer_id']) == 1
            assert result['status']
            assert int(result['credit_limit']) == 3000

        basic_operations.delete_customers()
Exemplo n.º 7
0
 def test_add_customer_with_id(cls):
     """ Ensure can add a customer to the database with id """
     assert basic_operations.create_database()
     added_user = basic_operations.add_customer(0, 'jaimes', 'hernandez',
                                                '101 Elliot Ave. SE',
                                                '205-222-1111',
                                                '*****@*****.**', True, 2000)
     added_user = basic_operations.add_customer(1, 'jaimes', 'hernandez',
                                                '101 Elliot Ave. SE',
                                                '205-222-1111',
                                                '*****@*****.**', True, 2000)
     assert added_user['customer_id'] == 1
     assert added_user['customer_status_id'] == 1
     basic_operations.delete_customers()