def setUp(self): testdata = open(os.path.join(TESTDATA_PATH, 'home_match.html'), encoding='utf8') MatchdayFactory.create(number=1) self.user = OFMUserFactory.create() parser = MatchDetailsParser(testdata, self.user, True) self.match_stat = parser.parse()
def test_get_current_matchday(self): MatchdayFactory.create() self.client.login(username='******', password='******') response = self.client.get(reverse('core:ofm:get_current_matchday')) self.assertEqual(response.status_code, 200) returned_json_data = json.loads(response.content.decode('utf-8')) self.assertEqual(returned_json_data['matchday_number'], 0) self.assertEqual(returned_json_data['season_number'], 1)
def test_get_current_matchday(self): MatchdayFactory.create() self.client.login(username='******', password='******') response = self.client.get(reverse('core:ofm:get_current_matchday')) self.assertEqual(response.status_code, 200) returned_json_data = json.loads(response.content.decode('utf-8')) self.assertEqual(returned_json_data['matchday_number'], 0) self.assertEqual(returned_json_data['season_number'], 1)
def setUp(self): testdata = open(os.path.join(TESTDATA_PATH, 'home_match_row_won_by_default.html'), encoding='utf8') MatchdayFactory.create(number=1) self.user = OFMUserFactory.create() soup = BeautifulSoup(testdata, "html.parser") self.parser = BasicMatchRowParser(soup, self.user) self.match_stat = self.parser.parse()
def setUp(self): MatchdayFactory.create(season__number=100, number=1) self.user = OFMUser.objects.create_user(username='******', email='', password='******', ofm_username='******', ofm_password='******') self.client.login(username='******', password='******')
def setUp(self): testdata = open(os.path.join(TESTDATA_PATH, 'future_match_row.html'), encoding='utf8') MatchdayFactory.create(number=1) self.user = OFMUserFactory.create() soup = BeautifulSoup(testdata, "html.parser") parser = BasicMatchRowParser(soup, self.user) self.match_stat = parser.parse()
def test_sold_player_gets_according_attribute(self): testdata = open(os.path.join(TESTDATA_PATH, 'players_one_player_sold.html'), encoding='utf8') MatchdayFactory.create(number=3) parser = PlayersParser(testdata, self.user, self.matchday) parser.parse() sold_players = [c.player for c in Contract.objects.filter(sold_on_matchday__isnull=False)] self.assertEqual(1, len(sold_players)) self.assertEqual("Estaníslão Euklidio", sold_players[0].name)
def setUp(self): MatchdayFactory.create(season__number=100, number=1) self.user = OFMUser.objects.create_user( username='******', email='', password='******', ofm_username='******', ofm_password='******' ) self.client.login(username='******', password='******')
def test_sold_player_gets_according_attribute(self): testdata = open(os.path.join(TESTDATA_PATH, 'players_one_player_sold.html'), encoding='utf8') MatchdayFactory.create(number=3) parser = PlayersParser(testdata, self.user, self.matchday) parser.parse() sold_players = [ c.player for c in Contract.objects.filter(sold_on_matchday__isnull=False) ] self.assertEqual(1, len(sold_players)) self.assertEqual("Estaníslão Euklidio", sold_players[0].name)
def setUp(self): testdata = open(os.path.join(TESTDATA_PATH, 'awp_boundaries.html'), encoding='utf8') self.matchday = MatchdayFactory.create() self.user = OFMUserFactory.create() self.parser = AwpBoundariesParser(testdata, self.user, self.matchday) self.awp_boundaries = self.parser.parse()
def setUp(self): testdata = open(os.path.join(TESTDATA_PATH, 'player.html'), encoding='utf8') self.matchday = MatchdayFactory.create(number=2) self.user = OFMUserFactory.create() self.parser = PlayersParser(testdata, self.user, self.matchday) self.player_list = self.parser.parse() self.first_player = self.player_list[0]
def test_user_can_see_his_finances_diff_when_given_only_newer_matchday( self): third_matchday = MatchdayFactory.create(number=self.matchday.number + 2) FinanceFactory.create(user=self.user1, matchday=third_matchday, balance=2500, income_visitors_league=250, expenses_player_salaries=250) response = self.client.get( reverse('core:ofm:finances_json'), { 'newer_matchday_season': third_matchday.season.number, 'newer_matchday': third_matchday.number }) self.assertEqual(response.status_code, 200) returned_json_data = json.loads(response.content.decode('utf-8')) self.assertEqual(len(returned_json_data), 1) self.assertEqual(returned_json_data[0]['account_balance'], 2500) self.assertEqual(returned_json_data[0]['balance'], 0) self.assertEqual(returned_json_data[0]['sum_income'], 250) self.assertEqual(returned_json_data[0]['sum_expenses'], -250) self.assertEqual(returned_json_data[0]['income_visitors_league'], 250) self.assertEqual(returned_json_data[0]['expenses_player_salaries'], -250)
def test_parser_does_not_create_new_boundaries_object_if_already_exists_for_quarter(self): self.matchday = MatchdayFactory.create(number=2) self.parser = AwpBoundariesParser(open(os.path.join(TESTDATA_PATH, 'awp_boundaries.html'), encoding='utf8'), self.user, self.matchday) self.parser.parse() self.assertEqual(AwpBoundaries.objects.count(), 1)
def test_parser_creates_new_boundaries_object(self): self.matchday = MatchdayFactory.create(number=17) self.parser = AwpBoundariesParser(open(os.path.join(TESTDATA_PATH, 'awp_boundaries.html'), encoding='utf8'), self.user, self.matchday) self.parser.parse() self.assertEqual(AwpBoundaries.objects.count(), 2)
def test_parser_creates_new_boundaries_object(self): self.matchday = MatchdayFactory.create(number=17) self.parser = AwpBoundariesParser( open(os.path.join(TESTDATA_PATH, 'awp_boundaries.html'), encoding='utf8'), self.user, self.matchday) self.parser.parse() self.assertEqual(AwpBoundaries.objects.count(), 2)
def setUp(self): self.matchday = MatchdayFactory.create() self.next_matchday = MatchdayFactory.create(number=1) self.user1 = OFMUser.objects.create_user(username='******', email='*****@*****.**', password='******', ofm_username='******', ofm_password='******') self.finances = FinanceFactory.create(user=self.user1, matchday=self.matchday) self.next_finances = FinanceFactory.create( user=self.user1, matchday=self.next_matchday, balance=2000, income_visitors_league=200, expenses_player_salaries=200) self.client.login(username='******', password='******')
def setUp(self): testdata = open(os.path.join(TESTDATA_PATH, 'player.html'), encoding='utf8') self.matchday = MatchdayFactory.create(number=2) self.user = OFMUserFactory.create() self.parser = PlayersParser(testdata, self.user, self.matchday) self.player_list = self.parser.parse() self.first_player = self.player_list[0]
def test_parser_does_not_create_new_boundaries_object_if_already_exists_for_quarter( self): self.matchday = MatchdayFactory.create(number=2) self.parser = AwpBoundariesParser( open(os.path.join(TESTDATA_PATH, 'awp_boundaries.html'), encoding='utf8'), self.user, self.matchday) self.parser.parse() self.assertEqual(AwpBoundaries.objects.count(), 1)
def setUp(self): MatchdayFactory.create(season__number=100, number=1) self.user = OFMUser.objects.create_user(username='******', email='', password='******', ofm_username='******', ofm_password='******') 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_stadium_details = True parsing_setting.save() self.client.login(username='******', password='******')
def setUp(self): MatchdayFactory.create(season__number=100, number=1) self.user = OFMUser.objects.create_user( username='******', email='', password='******', ofm_username='******', ofm_password='******' ) 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_stadium_details = True parsing_setting.save() self.client.login(username='******', password='******')
def setUp(self): self.matchday = MatchdayFactory.create() self.next_matchday = MatchdayFactory.create(number=1) self.user1 = OFMUser.objects.create_user( username='******', email='*****@*****.**', password='******', ofm_username='******', ofm_password='******' ) self.finances = FinanceFactory.create(user=self.user1, matchday=self.matchday) self.next_finances = FinanceFactory.create( user=self.user1, matchday=self.next_matchday, balance=2000, income_visitors_league=200, expenses_player_salaries=200 ) self.client.login(username='******', password='******')
def setUp(self): self.user = OFMUser.objects.create_user( username='******', email='*****@*****.**', password='******', ofm_username="******", ofm_password="******") self.checklist = ChecklistFactory.create(user=self.user) self.checklist_item = ChecklistItemFactory.create( checklist=self.checklist, name='do more unit tests') self.user2 = OFMUser.objects.create_user(username='******', email='*****@*****.**', password='******', ofm_username="******", ofm_password="******") checklist2 = ChecklistFactory.create(user=self.user2) ChecklistItemFactory.create(checklist=checklist2, name='do less unit tests') self.matchday = MatchdayFactory.create(number=6)
def test_get_checklist_items_for_today_if_tomorrow_home_match(self): matchday2 = MatchdayFactory.create(number=7) FinanceFactory.create(matchday=self.matchday, user=self.user) MatchFactory.create(matchday=matchday2, venue='', is_home_match=True, user=self.user) self.client.login(username='******', password='******') c1 = ChecklistItemFactory.create( checklist=self.checklist, name='on 6th and 9th matchday', to_be_checked_on_matchdays='6,9' ) c2 = ChecklistItemFactory.create( checklist=self.checklist, name='on every 2nd matchday', to_be_checked_on_matchday_pattern=2 ) c3 = ChecklistItemFactory.create( checklist=self.checklist, name='on every 9th matchday', to_be_checked_on_matchday_pattern=9 ) c4 = ChecklistItemFactory.create( checklist=self.checklist, name='if tomorrow home_match', to_be_checked_if_home_match_tomorrow=True ) c5 = ChecklistItemFactory.create( checklist=self.checklist, name='if not tomorrow home_match', to_be_checked_if_home_match_tomorrow=True, is_inversed=True ) response = self.client.get(reverse('core:checklist:get_checklist_items_for_today')) self.assertEqual(response.status_code, 200) returned_json_data = json.loads(response.content.decode('utf-8')) returned_checklist_item_ids = [checklist_item['id'] for checklist_item in returned_json_data] self.assertTrue(self.checklist_item.id in returned_checklist_item_ids) self.assertTrue(c1.id in returned_checklist_item_ids) self.assertTrue(c2.id in returned_checklist_item_ids) self.assertTrue(c3.id not in returned_checklist_item_ids) self.assertTrue(c4.id in returned_checklist_item_ids) self.assertTrue(c5.id not in returned_checklist_item_ids)
def setUp(self): self.user = OFMUser.objects.create_user( username='******', email='*****@*****.**', password='******', ofm_username="******", ofm_password="******" ) self.checklist = ChecklistFactory.create(user=self.user) self.checklist_item = ChecklistItemFactory.create(checklist=self.checklist, name='do more unit tests') self.user2 = OFMUser.objects.create_user( username='******', email='*****@*****.**', password='******', ofm_username="******", ofm_password="******" ) checklist2 = ChecklistFactory.create(user=self.user2) ChecklistItemFactory.create(checklist=checklist2, name='do less unit tests') self.matchday = MatchdayFactory.create(number=6)
def test_get_checklist_items_for_today_if_tomorrow_home_match(self): matchday2 = MatchdayFactory.create(number=7) FinanceFactory.create(matchday=self.matchday, user=self.user) MatchFactory.create(matchday=matchday2, venue='', is_home_match=True, user=self.user) self.client.login(username='******', password='******') c1 = ChecklistItemFactory.create(checklist=self.checklist, name='on 6th and 9th matchday', to_be_checked_on_matchdays='6,9') c2 = ChecklistItemFactory.create(checklist=self.checklist, name='on every 2nd matchday', to_be_checked_on_matchday_pattern=2) c3 = ChecklistItemFactory.create(checklist=self.checklist, name='on every 9th matchday', to_be_checked_on_matchday_pattern=9) c4 = ChecklistItemFactory.create( checklist=self.checklist, name='if tomorrow home_match', to_be_checked_if_home_match_tomorrow=True) c5 = ChecklistItemFactory.create( checklist=self.checklist, name='if not tomorrow home_match', to_be_checked_if_home_match_tomorrow=True, is_inversed=True) response = self.client.get( reverse('core:checklist:get_checklist_items_for_today')) self.assertEqual(response.status_code, 200) returned_json_data = json.loads(response.content.decode('utf-8')) returned_checklist_item_ids = [ checklist_item['id'] for checklist_item in returned_json_data ] self.assertTrue(self.checklist_item.id in returned_checklist_item_ids) self.assertTrue(c1.id in returned_checklist_item_ids) self.assertTrue(c2.id in returned_checklist_item_ids) self.assertTrue(c3.id not in returned_checklist_item_ids) self.assertTrue(c4.id in returned_checklist_item_ids) self.assertTrue(c5.id not in returned_checklist_item_ids)
def setUp(self): testdata = open(os.path.join(TESTDATA_PATH, 'awp_boundaries.html'), encoding='utf8') self.matchday = MatchdayFactory.create() self.user = OFMUserFactory.create() self.parser = AwpBoundariesParser(testdata, self.user, self.matchday) self.awp_boundaries = self.parser.parse()