def test_scheduler_sends_highlight_message_for_subscribed_team_when_too_recent_but_priority_is_set( self): # Given h = LatestHighlight.objects.filter( link='http://hoofoot/barcelona-liverpool')[0] h.priority_short = 1 h.save() # When self.send_most_recent_highlights() # Then messages = [json.loads(m) for m in sender.CLIENT.messages] assert_highlight_in( create_formatted_highlight_response( id=3, team1='Barcelona', score1=1, team2='Liverpool', score2=1, competition='Champions League', ), messages) # Set back old properties h.priority_short = 0 h.save()
def test_scheduler_does_not_send_highlight_with_incomplete_data(self): # Given # When self.send_most_recent_highlights() # Then messages = [json.loads(m) for m in sender.CLIENT.messages] assert_highlight_not_in( create_formatted_highlight_response( id=9, team1='Marseille', score1=-1, team2='Monaco', score2=-1, competition='Ligue 1', ), messages)
def test_scheduler_send_highlight_message_for_subscribed_team(self): # Given # When self.send_most_recent_highlights() # Then messages = [json.loads(m) for m in sender.CLIENT.messages] assert_highlight_in( create_formatted_highlight_response( id=2, team1='Burnley', score1=0, team2='Barcelona', score2=2, competition='Champions League', ), messages)
def test_scheduler_does_not_send_highlight_when_date_too_old(self): # Given # When self.send_most_recent_highlights() # Then messages = [json.loads(m) for m in sender.CLIENT.messages] assert_highlight_not_in( create_formatted_highlight_response( id=9, team1='Swansea', score1=0, team2='Barcelona', score2=3, competition='Champions League', ), messages)
def test_scheduler_send_highlight_message_for_subscribed_competition(self): # Given # When self.send_most_recent_highlights() # Then messages = [json.loads(m) for m in sender.CLIENT.messages] assert_highlight_in( create_formatted_highlight_response( id=5, team1='Arsenal', score1=0, team2='Liverpool', score2=4, competition='Premier League', ), messages)
def test_scheduler_overrides_picture_and_goals_for_highlights(self): # Given # When self.send_most_recent_highlights() # Then messages = [json.loads(m) for m in sender.CLIENT.messages] assert_highlight_in( create_formatted_highlight_response( id=10, team1='Manchester City', score1=0, team2='Tottenham', score2=0, competition='Premier League', ), messages)
def test_scheduler_does_not_send_highlight_message_for_subscribed_team_when_too_recent( self): # Given # When self.send_most_recent_highlights() # Then messages = [json.loads(m) for m in sender.CLIENT.messages] assert_highlight_not_in( create_formatted_highlight_response( id=6, team1='Barcelona', score1=1, team2='Liverpool', score2=1, competition='Champions League', ), messages)
def test_highlights_blocked_when_competition_flagged_in_blocked_notification( self): # Given # When self.send_most_recent_highlights() # Then messages = [json.loads(m) for m in sender.CLIENT.messages] assert_highlight_not_in( create_formatted_highlight_response( id=16, team1='France', score1=2, team2='England', score2=0, competition='Nations League', ), messages)
def test_scheduler_does_not_send_highlight_if_highlight_inverted_home_and_away_teams( self): # Given # When self.send_most_recent_highlights() # Then messages = [json.loads(m) for m in sender.CLIENT.messages] assert_highlight_not_in( create_formatted_highlight_response( id=9, team1='Barcelona', score1=2, team2='Chelsea', score2=0, competition='Champions League', ), messages)
def test_scheduler_should_send_highlight_when_no_goal_info_but_no_goals_in_match( self): # Given # When self.send_most_recent_highlights() # Then messages = [json.loads(m) for m in sender.CLIENT.messages] assert_highlight_in( create_formatted_highlight_response(id=20, team1='Belgium', score1=0, team2='England', score2=0, competition='Nations League', img_link=TEST_UPLOADED_IMAGE), messages)
def test_scheduler_does_not_send_highlight_when_no_goals_info_before_30_minutes( self): # Given # When self.send_most_recent_highlights() # Then messages = [json.loads(m) for m in sender.CLIENT.messages] assert_highlight_not_in( create_formatted_highlight_response(id=19, team1='Belgium', score1=1, team2='Liverpool', score2=0, competition='Nations League', img_link=TEST_UPLOADED_IMAGE), messages)
def test_scheduler_does_not_send_highlights_straight_if_goals_scored_in_last_minutes_of_match( self): # Given # When self.send_most_recent_highlights() # Then messages = [json.loads(m) for m in sender.CLIENT.messages] assert_highlight_not_in( create_formatted_highlight_response(id=18, team1='Liverpool', score1=1, team2='France', score2=0, competition='Nations League', img_link=TEST_UPLOADED_IMAGE), messages)
def test_scheduler_send_highlight_with_see_result_disabled(self): # Given user = user_manager.get_user(TEST_USER_ID) user.see_result = False user.save() # When self.send_most_recent_highlights() # Then messages = [json.loads(m) for m in sender.CLIENT.messages] assert_highlight_in( create_formatted_highlight_response(id=2, team1='Burnley', score1=0, team2='Barcelona', score2=2, competition='Champions League', score_hidden=True), messages) self.assertNotIn( { 'recipient': { 'id': str(TEST_USER_ID) }, "messaging_type": "MESSAGE_TAG", "tag": "NON_PROMOTIONAL_SUBSCRIPTION", "message": { "text": "Barcelona ⚽\nL. Messi - 4 (p), 90\nL. Suarez - 43\n\nReal Madrid ⚽\nC. Ronaldo - 10\nG. Pique - 56 (o.g)" } }, messages) # Set back old properties user.see_result = True user.save()