def test_register_device_service_notify_types(self):
        """
        Tests if register_push_device in services workw with extra
        notice_types
        """
        responses.add_callback(
            responses.POST, ZEROPUSH_REGISTER_URL,
            callback=request_register_callback,
            content_type='application/json',
        )

        user = self._create_user()
        device = register_push_device(user, self._create_token(), notice_types='likes')

        # Check if notice_types has 'likes' in it
        notification = device.notification_settings.first()
        assert device.notification_settings.count() == 1
        assert notification.name == 'likes'
        assert notification.send is True

        # Test with multiple notice_types
        device = register_push_device(user, self._create_token(),
                                      notice_types=['likes', 'comments'])

        # Check if notice_types has 'likes' and 'comments'
        assert device.notification_settings.count() == 2

        notification_likes = device.notification_settings.filter(name='likes').first()
        assert notification_likes.send is True

        notification_comments = device.notification_settings.filter(name='comments').first()
        assert notification_comments.send is True
Example #2
0
    def test_register_device_service_notify_types(self):
        """
        Tests if register_push_device in services workw with extra
        notice_types
        """
        responses.add_callback(
            responses.POST,
            ZEROPUSH_REGISTER_URL,
            callback=request_register_callback,
            content_type='application/json',
        )

        user = self._create_user()
        device = register_push_device(user,
                                      self._create_token(),
                                      notice_types='likes')

        # Check if notice_types has 'likes' in it
        notification = device.notification_settings.first()
        assert device.notification_settings.count() == 1
        assert notification.name == 'likes'
        assert notification.send is True

        # Test with multiple notice_types
        device = register_push_device(user,
                                      self._create_token(),
                                      notice_types=['likes', 'comments'])

        # Check if notice_types has 'likes' and 'comments'
        assert device.notification_settings.count() == 2

        notification_likes = device.notification_settings.filter(
            name='likes').first()
        assert notification_likes.send is True

        notification_comments = device.notification_settings.filter(
            name='comments').first()
        assert notification_comments.send is True
    def test_register_device_service(self):
        """
        Tests if register_push_device in services works as expected
        """
        responses.add_callback(
            responses.POST, ZEROPUSH_REGISTER_URL,
            callback=request_register_callback,
            content_type='application/json',
        )

        user = self._create_user()
        device = register_push_device(user, self._create_token())

        assert device is not None
        assert device.user.pk == user.pk
Example #4
0
    def test_register_device_service(self):
        """
        Tests if register_push_device in services works as expected
        """
        responses.add_callback(
            responses.POST,
            ZEROPUSH_REGISTER_URL,
            callback=request_register_callback,
            content_type='application/json',
        )

        user = self._create_user()
        device = register_push_device(user, self._create_token())

        assert device is not None
        assert device.user.pk == user.pk