Пример #1
0
    def gets_default_value_if_provided_and_not_in_client(self):
        handler = StubHandler()
        manager = NotificationManager(handler)

        value = manager.get('foo', 'Default')

        self.assertEqual(value, 'Default')
Пример #2
0
    def gets_default_value_if_provided_and_not_in_client(self):
        handler = StubHandler()
        manager = NotificationManager(handler)

        value = manager.get('foo', 'Default')

        self.assertEqual(value, 'Default')
Пример #3
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'))
Пример #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)
Пример #5
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)
Пример #6
0
    def sets_object_with_dict_key(self):
        handler = StubHandler()
        manager = NotificationManager(handler)

        manager['foo'] = 'bar'

        self.assertEqual(manager['foo'], 'bar')
Пример #7
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()), [])
Пример #8
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'))
Пример #9
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()), [])