6
6
from unittest import TestCase
7
7
8
8
from aws_lambda_builders .builder import LambdaBuilder
9
- from aws_lambda_builders .exceptions import WorkflowFailedError
9
+ from aws_lambda_builders .exceptions import WorkflowFailedError , MisMatchRuntimeError
10
10
11
11
12
12
class TestPythonPipWorkflow (TestCase ):
@@ -33,6 +33,12 @@ def setUp(self):
33
33
language = self .builder .capability .language ,
34
34
major = sys .version_info .major ,
35
35
minor = sys .version_info .minor )
36
+ self .runtime_mismatch = {
37
+ 'python3.6' : 'python2.7' ,
38
+ 'python3.7' : 'python2.7' ,
39
+ 'python2.7' : 'python3.6'
40
+
41
+ }
36
42
37
43
def tearDown (self ):
38
44
shutil .rmtree (self .artifacts_dir )
@@ -46,6 +52,15 @@ def test_must_build_python_project(self):
46
52
output_files = set (os .listdir (self .artifacts_dir ))
47
53
self .assertEquals (expected_files , output_files )
48
54
55
+ def test_mismatch_runtime_python_project (self ):
56
+ with self .assertRaises (MisMatchRuntimeError ) as mismatch_error :
57
+ self .builder .build (self .source_dir , self .artifacts_dir , self .scratch_dir , self .manifest_path_valid ,
58
+ runtime = self .runtime_mismatch [self .runtime ])
59
+ self .assertEquals (mismatch_error .msg ,
60
+ MisMatchRuntimeError (language = "python" ,
61
+ required_runtime = self .runtime_mismatch [self .runtime ],
62
+ found_runtime = self .runtime ).MESSAGE )
63
+
49
64
def test_runtime_validate_python_project_fail_open_unsupported_runtime (self ):
50
65
with self .assertRaises (WorkflowFailedError ):
51
66
self .builder .build (self .source_dir , self .artifacts_dir , self .scratch_dir , self .manifest_path_valid ,
0 commit comments