コード例 #1
0
 def test_given_dot_net_packager_with_bad_zippath_when_upload_then_exception(
         self):
     packager = lambda_code_packager.DotNetCodePackageValidator(
         self.context, self.TEST_FUNCTION_NAME)
     self.assertRaises(errors.HandledError,
                       packager.upload,
                       uploader=self.uploader)
コード例 #2
0
    def test_given_dot_net_packager_wth_valid_zip_when_validate_then_pass(
            self):
        make_os_path_patcher([True])

        packager = lambda_code_packager.DotNetCodePackageValidator(
            self.context, self.TEST_FUNCTION_NAME)
        # Create mock zipfile and override the is_zipfile function
        with mock.patch('resource_manager.lambda_code_packager.zipfile'
                        ) as mock_zipfile:
            mock_zipfile.is_zipfile.return_value = True
            mock_zipfile.namelist.return_value = [
                'Amazon.Lambda.Core.dll', 'TestLambda.deps.json'
            ]

            # Since a ZipFile is a separate object, which returns a zipfile (note
            # that that's lowercase), we need to mock the ZipFile and have it return
            # the zipfile mock previously created.
            with mock.patch(
                    'resource_manager.lambda_code_packager.zipfile.ZipFile'
            ) as mock_ZipFile:
                mock_ZipFile.return_value = mock_zipfile

                self.assertTrue(
                    packager.validate_package(
                        additional_info=self.additional_info))
コード例 #3
0
    def test_given_dot_net_lang_packager_with_invalid_code_path_when_validate_then_fail(
            self):
        make_os_path_patcher([False])

        packager = lambda_code_packager.DotNetCodePackageValidator(
            self.context, self.TEST_FUNCTION_NAME)
        self.assertFalse(
            packager.validate_package(additional_info=self.additional_info))