class TestBaseNotification(unittest2.TestCase):
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()

        # User a Ping notification to test the render and send classes
        # It's as simple as it gets
        self.notification = PingNotification()
        self.keys = {
            ClientType.OS_ANDROID: ["abc123"],
            ClientType.WEBHOOK: ["123abc"]
        }
        self.notification.keys = self.keys

    def tearDown(self):
        self.testbed.deactivate()

    def test_render_android(self):
        message = self.notification._render_android()

        self.assertEqual(self.keys[ClientType.OS_ANDROID],
                         message.device_tokens)
        self.assertEqual(self.notification._build_dict(), message.notification)

    def test_render_webhook(self):
        message = self.notification._render_webhook()

        self.assertEqual(message, self.notification._build_dict())

    def test_render_ios(self):
        pass
class TestBaseNotification(unittest2.TestCase):
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()

        # User a Ping notification to test the render and send classes
        # It's as simple as it gets
        self.notification = PingNotification()
        self.keys = {ClientType.OS_ANDROID: ["abc123"], ClientType.WEBHOOK: ["123abc"]}
        self.notification.keys = self.keys

    def tearDown(self):
        self.testbed.deactivate()

    def test_render_android(self):
        message = self.notification._render_android()

        self.assertEqual(self.keys[ClientType.OS_ANDROID], message.device_tokens)
        self.assertEqual(self.notification._build_dict(), message.notification)

    def test_render_webhook(self):
        message = self.notification._render_webhook()

        self.assertEqual(message, self.notification._build_dict())

    def test_render_ios(self):
        pass
class TestBaseNotification(unittest2.TestCase):
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()

        # User a Ping notification to test the render and send classes
        # It's as simple as it gets
        self.notification = PingNotification()
        self.keys = {
            ClientType.OS_ANDROID: ["abc123"],
            ClientType.WEBHOOK: ["123abc"]
        }
        self.notification.keys = self.keys

    def tearDown(self):
        self.testbed.deactivate()

    def test_render_android(self):
        self._test_render_gcm(ClientType.OS_ANDROID)

    def test_render_webhook(self):
        message = self.notification._render_webhook()
        expect = {
            'message_type': 'ping',
            'message_data': {
                'title':
                'Test Message',
                'desc':
                'This is a test message ensuring your device can recieve push messages from The Blue Alliance.'
            }
        }
        self.assertEqual(message, expect)

    def _test_render_gcm(self, client_type):
        message = self.notification._render_gcm(client_type)

        self.assertEqual(self.keys[client_type], message.device_tokens)
        self.assertEqual(self.notification._build_dict(), message.notification)

    def test_render_method(self):
        self.assertEqual(
            self.notification.render_method(ClientType.OS_ANDROID),
            self.notification._render_android)
        self.assertEqual(self.notification.render_method(ClientType.WEBHOOK),
                         self.notification._render_webhook)

    def test_render_method_renders(self):
        client_type = ClientType.OS_ANDROID
        client_render_method = self.notification.render_method(client_type)

        message = client_render_method()
        self.assertEqual(self.keys[client_type], message.device_tokens)
        self.assertEqual(self.notification._build_dict(), message.notification)
Пример #4
0
class TestUserPingNotification(unittest2.TestCase):
    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(
        )  # Prevent data from leaking between tests

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

        self.notification = PingNotification()

    def tearDown(self):
        self.testbed.deactivate()

    def test_build(self):
        expected = {}
        expected['message_type'] = NotificationType.type_names[
            NotificationType.PING]
        expected['message_data'] = {
            'title':
            "Test Message",
            'desc':
            "This is a test message ensuring your device can recieve push messages from The Blue Alliance."
        }

        data = self.notification._build_dict()

        self.assertEqual(expected, data)
Пример #5
0
class TestBaseNotification(unittest2.TestCase):
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()

        # User a Ping notification to test the render and send classes
        # It's as simple as it gets
        self.notification = PingNotification()
        self.keys = {ClientType.OS_IOS: ["abc123"], ClientType.OS_ANDROID: ["abc123"], ClientType.WEB: ["abc123"], ClientType.WEBHOOK: ["123abc"]}
        self.notification.keys = self.keys

    def tearDown(self):
        self.testbed.deactivate()

    def test_render_android(self):
        self._test_render_gcm(ClientType.OS_ANDROID)

    def test_render_ios(self):
        self._test_render_gcm(ClientType.OS_IOS)

    def test_render_web(self):
        self._test_render_gcm(ClientType.WEB)

    def test_render_webhook(self):
        message = self.notification._render_webhook()

        self.assertEqual(message, self.notification._build_dict())

    def _test_render_gcm(self, client_type):
        message = self.notification._render_gcm(client_type)

        self.assertEqual(self.keys[client_type], message.device_tokens)
        self.assertEqual(self.notification._build_dict(), message.notification)

    def test_render_method(self):
        self.assertEqual(self.notification.render_method(ClientType.OS_ANDROID), self.notification._render_android)
        self.assertEqual(self.notification.render_method(ClientType.OS_IOS), self.notification._render_ios)
        self.assertEqual(self.notification.render_method(ClientType.WEB), self.notification._render_web)
        self.assertEqual(self.notification.render_method(ClientType.WEBHOOK), self.notification._render_webhook)

    def test_render_method_renders(self):
        client_type = ClientType.OS_IOS
        client_render_method = self.notification.render_method(client_type)

        message = client_render_method()
        self.assertEqual(self.keys[client_type], message.device_tokens)
        self.assertEqual(self.notification._build_dict(), message.notification)
class TestBaseNotification(unittest2.TestCase):
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()

        # User a Ping notification to test the render and send classes
        # It's as simple as it gets
        self.notification = PingNotification()
        self.keys = {ClientType.OS_ANDROID: ["abc123"], ClientType.WEBHOOK: ["123abc"]}
        self.notification.keys = self.keys

    def tearDown(self):
        self.testbed.deactivate()

    def test_render_android(self):
        self._test_render_gcm(ClientType.OS_ANDROID)

    def test_render_webhook(self):
        message = self.notification._render_webhook()
        expect = {
            'message_type': 'ping',
            'message_data': {
                'title': 'Test Message',
                'desc': 'This is a test message ensuring your device can recieve push messages from The Blue Alliance.'
            }
        }
        self.assertEqual(message, expect)

    def _test_render_gcm(self, client_type):
        message = self.notification._render_gcm(client_type)

        self.assertEqual(self.keys[client_type], message.device_tokens)
        self.assertEqual(self.notification._build_dict(), message.notification)

    def test_render_method(self):
        self.assertEqual(self.notification.render_method(ClientType.OS_ANDROID), self.notification._render_android)
        self.assertEqual(self.notification.render_method(ClientType.WEBHOOK), self.notification._render_webhook)

    def test_render_method_renders(self):
        client_type = ClientType.OS_ANDROID
        client_render_method = self.notification.render_method(client_type)

        message = client_render_method()
        self.assertEqual(self.keys[client_type], message.device_tokens)
        self.assertEqual(self.notification._build_dict(), message.notification)
class TestUserPingNotification(unittest2.TestCase):
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()

        self.notification = PingNotification()

    def tearDown(self):
        self.testbed.deactivate()

    def test_build(self):
        expected = {}
        expected['message_type'] = NotificationType.type_names[NotificationType.PING]
        expected['message_data'] = {'title': "Test Message",
                                    'desc': "This is a test message ensuring your device can recieve push messages from The Blue Alliance."}

        data = self.notification._build_dict()

        self.assertEqual(expected, data)
Пример #8
0
class TestUserPingNotification(unittest2.TestCase):
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()

        self.notification = PingNotification()

    def tearDown(self):
        self.testbed.deactivate()

    def test_build(self):
        expected = {}
        expected['message_type'] = NotificationType.type_names[NotificationType.PING]
        expected['message_data'] = {'title': "Test Message",
                                    'desc': "This is a test message ensuring your device can recieve push messages from The Blue Alliance."}

        data = self.notification._build_dict()

        self.assertEqual(expected, data)
class TestUserPingNotification(unittest2.TestCase):
    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()  # Prevent data from leaking between tests

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

        self.notification = PingNotification()

    def tearDown(self):
        self.testbed.deactivate()

    def test_build(self):
        expected = {}
        expected['notification_type'] = NotificationType.type_names[NotificationType.PING]
        expected['message_data'] = {'title': "Test Message",
                                    'desc': "This is a test message ensuring your device can recieve push messages from The Blue Alliance."}

        data = self.notification._build_dict()

        self.assertEqual(expected, data)