35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
import unittest
|
|
|
|
import mockredis
|
|
from nose.tools import eq_
|
|
|
|
from helix.store import Store
|
|
|
|
|
|
class StoreTest(unittest.TestCase):
|
|
def setUp(self):
|
|
self.mock_redis = mockredis.mock_redis_client()
|
|
self.subject = Store(self.mock_redis, 'abcdef')
|
|
|
|
def test_saving_and_retrieving_list_of_maps(self):
|
|
self.subject.append_map_to_list('my_list', {'a': 'b', 'c': 'd'})
|
|
self.subject.append_map_to_list('my_list', {'e': 'f', 'g': 'h'})
|
|
|
|
eq_(self.subject.get_list_of_maps('my_list'), [{'a': 'b', 'c': 'd'}, {'e': 'f', 'g': 'h'}])
|
|
|
|
def test_updating_a_map_in_a_list(self):
|
|
self.subject.append_map_to_list('my_list', {'a': 'b', 'c': 'd'})
|
|
self.subject.append_map_to_list('my_list', {'e': 'f', 'g': 'h'})
|
|
|
|
self.subject.replace_map_in_list('my_list', {'a': 'z', 'c': 'y'}, 0)
|
|
|
|
eq_(self.subject.get_list_of_maps('my_list'), [{'a': 'z', 'c': 'y'}, {'e': 'f', 'g': 'h'}])
|
|
|
|
def test_removing_map_from_list(self):
|
|
self.subject.append_map_to_list('my_list', {'a': 'b', 'c': 'd'})
|
|
self.subject.append_map_to_list('my_list', {'e': 'f', 'g': 'h'})
|
|
|
|
self.subject.remove_map_from_list('my_list', 0)
|
|
|
|
eq_(self.subject.get_list_of_maps('my_list'), [{'e': 'f', 'g': 'h'}])
|