File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff line change 22import os
33from subprocess import PIPE
44
5+ from packaging .version import parse as parse_version
56from wrapt import decorator
67
78from aws_gate .constants import PLUGIN_INSTALL_PATH , PLUGIN_NAME
@@ -43,9 +44,7 @@ def wrapper(
4344 required_version ,
4445 )
4546
46- if version and int (version .replace ("." , "" )) < int (
47- required_version .replace ("." , "" )
48- ):
47+ if version and parse_version (version ) < parse_version (required_version ):
4948 raise ValueError ("Invalid plugin version: {}" .format (version ))
5049
5150 return wrapped_function (* args , ** kwargs )
Original file line number Diff line number Diff line change 11boto3 ~= 1.15.15
2+ cryptography == 3.1.1
23marshmallow == 3.8.0
4+ packaging == 20.4
35PyYAML >= 5.1 ,< 5.4
46requests == 2.24.0
5- cryptography == 3.1.1
6- wrapt == 1.12.1
77unix-ar == 0.2.1
8+ wrapt == 1.12.1
Original file line number Diff line number Diff line change @@ -41,8 +41,9 @@ def test_function():
4141 test_function ()
4242
4343
44- def test_plugin_version (mocker ):
45- m = mocker .patch ("aws_gate.decorators.execute_plugin" , return_value = "1.1.23.0" )
44+ @pytest .mark .parametrize ("version" , ["1.1.23.0" , "1.2.7.0" ])
45+ def test_plugin_version (mocker , version ):
46+ m = mocker .patch ("aws_gate.decorators.execute_plugin" , return_value = version )
4647
4748 @plugin_version ("1.1.23.0" )
4849 def test_function ():
@@ -52,10 +53,11 @@ def test_function():
5253 assert m .call_args == mocker .call (["--version" ], stdout = PIPE , stderr = PIPE )
5354
5455
55- def test_plugin_version_bad_version (mocker ):
56+ @pytest .mark .parametrize ("version" , ["1.1.25.0" , "1.2.7.0" ])
57+ def test_plugin_version_bad_version (mocker , version ):
5658 mocker .patch ("aws_gate.decorators.execute_plugin" , return_value = "1.1.23.0" )
5759
58- @plugin_version ("1.1.25.0" )
60+ @plugin_version (version )
5961 def test_function ():
6062 return "executed"
6163
You can’t perform that action at this time.
0 commit comments