예제 #1
0
    def test_fcm_notification_team_winner(self):
        self.winner_award.team_list = [self.team.key]
        self.winner_award.put()

        notification = AwardsNotification(self.event, self.team)

        self.assertIsNotNone(notification.fcm_notification)
        self.assertEqual(notification.fcm_notification.title, 'Team 7332 Awards')
        self.assertEqual(notification.fcm_notification.body, 'Team 7332 is the District Event Winner at the 2020 Kettering University #1 District.')
예제 #2
0
    def test_fcm_notification_team(self):
        self.award.team_list = [self.team.key]
        self.award.put()

        notification = AwardsNotification(self.event, self.team)

        self.assertIsNotNone(notification.fcm_notification)
        self.assertEqual(notification.fcm_notification.title, 'Team 7332 Awards')
        self.assertEqual(notification.fcm_notification.body, 'Team 7332 won the Industrial Design Award sponsored by General Motors at the 2020 Kettering University #1 District.')
예제 #3
0
    def awards(cls, event, user_id=None):
        if user_id:
            users = [user_id]
        else:
            users = Subscription.users_subscribed_to_event(
                event, NotificationType.AWARDS)

        from models.notifications.awards import AwardsNotification
        # Send to FCM/webhooks
        cls._send(users, AwardsNotification(event))
예제 #4
0
    def test_fcm_notification_team_finalist(self):
        self.winner_award.award_type_enum=AwardType.WINNER
        self.winner_award.name_str='District Event Finalist'
        self.winner_award.team_list = [self.team.key]
        self.winner_award.put()

        notification = AwardsNotification(self.event, self.team)

        self.assertIsNotNone(notification.fcm_notification)
        self.assertEqual(notification.fcm_notification.title, 'Team 7332 Awards')
        self.assertEqual(notification.fcm_notification.body, 'Team 7332 is the District Event Finalist at the 2020 Kettering University #1 District.')
예제 #5
0
    def test_webhook_message_data(self):
        self.award.put()
        self.winner_award.put()

        notification = AwardsNotification(self.event)

        payload = notification.webhook_message_data
        self.assertEqual(len(payload), 3)
        self.assertEqual(payload['event_key'], '2020miket')
        self.assertEqual(payload['event_name'], 'FIM District Kettering University Event #1')
        self.assertIsNotNone(payload['awards'])
        self.assertEqual(len(payload['awards']), 2)
예제 #6
0
    def test_webhook_message_data_team(self):
        self.award.team_list = [self.team.key]
        self.award.put()

        notification = AwardsNotification(self.event, self.team)

        payload = notification.webhook_message_data
        self.assertEqual(len(payload), 4)
        self.assertEqual(payload['event_key'], '2020miket')
        self.assertEqual(payload['team_key'], 'frc7332')
        self.assertEqual(payload['event_name'], 'FIM District Kettering University Event #1')
        self.assertIsNotNone(payload['awards'])
        self.assertEqual(len(payload['awards']), 1)
예제 #7
0
    def awards(cls, event, user_id=None):
        from models.notifications.awards import AwardsNotification
        # Send to Event subscribers
        if NotificationType.AWARDS in NotificationType.enabled_event_notifications:
            users = [user_id] if user_id else []
            if not users:
                users = Subscription.users_subscribed_to_event(event, NotificationType.AWARDS)
            if users:
                cls._send(users, AwardsNotification(event))

        # Send to Team subscribers
        if NotificationType.AWARDS in NotificationType.enabled_team_notifications:
            # Map all Teams to their Awards so we can populate our Awards notification with more specific info
            team_awards = event.team_awards()
            for team_key in team_awards.keys():
                team = team_key.get()

                users = [user_id] if user_id else []
                if not users:
                    users = Subscription.users_subscribed_to_team(team, NotificationType.AWARDS)
                if users:
                    cls._send(users, AwardsNotification(event, team))
예제 #8
0
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        ndb.get_context().clear_cache()

        self.testbed.init_taskqueue_stub(root_path=".")

        for team_number in range(7):
            Team(id="frc%s" % team_number, team_number=team_number).put()

        self.event = EventTestCreator.createPresentEvent()
        self.notification = AwardsNotification(self.event)
예제 #9
0
 def test_fcm_notification_event(self):
     notification = AwardsNotification(self.event)
     self.assertIsNotNone(notification.fcm_notification)
     self.assertEqual(notification.fcm_notification.title, 'MIKET Awards')
     self.assertEqual(notification.fcm_notification.body, '2020 Kettering University #1 District awards have been posted.')
예제 #10
0
 def test_type(self):
     notification = AwardsNotification(self.event)
     self.assertEqual(AwardsNotification._type(), NotificationType.AWARDS)
예제 #11
0
 def test_data_payload_team(self):
     notification = AwardsNotification(self.event, self.team)
     payload = notification.data_payload
     self.assertEqual(len(payload), 2)
     self.assertEqual(payload['event_key'], '2020miket')
     self.assertEqual(payload['team_key'], 'frc7332')
예제 #12
0
 def test_data_payload(self):
     notification = AwardsNotification(self.event)
     # No `event_name`
     payload = notification.data_payload
     self.assertEqual(len(payload), 1)
     self.assertEqual(payload['event_key'], '2020miket')
예제 #13
0
 def test_type(self):
     self.assertEqual(AwardsNotification._type(), NotificationType.AWARDS)