class MemoryBackendTest(unittest.TestCase): def setUp(self): self.backend = MemoryBackend(keys=['kind', 'user', 'game']) def test_basic(self): items = [ {'kind': 'play', 'user': 1, 'game': 'bloons'}, {'kind': 'play', 'user': 1, 'game': 'ryokan'}, {'kind': 'high-score', 'user': 1, 'game': 'ryokan', 'score': 10}, {'kind': 'high-score', 'user': 2, 'game': 'ryokan', 'score': 20}, ] # First we insert some data for item in items: self.backend.insert(item) # Now we assert that it comes back properly in different queries self.assertEqual(self.backend.items(), list(reversed(items))) self.assertEqual(self.backend.items(kind='play'), [items[1], items[0]]) self.assertEqual(self.backend.items(user=1), [items[2], items[1], items[0]]) self.assertEqual(self.backend.items(user=2), [items[3]]) self.assertEqual(self.backend.items(user=1, kind='play'), [items[1], items[0]]) self.assertEqual(self.backend.items(user=1, kind='high-score'), [items[2]]) self.assertEqual(self.backend.items(user=[1, 2]), list(reversed(items)))
def setUp(self): self.backend = MemoryBackend(keys=['kind', 'user', 'game'])
print ">>> c.items(user=[1, 2], kind=['high-score', 'play'])" pprint(c.items(user=[1, 2], kind=['high-score', 'play'])) ########NEW FILE######## __FILENAME__ = memory_server import os import sys # Munge the path a bit to make this work from directly within the examples dir sys.path.insert(0, os.path.abspath(os.path.join(__file__, '..', '..'))) from awesomestream.backends import MemoryBackend from awesomestream.jsonrpc import create_app, run_server if __name__ == '__main__': backend = MemoryBackend(keys=['kind', 'user', 'game']) app = create_app(backend) run_server(app, 9997) ########NEW FILE######## __FILENAME__ = redis_server import os import sys # Munge the path a bit to make this work from directly within the examples dir sys.path.insert(0, os.path.abspath(os.path.join(__file__, '..', '..'))) from awesomestream.backends import RedisBackend from awesomestream.jsonrpc import create_app, run_server if __name__ == '__main__': backend = RedisBackend(keys=['kind', 'user', 'game'],