66from unittest import TestCase
77
88from aws_lambda_builders .builder import LambdaBuilder
9- from aws_lambda_builders .exceptions import WorkflowFailedError
9+ from aws_lambda_builders .exceptions import WorkflowFailedError , MisMatchRuntimeError
1010
1111
1212class TestPythonPipWorkflow (TestCase ):
@@ -33,6 +33,12 @@ def setUp(self):
3333 language = self .builder .capability .language ,
3434 major = sys .version_info .major ,
3535 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+ }
3642
3743 def tearDown (self ):
3844 shutil .rmtree (self .artifacts_dir )
@@ -46,6 +52,15 @@ def test_must_build_python_project(self):
4652 output_files = set (os .listdir (self .artifacts_dir ))
4753 self .assertEquals (expected_files , output_files )
4854
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+
4964 def test_runtime_validate_python_project_fail_open_unsupported_runtime (self ):
5065 with self .assertRaises (WorkflowFailedError ):
5166 self .builder .build (self .source_dir , self .artifacts_dir , self .scratch_dir , self .manifest_path_valid ,
0 commit comments