Example #1
0
    def gets_a_notification_only_once(self):
        handler = StubHandler()
        manager = NotificationManager(handler)

        manager.set('foo', 'bar')

        self.assertEqual(manager.get('foo'), 'bar')
        self.assertIsNone(manager.get('foo'))
Example #2
0
    def gets_a_notification_only_once(self):
        handler = StubHandler()
        manager = NotificationManager(handler)

        manager.set('foo', 'bar')

        self.assertEqual(manager.get('foo'), 'bar')
        self.assertIsNone(manager.get('foo'))
Example #3
0
 def uses_custom_notifications_database_if_provided(self):
     handler = StubHandler()
     handler.settings = {
         'pycket': {
             'engine': 'redis',
             'storage': {
                 'db_sessions': 10,
                 'db_notifications': 11,
             }
         }
     }
     manager = NotificationManager(handler)
     manager.set('foo', 'bar')
     self.assertEqual(manager.driver.client.connection_pool._available_connections[0].db, 11)
Example #4
0
 def uses_custom_notifications_database_if_provided(self):
     handler = StubHandler()
     handler.settings = {
         'pycket': {
             'engine': 'redis',
             'storage': {
                 'db_sessions': 10,
                 'db_notifications': 11,
             }
         }
     }
     manager = NotificationManager(handler)
     manager.set('foo', 'bar')
     self.assertEqual(
         manager.driver.client.connection_pool._available_connections[0].db,
         11)
Example #5
0
    def removes_notification_from_database_after_retrieval(self):
        handler = StubHandler()
        manager = NotificationManager(handler)

        manager.set('foo', 'bar')

        raw_notifications = self.client.get(handler.session_id)
        notifications = pickle.loads(raw_notifications)

        self.assertEqual(list(notifications.keys()), ['foo'])

        manager.get('foo')

        raw_notifications = self.client.get(handler.session_id)
        notifications = pickle.loads(raw_notifications)

        self.assertEqual(list(notifications.keys()), [])
Example #6
0
    def removes_notification_from_database_after_retrieval(self):
        handler = StubHandler()
        manager = NotificationManager(handler)

        manager.set('foo', 'bar')

        raw_notifications = self.client.get(handler.session_id)
        notifications = pickle.loads(raw_notifications)

        self.assertEqual(list(notifications.keys()), ['foo'])

        manager.get('foo')

        raw_notifications = self.client.get(handler.session_id)
        notifications = pickle.loads(raw_notifications)

        self.assertEqual(list(notifications.keys()), [])