def test_given_java_packager_with_bad_zippath_when_upload_then_exception( self): packager = lambda_code_packager.JavaCodePackageValidator( self.context, self.TEST_FUNCTION_NAME) self.assertRaises(errors.HandledError, packager.upload, uploader=self.uploader)
def test_given_java_packager_with_zip_without_bad_structure_file_when_validate_then_exception( self): make_os_path_patcher([False, False, True]) # No base jar, snapshot jar but zip packager = lambda_code_packager.JavaCodePackageValidator( 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 = [ 'some_path/fail.jar' ] # All jars need to be in the lib/ folder # 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.assertRaises(errors.HandledError, packager.validate_package, additional_info=self.additional_info)
def test_given_java_packager_wth_valid_snapshot_jar_path_when_validate_then_pass( self): make_os_path_patcher([False, True]) # No base jar, but snapshot jar packager = lambda_code_packager.JavaCodePackageValidator( self.context, self.TEST_FUNCTION_NAME) self.assertTrue( packager.validate_package(additional_info=self.additional_info))
def test_given_java_lang_packager_with_invalid_code_path_when_validate_then_fail( self): make_os_path_patcher([False, False, False]) # No base jar, snapshot jar or zip packager = lambda_code_packager.JavaCodePackageValidator( self.context, self.TEST_FUNCTION_NAME) self.assertFalse( packager.validate_package(additional_info=self.additional_info))