From 9cb3d3f7ea4f0896bd7f425eca7bd807d8116b77 Mon Sep 17 00:00:00 2001 From: Yeison Vargas Date: Mon, 25 Mar 2024 21:51:56 -0500 Subject: [PATCH] fix: support pydantic2 by using safety_schemas 0.0.2 (#509) --- setup.cfg | 4 ++-- test_requirements.txt | 4 ++-- tests/test_cli.py | 6 ++---- tests/test_safety.py | 1 + 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/setup.cfg b/setup.cfg index c831f0b..97a7254 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,8 +49,8 @@ install_requires = Authlib>=1.2.0 rich typer - pydantic>=1.10.12,<2.0 - safety_schemas>=0.0.1 + pydantic>=1.10.12 + safety_schemas>=0.0.2 typing-extensions>=4.7.1 [options.entry_points] diff --git a/test_requirements.txt b/test_requirements.txt index 3d5e5b5..f1cc7af 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -16,6 +16,6 @@ marshmallow>=3.15.0; python_version>="3.7" Authlib>=1.2.0 rich typer -pydantic>=1.10.12,<2.0 -safety_schemas>=0.0.1 +pydantic>=1.10.12 +safety_schemas>=0.0.2 typing-extensions>=4.7.1 diff --git a/tests/test_cli.py b/tests/test_cli.py index 8260118..f704824 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -285,11 +285,9 @@ def test_validate_with_policy_file_using_invalid_keyword(self): path = os.path.join(dirname, "test_policy_file", "v3_0", filename) result = self.runner.invoke(cli.cli, ['validate', 'policy_file', '3.0', '--path', path]) cleaned_stdout = click.unstyle(result.stderr) - msg_hint = 'report -> dependency-vulnerabilities -> transitive\n' \ - ' extra fields not permitted (type=value_error.extra)\n' - msg = f'Unable to load the Safety Policy file ("{path}"), this command only supports version 3.0, details: 1 validation error for Config\n{msg_hint}' + msg = f'Unable to load the Safety Policy file ("{path}"), this command only supports version 3.0, details: 1 validation error for Config' - self.assertEqual(msg, cleaned_stdout) + self.assertIn(msg, cleaned_stdout) self.assertEqual(result.exit_code, 1) diff --git a/tests/test_safety.py b/tests/test_safety.py index ba0debc..2826932 100644 --- a/tests/test_safety.py +++ b/tests/test_safety.py @@ -466,6 +466,7 @@ def test_get_announcements_catch_unhandled_http_codes(self, get_used_options): @patch("safety.util.get_used_options") @patch.object(click, 'get_current_context', Mock(command=Mock(name=Mock(return_value='check')))) def test_get_announcements_http_ok(self, get_used_options): + get_used_options.return_value = {} announcements = { "announcements": [{