Example #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)
Example #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'),
            )
        )
Example #3
0
 def test_parse_empty(self):
     reconstructed_plan = RenamePlan.from_json_representation({
         'steps': [],
     })
     self.assertEqual(reconstructed_plan.test_repr(), ())
 def _test_load_plan(self, path):
     return RenamePlan.load_from_file(self.resolve_test_path(path))
Example #5
0
def load_rename_plan_backup():
    try:
        return RenamePlan.load_from_file(get_rename_plan_backup_filename())
    except Exception:
        raise CannotLoadRenamePlanBackupError() from None