예제 #1
0
 def test_copy(self):
     Cache.clean()
     id = 'd'
     new_id = 'new_' + id
     Cache.add(self.__d, id)
     Cache.copy(id, new_id)
     self.assertDictEqual(Cache.get(new_id), self.__d)
예제 #2
0
 def test_touch(self):
     Cache.clean()
     self.assertDictEqual(Cache.get_objects(), {})
     Cache.touch(self.__d, 'd')
     self.assertDictEqual(Cache.get('d'), self.__d)
     Cache.touch(None, 'd')
     self.assertDictEqual(Cache.get('d'), self.__d)
     Cache.touch({}, 'd')
     self.assertDictEqual(Cache.get('d'), self.__d)
예제 #3
0
 def test_get_list_of_objects(self):
     Cache.clean()
     Cache.add(self.__d, 'd')
     self.assertListEqual(Cache.get_list_of_objects(), ['d'])
예제 #4
0
 def test_get_objects(self):
     Cache.clean()
     Cache.add(self.__d, 'd')
     self.assertDictEqual(Cache.get_objects(), {'d': self.__d})
예제 #5
0
 def test_get_wrong_id(self):
     Cache.clean()
     Cache.add(self.__d, 'd')
     self.assertEqual(Cache.get('d1'), None)
예제 #6
0
 def test_remove_object_by_wrong_id(self):
     Cache.clean()
     Cache.add(self.__d, 'd')
     Cache.remove_object_by_id('d1')
     self.assertDictEqual(Cache.get('d'), self.__d)
예제 #7
0
 def test_remove_object_by_id(self):
     Cache.clean()
     Cache.add(self.__d, 'd')
     Cache.remove_object_by_id('d')
     self.assertEqual(Cache.get('d'), None)
예제 #8
0
 def test_rename_wrong_id(self):
     Cache.clean()
     Cache.add(self.__d, 'd')
     Cache.rename('d2', 'd1')
     self.assertEqual(Cache.get('d1'), None)
     self.assertDictEqual(Cache.get('d'), self.__d)
예제 #9
0
 def test_remove_none(self):
     Cache.clean()
     self.assertEqual(Cache.remove(None), None)
예제 #10
0
 def test_log_level(self):
     Cache.clean()
     level = 40
     Cache.set_log_level(level)
     self.assertEqual(Cache.get_log_level(), level)
예제 #11
0
 def test_copy_non_existent(self):
     Cache.clean()
     id = 'd'
     new_id = 'new_' + id
     Cache.copy(id, new_id)
     self.assertFalse(new_id in Cache.get_list_of_objects())
예제 #12
0
 def test_add_wo_id(self):
     Cache.clean()
     Cache.add(self.__d)
     self.assertEqual(Cache.get('d'), None)
예제 #13
0
 def test_add_with_id(self):
     Cache.clean()
     Cache.add(self.__d, 'd')
     self.assertDictEqual(Cache.get('d'), self.__d)