Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    def test_highlights_not_blocked_when_competition_not_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_in(
            create_formatted_highlight_response(
                id=15,
                team1='France',
                score1=2,
                team2='Belgium',
                score2=0,
                competition='Nations League',
            ), messages)
Ejemplo n.º 6
0
    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)
Ejemplo n.º 7
0
    def test_scheduler_sends_highlights_straight_if_no_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_in(
            create_formatted_highlight_response(id=17,
                                                team1='Liverpool',
                                                score1=1,
                                                team2='England',
                                                score2=0,
                                                competition='Nations League',
                                                img_link=TEST_UPLOADED_IMAGE),
            messages)
Ejemplo n.º 8
0
    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()