예제 #1
0
 def test_parse_malformed(self):
     for json_repr in (
         123,
         'bogus',
         (1, 2, 3),
         {},
         {'steps': (1, 2, 3)},
         {'steps': (('InvalidAction', 'path'),)},
         {'steps': (('CreateDirectory', 'path', 'path2'),)},
     ):
         with self.subTest(json_repr=json_repr):
             with self.assertRaises(ValueError):
                 RenamePlan.from_json_representation(json_repr)
예제 #2
0
    def test_parse_basic(self):
        reconstructed_plan = RenamePlan.from_json_representation(self.RENAME_PLAN_EXAMPLE.json_representation())

        self.assertEqual(
            reconstructed_plan.test_repr(),
            (
                ('CreateDirectory', '/base/dest_dir'),
                ('MoveFile', '/base/src_dir/file1', '/base/dest_dir/file2'),
                ('DeleteEmptyDirectory', '/base/src_dir'),
            )
        )
예제 #3
0
 def test_parse_empty(self):
     reconstructed_plan = RenamePlan.from_json_representation({
         'steps': [],
     })
     self.assertEqual(reconstructed_plan.test_repr(), ())
예제 #4
0
 def _test_load_plan(self, path):
     return RenamePlan.load_from_file(self.resolve_test_path(path))
예제 #5
0
def load_rename_plan_backup():
    try:
        return RenamePlan.load_from_file(get_rename_plan_backup_filename())
    except Exception:
        raise CannotLoadRenamePlanBackupError() from None