def test_new_person(): # Arrange app = TindevQA() user = {'people_seen': []} expected_person = 'Alexandra' # Action actual_person = app.get_next_person(user) # Assert assert actual_person == expected_person
def test_new_person_decorator(): # Arrange app = TindevQA() user = {'people_seen': []} expected_person = 'Alexandra' when(app).get_random_user().thenReturn('Alexandra') # Action actual_person = app.get_next_person(user) # Assert assert actual_person == expected_person
def test_new_person_several_times(): app = TindevQA() user = {'people_seen': ['Sara', 'Alexandra']} expected_person = 'Leia' when(app).get_random_user().thenReturn('Alexandra', 'Sara', 'Leia') # Action actual_person = app.get_next_person(user) # Assert assert actual_person == expected_person
def test_new_person_several_times(mock_get_random_user): app = TindevQA() user = {'people_seen': ['Sara', 'Alexandra']} expected_person = 'Leia' mock_get_random_user.side_effect = ['Alexandra', 'Sara', 'Leia'] # Action actual_person = app.get_next_person(user) # Assert assert actual_person == expected_person
def test_new_person_decorator(mock_get_random_user): # Arrange app = TindevQA() user = {'people_seen': []} expected_person = 'Alexandra' mock_get_random_user.return_value = 'Alexandra' # Action actual_person = app.get_next_person(user) # Assert assert actual_person == expected_person
def test_new_person_context_manager(): with patch.object(TindevQA, "get_random_user") as mock_get_random_user: # Arrange app = TindevQA() user = {'people_seen': []} expected_person = 'Alexandra' mock_get_random_user.return_value = 'Alexandra' # Action actual_person = app.get_next_person(user) # Assert assert actual_person == expected_person