Skip to content

Commit

Permalink
#108 fix failing unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh4kE committed Mar 18, 2017
1 parent 028c42e commit 34416ef
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions core/tests/unit/views/test_parsing_chain_view.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from unittest.mock import patch

from django.core.urlresolvers import reverse
Expand Down Expand Up @@ -198,42 +199,43 @@ def test_parser_view_do_not_parse_awp_boundaries(self, site_manager_mock, parse_
@patch('core.managers.parser_manager.ParserManager._parse_stadium_statistics')
@patch('core.managers.parser_manager.ParserManager.parse_ofm_version')
@patch('core.managers.parser_manager.ParserManager.parse_awp_boundaries')
@patch('core.managers.parser_manager.ParserManager.parse_all_matches')
@patch('core.managers.parser_manager.ParserManager.parse_finances')
@patch('core.managers.parser_manager.ParserManager.parse_player_statistics')
@patch('core.managers.parser_manager.ParserManager.parse_players')
@patch('core.managers.parser_manager.ParserManager.parse_matchday')
@patch('core.views.trigger_parsing_views.SiteManager')
def test_parser_view_do_not_parse_stadium_statistics(self, site_manager_mock, parse_matchday_mock, # pylint: disable=too-many-arguments
def test_parser_view_do_not_parse_stadium_statistics(self, parse_matchday_mock, # pylint: disable=too-many-arguments
parse_players_mock, parse_player_statistics_mock,
parse_finances_mock, parse_all_matches_mock, parse_awp_mock,
parse_finances_mock, parse_awp_mock,
parse_version_mock, parse_stadium_statistics_mock,
parse_match_details_mock):
site_manager_instance_mock = site_manager_mock.return_value
site_manager_instance_mock.user = self.user
parsing_setting, _ = ParsingSetting.objects.get_or_create(user=self.user)
parsing_setting.parsing_chain_includes_player_statistics = True
parsing_setting.parsing_chain_includes_awp_boundaries = True
parsing_setting.parsing_chain_includes_finances = True
parsing_setting.parsing_chain_includes_matches = True
parsing_setting.parsing_chain_includes_match_details = True
parsing_setting.parsing_chain_includes_match_details_only_for_current_matchday = False
parsing_setting.parsing_chain_includes_stadium_details = False
parsing_setting.save()
response = self.client.get(reverse('core:trigger:trigger_parsing'))

self.assertEqual(response.status_code, 302)
with open(os.path.join(TESTDATA_PATH, 'match_schedule.html'), encoding='utf8') as match_schedule_html:
with patch('core.views.trigger_parsing_views.SiteManager') as site_manager_mock:
site_manager_instance_mock = site_manager_mock.return_value
site_manager_instance_mock.browser.page_source = match_schedule_html
site_manager_instance_mock.user = self.user
parsing_setting, _ = ParsingSetting.objects.get_or_create(user=self.user)
parsing_setting.parsing_chain_includes_player_statistics = True
parsing_setting.parsing_chain_includes_awp_boundaries = True
parsing_setting.parsing_chain_includes_finances = True
parsing_setting.parsing_chain_includes_matches = True
parsing_setting.parsing_chain_includes_match_details = True
parsing_setting.parsing_chain_includes_match_details_only_for_current_matchday = False
parsing_setting.parsing_chain_includes_stadium_details = False
parsing_setting.save()
response = self.client.get(reverse('core:trigger:trigger_parsing'))

assert site_manager_mock.called
assert parse_matchday_mock.called
assert parse_players_mock.called
assert parse_player_statistics_mock.called
assert parse_finances_mock.called
assert parse_all_matches_mock.called
assert parse_match_details_mock.called
assert not parse_stadium_statistics_mock.called
assert parse_awp_mock.called
assert parse_version_mock.called
self.assertEqual(response.status_code, 302)

assert site_manager_mock.called
assert parse_matchday_mock.called
assert parse_players_mock.called
assert parse_player_statistics_mock.called
assert parse_finances_mock.called
assert parse_match_details_mock.called
assert not parse_stadium_statistics_mock.called
assert parse_awp_mock.called
assert parse_version_mock.called

@patch('core.managers.parser_manager.ParserManager.parse_ofm_version')
@patch('core.managers.parser_manager.ParserManager.parse_awp_boundaries')
Expand Down

0 comments on commit 34416ef

Please sign in to comment.