Exemplo n.º 1
0
 def test_restore_parse_fail(self):
     path = 'test_file'
     with open(path, 'w') as f:
         f.write('test contents')
     with mock.patch('json.loads') as l:
         l.side_effect = Exception('test error')
         with self.assertRaises(DownstreamError) as ex:
             restore(path)
         self.assertEqual(
             str(ex.exception), 'Couldn\'t parse \'{0}\': test error'
             .format(path))
     os.remove(path)
Exemplo n.º 2
0
 def test_restore_parse_fail(self):
     path = 'test_file'
     with open(path, 'w') as f:
         f.write('test contents')
     with mock.patch('json.loads') as l:
         l.side_effect = Exception('test error')
         with self.assertRaises(DownstreamError) as ex:
             restore(path)
         self.assertEqual(
             str(ex.exception),
             'Couldn\'t parse \'{0}\': test error'.format(path))
     os.remove(path)
Exemplo n.º 3
0
 def test_save_restore_parity(self):
     d = {'key': 'value'}
     path = 'test_file'
     save(path, d)
     r = restore(path)
     self.assertEqual(d, r)
     os.remove(path)
Exemplo n.º 4
0
 def test_save_restore_parity(self):
     d = {'key': 'value'}
     path = 'test_file'
     save(path, d)
     r = restore(path)
     self.assertEqual(d, r)
     os.remove(path)
Exemplo n.º 5
0
 def test_save_directory_creation(self):
     d = {'key': 'value'}
     dir = 'testdir'
     path = os.path.join(dir, 'file')
     save(path, d)
     self.assertTrue(os.path.isdir(dir))
     self.assertTrue(os.path.exists(path))
     r = restore(path)
     self.assertEqual(d, r)
     os.remove(path)
     os.rmdir(dir)
Exemplo n.º 6
0
 def test_save_directory_creation(self):
     d = {'key': 'value'}
     dir = 'testdir'
     path = os.path.join(dir, 'file')
     save(path, d)
     self.assertTrue(os.path.isdir(dir))
     self.assertTrue(os.path.exists(path))
     r = restore(path)
     self.assertEqual(d, r)
     os.remove(path)
     os.rmdir(dir)
Exemplo n.º 7
0
 def test_restore_path_doesnt_exist(self):
     path = 'nonexistentpath'
     state = restore(path)
     self.assertEqual(state, dict())
Exemplo n.º 8
0
 def test_restore_path_doesnt_exist(self):
     path = 'nonexistentpath'
     state = restore(path)
     self.assertEqual(state, dict())