예제 #1
0
 def test_setattr_syncs_to_cache(self):
     workflow_id = uuid4()
     context = {'workflow_execution_id': workflow_id}
     app = AppBase('Something', self.device2.id, context)
     app._cache = self.cache
     app.foo = 42
     app.bar = 23
     self.assertSetEqual(
         set(self.cache.scan()),
         {app._format_cache_key('foo'), app._format_cache_key('bar')}
     )
     for field, expected in (('foo', 42), ('bar', 23)):
         self.assertEqual(dill.loads(self.cache.get(app._format_cache_key(field))), expected)
예제 #2
0
 def test_setattr_syncs_to_cache(self):
     workflow_id = uuid4()
     context = {'workflow_execution_id': workflow_id}
     app = AppBase('Something', self.device2.id, context)
     app._cache = self.cache
     app.foo = 42
     app.bar = 23
     self.assertSetEqual(
         set(self.cache.scan()),
         {app._format_cache_key('foo'),
          app._format_cache_key('bar')})
     for field, expected in (('foo', 42), ('bar', 23)):
         self.assertEqual(
             dill.loads(self.cache.get(app._format_cache_key(field))),
             expected)
예제 #3
0
 def test_getattr_gets_from_cache(self):
     workflow_id = uuid4()
     context = {'workflow_execution_id': workflow_id}
     app = AppBase('Something', self.device2.id, context)
     app._cache = self.cache
     app.foo = 42
     app.bar = 23
     self.cache.set(app._format_cache_key('foo'), dill.dumps('a'))
     self.cache.set(app._format_cache_key('bar'), dill.dumps('b'))
     self.assertEqual(app.foo, 'a')
     self.assertEqual(app.bar, 'b')
     with self.assertRaises(AttributeError):
         y = app.baz
예제 #4
0
 def test_getattr_gets_from_cache(self):
     workflow_id = uuid4()
     context = {'workflow_execution_id': workflow_id}
     app = AppBase('Something', self.device2.id, context)
     app._cache = self.cache
     app.foo = 42
     app.bar = 23
     self.cache.set(app._format_cache_key('foo'), dill.dumps('a'))
     self.cache.set(app._format_cache_key('bar'), dill.dumps('b'))
     self.assertEqual(app.foo, 'a')
     self.assertEqual(app.bar, 'b')
     with self.assertRaises(AttributeError):
         y = app.baz