diff --git a/tests/standalone_plugins/test_deprecate_vts.py b/tests/standalone_plugins/test_deprecate_vts.py index 1e5715c7..66709f55 100644 --- a/tests/standalone_plugins/test_deprecate_vts.py +++ b/tests/standalone_plugins/test_deprecate_vts.py @@ -4,88 +4,90 @@ # pylint: disable=protected-access import unittest from pathlib import Path -from tests.plugins import TemporaryDirectory +from tests.plugins import TemporaryDirectory from troubadix.standalone_plugins.deprecate_vts import ( - deprecate, - parse_args, DeprecatedFile, - _get_summary, _finalize_content, - update_summary, - get_files_from_path, + _get_summary, + deprecate, filter_files, + get_files_from_path, + parse_args, + update_summary, ) class ParseArgsTestCase(unittest.TestCase): def test_parse_args(self): testfile = "testfile.nasl" - output_path = "attic/" - reason = "NOTUS" - - args = parse_args( - [ - "--files", - testfile, - "--output-path", - output_path, - "--deprecation-reason", - reason, - ] - ) - self.assertEqual(args.files, [Path(testfile)]) - self.assertEqual(args.output_path, Path(output_path)) - self.assertEqual(args.deprecation_reason, reason) - - def test_mandatory_arg_group_both(self): - testfile = "testfile.nasl" - output_path = "attic/" - input_path = "nasl/common" reason = "NOTUS" - with self.assertRaises(SystemExit): - parse_args( + with TemporaryDirectory() as out_dir: + args = parse_args( [ "--files", testfile, "--output-path", - output_path, - "--input-path", - input_path, + str(out_dir), "--deprecation-reason", reason, ] ) + self.assertEqual(args.files, [Path(testfile)]) + self.assertEqual(args.output_path, out_dir) + self.assertEqual(args.deprecation_reason, reason) + + def test_mandatory_arg_group_both(self): + testfile = "testfile.nasl" + reason = "NOTUS" + + with ( + TemporaryDirectory() as out_dir, + TemporaryDirectory() as in_dir, + ): + with self.assertRaises(SystemExit): + parse_args( + [ + "--files", + testfile, + "--input-path", + str(in_dir), + "--deprecation-reason", + reason, + "--output-path", + str(out_dir), + ] + ) def test_invalid_reason(self): - output_path = "attic/" - input_path = "nasl/common" reason = "foo" - with self.assertRaises(SystemExit): - parse_args( - [ - "--output-path", - output_path, - "--input-path", - input_path, - "--deprecation-reason", - reason, - ] - ) + + with TemporaryDirectory() as out_dir, TemporaryDirectory() as in_dir: + with self.assertRaises(SystemExit): + parse_args( + [ + "--output-path", + str(out_dir), + "--input-path", + str(in_dir), + "--deprecation-reason", + reason, + ] + ) def test_mandatory_arg_group_neither(self): - output_path = "attic/" reason = "NOTUS" - with self.assertRaises(SystemExit): - parse_args( - [ - "--output-path", - output_path, - "--deprecation-reason", - reason, - ] - ) + with TemporaryDirectory() as out_dir: + with self.assertRaises(SystemExit): + parse_args( + [ + "--output-path", + str(out_dir), + "--deprecation-reason", + reason, + ] + ) NASL_CONTENT = (