diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2010-03-10 17:50:51 -0800 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2010-03-10 17:50:51 -0800 |
commit | bd411f99f890d918b192156e882be743e6fbf545 (patch) | |
tree | 44be7ee0588d01b3706e7b83e9da72d9dcbaf85c /tests/pipeline.py | |
parent | 708c458adb8d90a00041977df4880d28a11e2cb9 (diff) | |
download | redis-py-bd411f99f890d918b192156e882be743e6fbf545.tar.gz |
Pipeline objects are now executed atomically via the MULTI and EXEC commands
Diffstat (limited to 'tests/pipeline.py')
-rw-r--r-- | tests/pipeline.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/pipeline.py b/tests/pipeline.py index cd130d1..da85e55 100644 --- a/tests/pipeline.py +++ b/tests/pipeline.py @@ -23,3 +23,33 @@ class PipelineTestCase(unittest.TestCase): [('z1', 2.0), ('z2', 4)] ] ) + + def test_invalid_command_in_pipeline(self): + # all commands but the invalid one should be excuted correctly + self.client['c'] = 'a' + pipe = self.client.pipeline() + pipe.set('a', 1).set('b', 2).lpush('c', 3).set('d', 4) + result = pipe.execute() + + self.assertEquals(result[0], True) + self.assertEquals(self.client['a'], '1') + self.assertEquals(result[1], True) + self.assertEquals(self.client['b'], '2') + # we can't lpush to a key that's a string value, so this should + # be a ResponseError exception + self.assert_(isinstance(result[2], redis.ResponseError)) + self.assertEquals(self.client['c'], 'a') + self.assertEquals(result[3], True) + self.assertEquals(self.client['d'], '4') + + # make sure the pipe was restored to a working state + self.assertEquals(pipe.set('z', 'zzz').execute(), [True]) + self.assertEquals(self.client['z'], 'zzz') + + def test_pipe_cannot_select(self): + pipe = self.client.pipeline() + self.assertRaises(redis.RedisError, + pipe.select, 'localhost', 6379, db=9) + + + |