Пример #1
0
 def test_display_all_customers_pass(self):
     """
     Confirm that the generator output is correct.
     """
     load_database.add_customers(customers)
     results = display_all_customers()
     for i, result in results:
         if i == 0:
             self.assertEqual(
                 result,
                 ' JF0001 |  Jarron  |  Fondue  |1234 A St NW, Nowhere, HH 12345         | 1234567890 |         [email protected]|  active  | 20000 '
             )
         if i == 1:
             self.assertEqual(
                 result,
                 ' SC0198 |  Stormy  |  Calmy   |1234 Z St SE, Somewhere, HH 23456       | 1112223333 |        [email protected]|  active  | 15000 '
             )
         if i == 2:
             self.assertEqual(
                 result,
                 ' DK7621 |   Dana   |  Kabar   |1234 BB Dr SE, Here, HH 23456           | 1112225555 |      [email protected]| inactive | 12000 '
             )
         if i == 3:
             self.assertEqual(
                 result,
                 ' JT0198 |   John   |  Tigger  |1234 K St SW, Somewhere, HH 23456       | 1112224444 |      [email protected]|  active  | 7000  '
             )
Пример #2
0
 def test_load_database_fail(self):
     """
     Confirm that adding a customer with an improperly formatted phone# will result in no addition.
     """
     load_database.add_customers(customers_err)
     cursor = self.conn.execute('SELECT * FROM Customer;')
     results = cursor.fetchall()
     self.assertEqual(results, [])
Пример #3
0
 def test_load_database_pass(self):
     """
     Confirm that adding a customer with an improperly formatted phone# will result in no addition.
     """
     load_database.add_customers(customers)
     cursor = self.conn.execute('SELECT * FROM Customer;')
     results = cursor.fetchall()
     self.assertEqual(
         results,
         [('JF0001', 'Jarron', 'Fondue', '1234 A St NW, Nowhere, HH 12345',
           '1234567890', '*****@*****.**', 'active', '20000'),
          ('SC0198', 'Stormy', 'Calmy', '1234 Z St SE, Somewhere, HH 23456',
           '1112223333', '*****@*****.**', 'active', '15000'),
          ('DK7621', 'Dana', 'Kabar', '1234 BB Dr SE, Here, HH 23456',
           '1112225555', '*****@*****.**', 'inactive', '12000'),
          ('JT0198', 'John', 'Tigger', '1234 K St SW, Somewhere, HH 23456',
           '1112224444', '*****@*****.**', 'active', '7000')])
Пример #4
0
    def test_main_menu_5(self, mock_stdout):
        """
        Confirm behavior for main menu handling of option 5.
        """
        load_database.add_customers(customers)
        with patch('builtins.input', side_effect=key_seq[25:26]):
            main_menu()
            self.assertEqual(
                mock_stdout.getvalue(), """Please choose from the following:
              '1' - Add a new customer
              '2' - Search a customer
              '3' - Delete a customer
              '4' - Update customer credit
              '5' - List active customers
              'q' - Quit
(active_customers, inactive_customers) = (3, 1)
""")
Пример #5
0
    def test_main_menu_6(self, mock_stdout):
        """
        Confirm behavior for main menu handling of option 6.
        """
        load_database.add_customers(customers)
        with patch('builtins.input', side_effect=key_seq[26:27]):
            main_menu()
            self.assertEqual(
                mock_stdout.getvalue(), """Please choose from the following:
              '1' - Add a new customer
              '2' - Search a customer
              '3' - Delete a customer
              '4' - Update customer credit
              '5' - List active customers
              '6' - Display all customers
              'q' - Quit
 JF0001 |  Jarron  |  Fondue  |1234 A St NW, Nowhere, HH 12345         | 1234567890 |         [email protected]|  active  | 20000 
 SC0198 |  Stormy  |  Calmy   |1234 Z St SE, Somewhere, HH 23456       | 1112223333 |        [email protected]|  active  | 15000 
 DK7621 |   Dana   |  Kabar   |1234 BB Dr SE, Here, HH 23456           | 1112225555 |      [email protected]| inactive | 12000 
 JT0198 |   John   |  Tigger  |1234 K St SW, Somewhere, HH 23456       | 1112224444 |      [email protected]|  active  | 7000  
""")
Пример #6
0
 def test_list_active_customers_pass(self):
     """
     Confirm that the number of active an inactive customers will be properly returned.
     """
     load_database.add_customers(customers)
     self.assertEqual(list_active_customers(), (3, 1))