def test_should_not_download_game_if_there_is_no_game(self, exists_match, get_details_match, d2api): r = mock.Mock() r.results_remaining = 0 d2api.get_match_history.return_value = r tasks._download_games(1) self.assertFalse(get_details_match.called, 'Should not download any game.') d2api.get_match_history.assert_called_with(1, start_at_match_id=None)
def test_should_download_games_if_there_is(self, exists_match, get_details_match, d2api): match = mock.Mock() match.match_id = 321 first_request = mock.Mock() first_request.results_remaining = 1 first_request.matches = [match] second_request = mock.Mock() second_request.results_remaining = 0 second_request.matches = [] exists_match.return_value = False d2api.get_match_history.side_effect = [first_request, second_request] tasks._download_games(1) get_details_match.assert_called_with(321) self.assertEqual(mock.call(1, start_at_match_id=None), d2api.get_match_history.call_args_list[0]) self.assertEqual(mock.call(1, start_at_match_id=321), d2api.get_match_history.call_args_list[1])