Best Python code snippet using lisa_python
test_local_lambda.py
Source:test_local_lambda.py  
...134        expected = {}135        actual = self.local_lambda.get_aws_creds()136        self.assertEquals(expected, actual)137        boto3_mock.session.Session.assert_called_with(profile_name=self.aws_profile, region_name=self.aws_region)138class TestLocalLambda_get_code_path(TestCase):139    def setUp(self):140        self.runtime_mock = Mock()141        self.function_provider_mock = Mock()142        self.cwd = "/my/current/working/directory"143        self.env_vars_values = {}144        self.debug_context = None145        self.aws_profile = "myprofile"146        self.aws_region = "region"147        self.relative_codeuri = "./my/path"148        self.absolute_codeuri = "/home/foo/bar"  # Some absolute path to use149        self.os_cwd = os.getcwd()150        self.local_lambda = LocalLambdaRunner(self.runtime_mock,151                                              self.function_provider_mock,152                                              self.cwd,153                                              env_vars_values=self.env_vars_values,154                                              aws_profile=self.aws_profile,155                                              debug_context=self.debug_context,156                                              aws_region=self.aws_region)157    @parameterized.expand([158        ("."),159        ("")160    ])161    def test_must_resolve_present_cwd(self, cwd_path):162        self.local_lambda.cwd = cwd_path163        codeuri = self.relative_codeuri164        expected = os.path.normpath(os.path.join(self.os_cwd, codeuri))165        actual = self.local_lambda._get_code_path(codeuri)166        self.assertEquals(expected, actual)167        self.assertTrue(os.path.isabs(actual), "Result must be an absolute path")168    @parameterized.expand([169        ("var/task"),170        ("some/dir")171    ])172    def test_must_resolve_relative_cwd(self, cwd_path):173        self.local_lambda.cwd = cwd_path174        codeuri = self.relative_codeuri175        abs_cwd = os.path.abspath(cwd_path)176        expected = os.path.normpath(os.path.join(abs_cwd, codeuri))177        actual = self.local_lambda._get_code_path(codeuri)178        self.assertEquals(expected, actual)179        self.assertTrue(os.path.isabs(actual), "Result must be an absolute path")180    @parameterized.expand([181        (""),182        ("."),183        ("hello"),184        ("a/b/c/d"),185        ("../../c/d/e")186    ])187    def test_must_resolve_relative_codeuri(self, codeuri):188        expected = os.path.normpath(os.path.join(self.cwd, codeuri))189        actual = self.local_lambda._get_code_path(codeuri)190        self.assertEquals(expected, actual)191        self.assertTrue(os.path.isabs(actual), "Result must be an absolute path")192    @parameterized.expand([193        ("/a/b/c"),194        ("/")195    ])196    def test_must_resolve_absolute_codeuri(self, codeuri):197        expected = codeuri  # CodeUri must be return as is for absolute paths198        actual = self.local_lambda._get_code_path(codeuri)199        self.assertEquals(expected, actual)200        self.assertTrue(os.path.isabs(actual), "Result must be an absolute path")201class TestLocalLambda_make_env_vars(TestCase):202    def setUp(self):203        self.runtime_mock = Mock()204        self.function_provider_mock = Mock()205        self.cwd = "/my/current/working/directory"206        self.debug_context = None207        self.aws_profile = "myprofile"208        self.aws_region = "region"209        self.env_vars_values = {}210        self.environ = {211            "Variables": {212                "var1": "value1",...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
