예제 #1
0
 def setUp(self):
     self.d1 = {"key1": "value1", "key2": "value2"}
     self.path1 = os.path.join(os.path.dirname(__file__), "test1.json")
     self.path2 = os.path.join(os.path.dirname(__file__), "test2.json")
     check_and_remove(self.path1)
     storage.save(self.path1, self.d1)
     check_and_remove(self.path2)
예제 #2
0
 def setUp(self):
     self.d1 = {"key1": "value1", "key2": "value2"}
     self.d2 = {"key3": "value3", "key4": "value4"}
     self.d3 = {"key5": "value5", "key6": "value6"}
     self.d4 = {"key7": "value7", "key8": "value8"}
     self.path1 = os.path.join(os.path.dirname(__file__), "test1.foo.json")
     self.path2 = os.path.join(os.path.dirname(__file__), "test2.foo.json")
     self.path3 = os.path.join(os.path.dirname(__file__), "test3.bar.json")
     self.path4 = os.path.join(os.path.dirname(__file__), "test4.bar.json")
     check_and_remove(self.path1)
     storage.save(self.path1, self.d1)
     check_and_remove(self.path2)
     storage.save(self.path2, self.d2)
     check_and_remove(self.path3)
     storage.save(self.path3, self.d3)
     check_and_remove(self.path4)
     storage.save(self.path4, self.d4)
예제 #3
0
 def test_save_and_load_keeps_data_intact(self):
     storage.save(self.path, self.d1)
     d2 = storage.load(self.path)
     self.assertDictEqual(self.d1, d2)
예제 #4
0
 def test_save_creates_file(self):
     self.assertFalse(os.path.exists(self.path))
     storage.save(self.path, self.d1)
     self.assertTrue(os.path.exists(self.path))
예제 #5
0
 def test_save_object_overwrites_files(self):
     storage.save(self.path, {})
     self.assertTrue(os.path.exists(self.path))
     self.test_save_object()