1
1
import datetime as dt
2
2
3
3
import pytest
4
+ import pathlib
4
5
from rattler import Version
5
6
6
- from minimum_versions import Policy , Release , Spec
7
+ from minimum_versions import Policy , Release , Spec , _main
7
8
8
9
9
10
@pytest .mark .parametrize (
@@ -27,6 +28,25 @@ def test_spec_parse(text, expected_spec, expected_name, expected_warnings):
27
28
assert actual_warnings == expected_warnings
28
29
29
30
31
+ def test_error_missing_version_or_exclude ():
32
+
33
+
34
+ msg = (
35
+ "No minimum version found for 'package_no_version_not_in_exclude' in"
36
+ " 'failing-env2'. Either add a version or add to the list of excluded packages"
37
+ " in the policy file."
38
+ )
39
+
40
+ with open ("policy.yaml" ) as policy :
41
+
42
+ environment_paths = [pathlib .Path ("envs/failing-env2.yaml" )]
43
+
44
+ with pytest .raises (ValueError , match = msg ):
45
+ _main (dt .date (2023 , 12 , 12 ), policy , environment_paths = environment_paths )
46
+
47
+
48
+
49
+
30
50
@pytest .mark .parametrize (
31
51
["package_name" , "policy" , "today" , "expected" ],
32
52
(
@@ -72,3 +92,5 @@ def test_policy_minimum_version(package_name, policy, today, expected):
72
92
actual = policy .minimum_version (today , package_name , releases [package_name ])
73
93
74
94
assert actual == expected
95
+
96
+
0 commit comments