Exemple #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')
Exemple #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')
Exemple #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'))
Exemple #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)
Exemple #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)
Exemple #6
0
    def sets_object_with_dict_key(self):
        handler = StubHandler()
        manager = NotificationManager(handler)

        manager['foo'] = 'bar'

        self.assertEqual(manager['foo'], 'bar')
Exemple #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()), [])
Exemple #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'))
Exemple #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()), [])