コード例 #1
0
 def test_person_no_ID(self):
     # Arrange
     expected_outcome = "Name: Alex Wallwork Age: 24 ID: None"
     testy = Person("Alex", "Wallwork", "24")
     # Act
     actual_outcome = Person.get_person_info(testy)
     # Assert
     self.assertEqual(expected_outcome, actual_outcome)
コード例 #2
0
 def test_person_ID(self):
     # Arrange
     expected_outcome = "Name: Alex Wallwork Age: 24 ID: Set"
     testy = Person("Alex", "Wallwork", "24", 100)
     # Act
     actual_outcome = testy.get_person_info()
     # Assert
     self.assertEqual(expected_outcome, actual_outcome)
コード例 #3
0
 def test_selection_1b(self, selection_1c, mock_person_list):
     # Arrange
     database = Mock(db())
     app = t.App(db=database)
     database.load_person.return_value = [Person("Gary", "McTest", 10)]
     # Act
     app.selection_1b([Person("Gary", "McTest", 10)])
     # Assert
     self.assertEqual(selection_1c.call_count, 1)
コード例 #4
0
 def test_selection_1a_searcher_Exit(self, main_menu, mock_input):
     # Arrange
     database = Mock(db())
     app = t.App(db=database)
     database.load_person.return_value = [Person("Stringy", "Testy", 10)]
     # Act
     app.selection_1a("Ex", [Person("Stringy", "Testy", 10)])
     # Assert
     self.assertEqual(main_menu.call_count, 1)
コード例 #5
0
    def test_selection_4a(self, selection_4, selection_4b_drink_input_getter):
        database = Mock(db())
        app = t.App("fake")
        database.load_drinks.return_value = [Drink("Testy", "Test", 10)]
        selection_4.side_effect = [Person("Garyo", "McTest", 10)]

        app.selection_4a([Person("Garyo", "McTest", 10)])

        self.assertEqual(selection_4b_drink_input_getter.call_count, 1)
コード例 #6
0
 def load_person(self):
     db_people_save_list.clear()
     sql_string = f"SELECT * FROM person"
     class_arguements = self.sql_load_all(sql_string)
     for tuple in class_arguements:
         new_person = Person(tuple[1], tuple[2], tuple[3], tuple[0])
         db_people_save_list.append(new_person)
     return db_people_save_list
コード例 #7
0
    def test_selection_5(self, selection_5a, mock_input, load_person):

        database = Mock(db())
        app = t.App(database)
        mock_input.side_effect = ["Testy"]
        database.load_person.return_value = [Person("Testy", "Test", 10)]

        app.selection_5()

        self.assertEqual(selection_5a.call_count, 1)
コード例 #8
0
    def test_selection_8(self, input):
        # arrange
        database = Mock(db())
        app = t.App(db=database)
        database.load_person.return_value = [Person("Testy", "Mctest", 20)]
        database.load_drinks.return_value = [
            Drink("Testy Ade", 1, "Soft Drink")
        ]
        input.side_effect = [
            "7", "Testy", "Mctest", "Testy", "Mctest", "Testy Ade", "n", "n",
            "y", "ex"
        ]

        # act
        app.main_menu()

        # assert
        self.assertEqual(database.round_to_db.call_count, 1)
コード例 #9
0
 def selection_3a(self, selection2, selection3, selection4):
     new_person = Person(selection2, selection3, selection4)
     self.selection_3b(new_person)
     return (new_person)
コード例 #10
0
 def test_selection_3b(self, selection_3, db):
     selection_3.side_effect = [Person("Garyo", "McTest", 10)]
     app = t.App("fake")
     app.selection_3b(selection_3.side_effect)
     self.assertEqual(db.call_count, 1)