code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def get_managed_test_resource_outputs(session: Session):
"""Read output of the managed test resource stack for resource names and arns"""
cfn_resource = session.resource("cloudformation", config=DEFAULT_BOTO_CONFIG, region_name="us-east-1")
stack = cfn_resource.Stack(MANAGED_TEST_RESOURCE_STACK_NAME)
ou... | Read output of the managed test resource stack for resource names and arns | get_managed_test_resource_outputs | python | aws/aws-sam-cli | tests/get_testing_resources.py | https://github.com/aws/aws-sam-cli/blob/master/tests/get_testing_resources.py | Apache-2.0 |
def method_to_stack_name(method_name):
"""Method expects method name which can be a full path. Eg: test.integration.test_deploy_command.method_name"""
method_name = method_name.split(".")[-1]
stack_name = f"{method_name.replace('_', '-')}-{CFN_PYTHON_VERSION_SUFFIX}-{uuid4().hex}"
if not stack_name.star... | Method expects method name which can be a full path. Eg: test.integration.test_deploy_command.method_name | method_to_stack_name | python | aws/aws-sam-cli | tests/testing_utils.py | https://github.com/aws/aws-sam-cli/blob/master/tests/testing_utils.py | Apache-2.0 |
def start_persistent_process(
command_list: List[str],
cwd: Optional[str] = None,
) -> Popen:
"""Start a process with parameters that are suitable for persistent execution."""
return Popen(
command_list,
stdout=PIPE,
stderr=subprocess.STDOUT,
stdin=PIPE,
encoding=... | Start a process with parameters that are suitable for persistent execution. | start_persistent_process | python | aws/aws-sam-cli | tests/testing_utils.py | https://github.com/aws/aws-sam-cli/blob/master/tests/testing_utils.py | Apache-2.0 |
def kill_process(process: Popen) -> None:
"""Kills a process and it's children.
This loop ensures orphaned children are killed as well.
https://psutil.readthedocs.io/en/latest/#kill-process-tree
Raises ValueError if some processes are alive"""
root_process = psutil.Process(process.pid)
all_proce... | Kills a process and it's children.
This loop ensures orphaned children are killed as well.
https://psutil.readthedocs.io/en/latest/#kill-process-tree
Raises ValueError if some processes are alive | kill_process | python | aws/aws-sam-cli | tests/testing_utils.py | https://github.com/aws/aws-sam-cli/blob/master/tests/testing_utils.py | Apache-2.0 |
def read_until_string(process: Popen, expected_output: str, timeout: int = 30) -> None:
"""Read output from process until a line equals to expected_output has shown up or reaching timeout.
Throws TimeoutError if times out
"""
def _compare_output(output, _: List[str]) -> bool:
return bool(expect... | Read output from process until a line equals to expected_output has shown up or reaching timeout.
Throws TimeoutError if times out
| read_until_string | python | aws/aws-sam-cli | tests/testing_utils.py | https://github.com/aws/aws-sam-cli/blob/master/tests/testing_utils.py | Apache-2.0 |
def read_until(process: Popen, callback: Callable[[str, List[str]], bool], timeout: int = 5):
"""Read output from process until callback returns True or timeout is reached
Parameters
----------
process : Popen
callback : Callable[[str, List[str]], None]
Call when a new line is read from the... | Read output from process until callback returns True or timeout is reached
Parameters
----------
process : Popen
callback : Callable[[str, List[str]], None]
Call when a new line is read from the process.
timeout : int, optional
By default 5
Raises
------
TimeoutError
... | read_until | python | aws/aws-sam-cli | tests/testing_utils.py | https://github.com/aws/aws-sam-cli/blob/master/tests/testing_utils.py | Apache-2.0 |
def create_file(self, filename, contents, mtime=None, mode="w"):
"""Creates a file in a tmpdir
``filename`` should be a relative path, e.g. "foo/bar/baz.txt"
It will be translated into a full path in a tmp dir.
If the ``mtime`` argument is provided, then the file's
mtime will be ... | Creates a file in a tmpdir
``filename`` should be a relative path, e.g. "foo/bar/baz.txt"
It will be translated into a full path in a tmp dir.
If the ``mtime`` argument is provided, then the file's
mtime will be set to the provided value (must be an epoch time).
Otherwise the mti... | create_file | python | aws/aws-sam-cli | tests/testing_utils.py | https://github.com/aws/aws-sam-cli/blob/master/tests/testing_utils.py | Apache-2.0 |
def append_file(self, filename, contents):
"""Append contents to a file
``filename`` should be a relative path, e.g. "foo/bar/baz.txt"
It will be translated into a full path in a tmp dir.
Returns the full path to the file.
"""
full_path = os.path.join(self.rootdir, filena... | Append contents to a file
``filename`` should be a relative path, e.g. "foo/bar/baz.txt"
It will be translated into a full path in a tmp dir.
Returns the full path to the file.
| append_file | python | aws/aws-sam-cli | tests/testing_utils.py | https://github.com/aws/aws-sam-cli/blob/master/tests/testing_utils.py | Apache-2.0 |
def strip_nightly_installer_suffix(request: dict, metric_type: str):
"""
If it's a nightly release version, it will have a suffix.
We can strip it for the purpose of testing telemetry.
"""
metrics = request.get("data", {}).get("metrics", [])
if not metrics:
return
version = metrics[0... |
If it's a nightly release version, it will have a suffix.
We can strip it for the purpose of testing telemetry.
| strip_nightly_installer_suffix | python | aws/aws-sam-cli | tests/testing_utils.py | https://github.com/aws/aws-sam-cli/blob/master/tests/testing_utils.py | Apache-2.0 |
def _verify_build(self, function_full_paths, layer_full_path, stack_paths, command_result):
"""
Verify resources have their build artifact folders, stack has their own template.yaml, and command succeeds.
"""
self._verify_process_code_and_output(command_result, function_full_paths, layer... |
Verify resources have their build artifact folders, stack has their own template.yaml, and command succeeds.
| _verify_build | python | aws/aws-sam-cli | tests/integration/buildcmd/build_integ_base.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/buildcmd/build_integ_base.py | Apache-2.0 |
def _verify_invoke_built_functions(self, template_path, functions, error_message):
"""
Invoke the function, if error_message is not None, the invoke should fail.
"""
for function_logical_id in functions:
LOG.info("Invoking built function '{}'".format(function_logical_id))
... |
Invoke the function, if error_message is not None, the invoke should fail.
| _verify_invoke_built_functions | python | aws/aws-sam-cli | tests/integration/buildcmd/build_integ_base.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/buildcmd/build_integ_base.py | Apache-2.0 |
def rust_parameterized_class(cls):
"""
common class parameterize for rust integration tests
"""
cls = parameterized_class(
("template", "code_uri", "binary", "expected_invoke_result"),
[
(
"template_build_method_rust_single_function.yaml",
"Rus... |
common class parameterize for rust integration tests
| rust_parameterized_class | python | aws/aws-sam-cli | tests/integration/buildcmd/build_integ_base.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/buildcmd/build_integ_base.py | Apache-2.0 |
def test_dedup_build(self):
"""
Build template above and verify that each function call returns as expected
"""
overrides = {
"Function1Handler": "main.first_function_handler",
"Function2Handler": "main.second_function_handler",
"FunctionRuntime": "3.1... |
Build template above and verify that each function call returns as expected
| test_dedup_build | python | aws/aws-sam-cli | tests/integration/buildcmd/test_build_cmd.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/buildcmd/test_build_cmd.py | Apache-2.0 |
def test_dedup_build_makefile(self):
"""
Build template above in the container and verify that each function call returns as expected
"""
cmdlist = self.get_command_list(beta_features=self.beta_features)
# Built using `native` python-pip builder for a python project.
com... |
Build template above in the container and verify that each function call returns as expected
| test_dedup_build_makefile | python | aws/aws-sam-cli | tests/integration/buildcmd/test_build_cmd.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/buildcmd/test_build_cmd.py | Apache-2.0 |
def test_cached_build_with_env_vars(self):
"""
Build 2 times to verify that second time hits the cached build
"""
overrides = {
"FunctionCodeUri": "Python",
"Function1Handler": "main.first_function_handler",
"Function2Handler": "main.second_function_ha... |
Build 2 times to verify that second time hits the cached build
| test_cached_build_with_env_vars | python | aws/aws-sam-cli | tests/integration/buildcmd/test_build_cmd.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/buildcmd/test_build_cmd.py | Apache-2.0 |
def setUpClass(cls):
"""Setting up a S3 bucket (using pre-created or create a new bucket) to use as a Terraform backend"""
cls.region_name = os.environ.get("AWS_DEFAULT_REGION", "us-east-1")
"""Please read comments in package_integ_base.py for more details around this."""
bucket_env_var... | Setting up a S3 bucket (using pre-created or create a new bucket) to use as a Terraform backend | setUpClass | python | aws/aws-sam-cli | tests/integration/buildcmd/test_build_terraform_applications.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/buildcmd/test_build_terraform_applications.py | Apache-2.0 |
def tearDownClass(cls):
"""Clean up and delete the bucket if it is not pre-created"""
cls.s3_bucket.objects.all().delete()
time.sleep(S3_SLEEP)
if not cls.pre_created_bucket:
cls.s3_bucket.delete() | Clean up and delete the bucket if it is not pre-created | tearDownClass | python | aws/aws-sam-cli | tests/integration/buildcmd/test_build_terraform_applications.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/buildcmd/test_build_terraform_applications.py | Apache-2.0 |
def tearDown(self):
"""Clean up the terraform state file on S3 and remove the backendconfg locally"""
self.s3_bucket.delete_objects(Delete={"Objects": [{"Key": self.backend_key}]})
time.sleep(S3_SLEEP)
try:
Path(self.backendconfig_path).unlink()
except FileNotFoundErr... | Clean up the terraform state file on S3 and remove the backendconfg locally | tearDown | python | aws/aws-sam-cli | tests/integration/buildcmd/test_build_terraform_applications.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/buildcmd/test_build_terraform_applications.py | Apache-2.0 |
def _validate_stack_deleted(self, stack_name: str) -> None:
"""
Validates that the stack is deleted from Cloudformation
Parameters
----------
stack_name: str
The name of the stack to check if it exists in Cloudformation
"""
try:
self.cf_cl... |
Validates that the stack is deleted from Cloudformation
Parameters
----------
stack_name: str
The name of the stack to check if it exists in Cloudformation
| _validate_stack_deleted | python | aws/aws-sam-cli | tests/integration/delete/test_delete_command.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/delete/test_delete_command.py | Apache-2.0 |
def test_deploy_with_code_signing_params(self, should_sign, should_enforce, will_succeed):
"""
Signed function with UntrustedArtifactOnDeployment = Enforced config should succeed
Signed function with UntrustedArtifactOnDeployment = Warn config should succeed
Unsigned function with Untrus... |
Signed function with UntrustedArtifactOnDeployment = Enforced config should succeed
Signed function with UntrustedArtifactOnDeployment = Warn config should succeed
Unsigned function with UntrustedArtifactOnDeployment = Enforce config should fail
Unsigned function with UntrustedArtifactO... | test_deploy_with_code_signing_params | python | aws/aws-sam-cli | tests/integration/deploy/test_deploy_command.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/deploy/test_deploy_command.py | Apache-2.0 |
def _assert_template_with_cfn_lint(self, cwd):
"""Assert if the generated project passes cfn-lint"""
cmd_list = [
get_sam_command(),
"validate",
"--lint",
]
result = run_command(cmd_list, cwd=cwd)
self.assertEqual(result.process.returncode, 0) | Assert if the generated project passes cfn-lint | _assert_template_with_cfn_lint | python | aws/aws-sam-cli | tests/integration/init/test_init_command.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/init/test_init_command.py | Apache-2.0 |
def _create_cred_profile(self, profile_name, access_key, secret_key, session_token=None):
"""
Method to create aws credentials entry similar to ~/.aws/credentials file format.
"""
cred_profile_content = f"""
[{profile_name}]
aws_access_key_id = {access_key}
aws_secret_access_key = {secre... |
Method to create aws credentials entry similar to ~/.aws/credentials file format.
| _create_cred_profile | python | aws/aws-sam-cli | tests/integration/init/schemas/schemas_test_data_setup.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/init/schemas/schemas_test_data_setup.py | Apache-2.0 |
def tearDownClass(cls):
"""Clean up and delete the lambda layers, and bucket if it is not pre-created"""
# delete the created terraform project
if cls.should_apply_first:
apply_command = ["terraform", "destroy", "-auto-approve", "-input=false"]
stdout, _, return_code = c... | Clean up and delete the lambda layers, and bucket if it is not pre-created | tearDownClass | python | aws/aws-sam-cli | tests/integration/local/invoke/test_invoke_terraform_applications.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/invoke/test_invoke_terraform_applications.py | Apache-2.0 |
def test_build_and_invoke_functions(self, function_name):
"""
This method will first build functions (which contains a credentials call)
Then invoke each of them with passing AWS session env variables
"""
# first build application
build_command_list = self.get_build_comma... |
This method will first build functions (which contains a credentials call)
Then invoke each of them with passing AWS session env variables
| test_build_and_invoke_functions | python | aws/aws-sam-cli | tests/integration/local/invoke/test_with_credentials.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/invoke/test_with_credentials.py | Apache-2.0 |
def test_get_call_with_path_setup_with_any_implicit_api_http10(self):
"""
Get Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events
"""
response = requests.get(self.url + "/anyandall", timeout=300)
self.assertEqual(response.status_code, 200)
... |
Get Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events
| test_get_call_with_path_setup_with_any_implicit_api_http10 | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_post_call_with_path_setup_with_any_implicit_api_http10(self):
"""
Post Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events
"""
response = requests.post(self.url + "/anyandall", json={}, timeout=300)
self.assertEqual(response.status_... |
Post Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events
| test_post_call_with_path_setup_with_any_implicit_api_http10 | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_put_call_with_path_setup_with_any_implicit_api_http10(self):
"""
Put Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events
"""
response = requests.put(self.url + "/anyandall", json={}, timeout=300)
self.assertEqual(response.status_cod... |
Put Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events
| test_put_call_with_path_setup_with_any_implicit_api_http10 | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_head_call_with_path_setup_with_any_implicit_api_http10(self):
"""
Head Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events
"""
response = requests.head(self.url + "/anyandall", timeout=300)
self.assertEqual(response.status_code, 200... |
Head Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events
| test_head_call_with_path_setup_with_any_implicit_api_http10 | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_delete_call_with_path_setup_with_any_implicit_api_http10(self):
"""
Delete Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events
"""
response = requests.delete(self.url + "/anyandall", timeout=300)
self.assertEqual(response.status_cod... |
Delete Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events
| test_delete_call_with_path_setup_with_any_implicit_api_http10 | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_options_call_with_path_setup_with_any_implicit_api_http10(self):
"""
Options Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events
"""
response = requests.options(self.url + "/anyandall", timeout=300)
self.assertEqual(response.status_... |
Options Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events
| test_options_call_with_path_setup_with_any_implicit_api_http10 | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_patch_call_with_path_setup_with_any_implicit_api_http10(self):
"""
Patch Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events
"""
response = requests.patch(self.url + "/anyandall", timeout=300)
self.assertEqual(response.status_code, ... |
Patch Request to a path that was defined as ANY in SAM through AWS::Serverless::Function Events
| test_patch_call_with_path_setup_with_any_implicit_api_http10 | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_same_endpoint(self):
"""
Send two requests to the same path at the same time. This is to ensure we can handle
multiple requests at once and do not block/queue up requests
"""
number_of_requests = 10
start_time = time()
with ThreadPoolExecutor(number_of_re... |
Send two requests to the same path at the same time. This is to ensure we can handle
multiple requests at once and do not block/queue up requests
| test_same_endpoint | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_different_endpoints(self):
"""
Send two requests to different paths at the same time. This is to ensure we can handle
multiple requests for different paths and do not block/queue up the requests
"""
number_of_requests = 10
start_time = time()
with ThreadP... |
Send two requests to different paths at the same time. This is to ensure we can handle
multiple requests for different paths and do not block/queue up the requests
| test_different_endpoints | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_get_call_with_path_setup_with_any_swagger(self):
"""
Get Request to a path that was defined as ANY in SAM through Swagger
"""
response = requests.get(self.url + "/anyandall", timeout=300)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json... |
Get Request to a path that was defined as ANY in SAM through Swagger
| test_get_call_with_path_setup_with_any_swagger | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_post_call_with_path_setup_with_any_swagger(self):
"""
Post Request to a path that was defined as ANY in SAM through Swagger
"""
response = requests.post(self.url + "/anyandall", json={}, timeout=300)
self.assertEqual(response.status_code, 200)
self.assertEqual(r... |
Post Request to a path that was defined as ANY in SAM through Swagger
| test_post_call_with_path_setup_with_any_swagger | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_put_call_with_path_setup_with_any_swagger(self):
"""
Put Request to a path that was defined as ANY in SAM through Swagger
"""
response = requests.put(self.url + "/anyandall", json={}, timeout=300)
self.assertEqual(response.status_code, 200)
self.assertEqual(resp... |
Put Request to a path that was defined as ANY in SAM through Swagger
| test_put_call_with_path_setup_with_any_swagger | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_delete_call_with_path_setup_with_any_swagger(self):
"""
Delete Request to a path that was defined as ANY in SAM through Swagger
"""
response = requests.delete(self.url + "/anyandall", timeout=300)
self.assertEqual(response.status_code, 200)
self.assertEqual(resp... |
Delete Request to a path that was defined as ANY in SAM through Swagger
| test_delete_call_with_path_setup_with_any_swagger | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_patch_call_with_path_setup_with_any_swagger(self):
"""
Patch Request to a path that was defined as ANY in SAM through Swagger
"""
response = requests.patch(self.url + "/anyandall", timeout=300)
self.assertEqual(response.status_code, 200)
self.assertEqual(respons... |
Patch Request to a path that was defined as ANY in SAM through Swagger
| test_patch_call_with_path_setup_with_any_swagger | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_binary_request(self):
"""
This tests that the service can accept and invoke a lambda when given binary data in a request
"""
input_data = self.get_binary_data(self.binary_data_file)
response = requests.post(
self.url + "/echobase64eventbody", headers={"Conten... |
This tests that the service can accept and invoke a lambda when given binary data in a request
| test_binary_request | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_default_header_content_type(self):
"""
Test that if no ContentType is given the default is "application/json"
"""
response = requests.get(self.url + "/onlysetstatuscode", timeout=300)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content.... |
Test that if no ContentType is given the default is "application/json"
| test_default_header_content_type | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_default_status_code(self):
"""
Test that if no status_code is given, the status code is 200
:return:
"""
response = requests.get(self.url + "/onlysetbody", timeout=300)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.json(), {"hello... |
Test that if no status_code is given, the status code is 200
:return:
| test_default_status_code | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_default_body(self):
"""
Test that if no body is given, the response is ''
"""
response = requests.get(self.url + "/onlysetstatuscode", timeout=300)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.content.decode("utf-8"), "") |
Test that if no body is given, the response is ''
| test_default_body | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_request_with_form_data(self):
"""
Form-encoded data should be put into the Event to Lambda
"""
response = requests.post(
self.url + "/echoeventbody",
headers={"Content-Type": "application/x-www-form-urlencoded"},
data="key=value",
... |
Form-encoded data should be put into the Event to Lambda
| test_request_with_form_data | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_request_with_query_params(self):
"""
Query params given should be put into the Event to Lambda
"""
response = requests.get(self.url + "/id/4", params={"key": "value"}, timeout=300)
self.assertEqual(response.status_code, 200)
response_data = response.json()
... |
Query params given should be put into the Event to Lambda
| test_request_with_query_params | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_request_with_path_params(self):
"""
Path Parameters given should be put into the Event to Lambda
"""
response = requests.get(self.url + "/id/4", timeout=300)
self.assertEqual(response.status_code, 200)
response_data = response.json()
self.assertEqual(r... |
Path Parameters given should be put into the Event to Lambda
| test_request_with_path_params | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_forward_headers_are_added_to_event(self):
"""
Test the Forwarding Headers exist in the Api Event to Lambda
"""
response = requests.get(self.url + "/id/4", timeout=300)
response_data = response.json()
self.assertEqual(response_data.get("headers").get("X-Forwarde... |
Test the Forwarding Headers exist in the Api Event to Lambda
| test_forward_headers_are_added_to_event | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_cors_swagger_options_httpapi(self):
"""
This tests that the Cors headers are added to OPTIONS responses
"""
response = requests.options(
self.url + "/httpapi-echobase64eventbody", headers={"Origin": "https://abc"}, timeout=300
)
self.assert_cors(respo... |
This tests that the Cors headers are added to OPTIONS responses
| test_cors_swagger_options_httpapi | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_cors_swagger_get_httpapi(self):
"""
This tests that the Cors headers are added to _other_ method requests
"""
response = requests.get(
self.url + "/httpapi-echobase64eventbody", headers={"Origin": "https://abc"}, timeout=300
)
self.assert_cors(respons... |
This tests that the Cors headers are added to _other_ method requests
| test_cors_swagger_get_httpapi | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_cors_complex_post_presence(self):
"""
This tests that the Cors headers are added to POST responses
"""
self.assert_presence(requests.post(self.url, headers={"Origin": "https://abc"}, timeout=300), "https://abc")
self.assert_presence(
requests.post(self.url, h... |
This tests that the Cors headers are added to POST responses
| test_cors_complex_post_presence | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_cors_complex_absence(self):
"""
This tests that the Cors headers are NOT added to responses
when Origin is either unknown or missing
"""
self.assert_absence(requests.options(self.url, headers={"Origin": "https://unknown"}, timeout=300))
self.assert_absence(reques... |
This tests that the Cors headers are NOT added to responses
when Origin is either unknown or missing
| test_cors_complex_absence | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_cors_global(self, origin):
"""
This tests that the Cors headers are added to OPTIONS response when the global property is set
"""
response = requests.options(self.url + "/echobase64eventbody", **_create_request_params(origin))
self.assertEqual(response.status_code, 200)... |
This tests that the Cors headers are added to OPTIONS response when the global property is set
| test_cors_global | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_cors_options(self):
"""
This tests that the Cors headers are added to option requests in the swagger template
"""
response = requests.options(
self.url + "/anypath/anypath", headers={"Origin": "https://example.com"}, timeout=300
)
self.assertEqual(re... |
This tests that the Cors headers are added to option requests in the swagger template
| test_cors_options | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api.py | Apache-2.0 |
def test_cors_swagger_options(self):
"""
This tests that the Cors are added to option requests in the swagger template
"""
response = requests.options(self.url + "/", timeout=300)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers.get("Access-... |
This tests that the Cors are added to option requests in the swagger template
| test_cors_swagger_options | python | aws/aws-sam-cli | tests/integration/local/start_api/test_start_api_cdk_template.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_api/test_start_api_cdk_template.py | Apache-2.0 |
def test_invoke_with_function_timeout(self, use_full_path):
"""
This behavior does not match the actually Lambda Service. For functions that timeout, data returned like the
following:
{"errorMessage":"<timestamp> <request_id> Task timed out after 5.00 seconds"}
For Local Lambda'... |
This behavior does not match the actually Lambda Service. For functions that timeout, data returned like the
following:
{"errorMessage":"<timestamp> <request_id> Task timed out after 5.00 seconds"}
For Local Lambda's, however, timeouts are an interrupt on the thread that runs invokes t... | test_invoke_with_function_timeout | python | aws/aws-sam-cli | tests/integration/local/start_lambda/test_start_lambda.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/local/start_lambda/test_start_lambda.py | Apache-2.0 |
def test_package_with_deep_nested_template_image(self):
"""
this template contains two nested stacks:
- root
- FunctionA
- ChildStackX
- FunctionB
- ChildStackY
- FunctionA
"""
template_file = os.path.join("deep-nested-ima... |
this template contains two nested stacks:
- root
- FunctionA
- ChildStackX
- FunctionB
- ChildStackY
- FunctionA
| test_package_with_deep_nested_template_image | python | aws/aws-sam-cli | tests/integration/package/test_package_command_image.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/package/test_package_command_image.py | Apache-2.0 |
def test_package_with_deep_nested_template(self):
"""
this template contains two nested stacks:
- root
- FunctionA
- ChildStackX
- FunctionB
- ChildStackY
- FunctionA
- MyLayerVersion
"""
template_file = os.p... |
this template contains two nested stacks:
- root
- FunctionA
- ChildStackX
- FunctionB
- ChildStackY
- FunctionA
- MyLayerVersion
| test_package_with_deep_nested_template | python | aws/aws-sam-cli | tests/integration/package/test_package_command_zip.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/package/test_package_command_zip.py | Apache-2.0 |
def test_package_with_stackset(self):
"""
this template contains a stack set:
- root
- FunctionA
- StackSetA
"""
template_file = os.path.join("stackset", "template.yaml")
template_path = self.test_data_path.joinpath(template_file)
command_list... |
this template contains a stack set:
- root
- FunctionA
- StackSetA
| test_package_with_stackset | python | aws/aws-sam-cli | tests/integration/package/test_package_command_zip.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/package/test_package_command_zip.py | Apache-2.0 |
def test_package_with_stackset_in_a_substack(self):
"""
this template contains a stack set:
- root
- ChildStackX
- FunctionA
- StackSetA
"""
template_file = os.path.join("stackset", "nested-template.yaml")
template_path = self.test_data_... |
this template contains a stack set:
- root
- ChildStackX
- FunctionA
- StackSetA
| test_package_with_stackset_in_a_substack | python | aws/aws-sam-cli | tests/integration/package/test_package_command_zip.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/package/test_package_command_zip.py | Apache-2.0 |
def test_interactive_pipeline_user_only_created_once(self):
"""
Create 3 stages, only the first stage resource stack creates
a pipeline user, and the remaining two share the same pipeline user.
"""
stage_configuration_names = []
for suffix in ["1", "2", "3"]:
... |
Create 3 stages, only the first stage resource stack creates
a pipeline user, and the remaining two share the same pipeline user.
| test_interactive_pipeline_user_only_created_once | python | aws/aws-sam-cli | tests/integration/pipeline/test_bootstrap_command.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/pipeline/test_bootstrap_command.py | Apache-2.0 |
def get_kinesis_records(self, shard_id, sequence_number, stream_name):
"""Helper function to get kinesis records using the provided shard_id and sequence_number
Parameters
----------
shard_id: string
Shard Id to fetch the record from
sequence_number: string
... | Helper function to get kinesis records using the provided shard_id and sequence_number
Parameters
----------
shard_id: string
Shard Id to fetch the record from
sequence_number: string
Sequence number to get the record for
stream_name: string
N... | get_kinesis_records | python | aws/aws-sam-cli | tests/integration/remote/invoke/remote_invoke_integ_base.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/remote/invoke/remote_invoke_integ_base.py | Apache-2.0 |
def test_sync_infra_with_java(self, template_file):
"""This will test a case where user will flip ADL flag between sync sessions"""
template_path = str(self.test_data_path.joinpath(template_file))
stack_name = self._method_to_stack_name(self.id())
self.stacks.append({"name": stack_name})... | This will test a case where user will flip ADL flag between sync sessions | test_sync_infra_with_java | python | aws/aws-sam-cli | tests/integration/sync/test_sync_infra.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/sync/test_sync_infra.py | Apache-2.0 |
def run_initial_infra_validation(self) -> None:
"""Runs initial infra validation after deployment is completed"""
self.stack_resources = self._get_stacks(self.stack_name)
lambda_functions = self.stack_resources.get(AWS_LAMBDA_FUNCTION)
for lambda_function in lambda_functions:
... | Runs initial infra validation after deployment is completed | run_initial_infra_validation | python | aws/aws-sam-cli | tests/integration/sync/test_sync_watch.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/sync/test_sync_watch.py | Apache-2.0 |
def test_must_send_experimental_metrics_if_experimental_command(self):
"""
Metrics should be sent if "Disabled via config file but Enabled via Envvar"
"""
# Disable it via configuration file
self.unset_config()
self.set_config(telemetry_enabled=True)
os.environ["S... |
Metrics should be sent if "Disabled via config file but Enabled via Envvar"
| test_must_send_experimental_metrics_if_experimental_command | python | aws/aws-sam-cli | tests/integration/telemetry/test_experimental_metric.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/telemetry/test_experimental_metric.py | Apache-2.0 |
def test_send_installed_metric_on_first_run(self):
"""
On the first run, send the installed metric
"""
self.unset_config()
with TelemetryServer() as server:
# Start the CLI
process = self.run_cmd()
_, stderrdata = process.communicate()
... |
On the first run, send the installed metric
| test_send_installed_metric_on_first_run | python | aws/aws-sam-cli | tests/integration/telemetry/test_installed_metric.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/telemetry/test_installed_metric.py | Apache-2.0 |
def test_must_not_send_installed_metric_when_prompt_is_disabled(self):
"""
If the Telemetry Prompt is not displayed, we must *not* send installed metric, even if Telemetry is enabled.
This happens on all subsequent runs.
"""
# Enable Telemetry. This will skip the Telemetry Promp... |
If the Telemetry Prompt is not displayed, we must *not* send installed metric, even if Telemetry is enabled.
This happens on all subsequent runs.
| test_must_not_send_installed_metric_when_prompt_is_disabled | python | aws/aws-sam-cli | tests/integration/telemetry/test_installed_metric.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/telemetry/test_installed_metric.py | Apache-2.0 |
def test_must_not_send_installed_metric_on_second_run(self):
"""
On first run, send installed metric. On second run, must *not* send installed metric
"""
# Unset config to show the prompt
self.unset_config()
with TelemetryServer() as server:
# First Run
... |
On first run, send installed metric. On second run, must *not* send installed metric
| test_must_not_send_installed_metric_on_second_run | python | aws/aws-sam-cli | tests/integration/telemetry/test_installed_metric.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/telemetry/test_installed_metric.py | Apache-2.0 |
def test_must_prompt_if_config_is_not_set(self):
"""
Must print prompt if Telemetry config is not set.
"""
self.unset_config()
process = self.run_cmd()
_, stderrdata = process.communicate()
# Telemetry prompt should be printed to the terminal
self.assert... |
Must print prompt if Telemetry config is not set.
| test_must_prompt_if_config_is_not_set | python | aws/aws-sam-cli | tests/integration/telemetry/test_prompt.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/telemetry/test_prompt.py | Apache-2.0 |
def test_must_not_prompt_if_config_is_set(self, telemetry_enabled, msg):
"""
If telemetry config is already set, prompt must not be displayed
"""
# Set the telemetry config
self.set_config(telemetry_enabled=telemetry_enabled)
process = self.run_cmd()
stdoutdata,... |
If telemetry config is already set, prompt must not be displayed
| test_must_not_prompt_if_config_is_set | python | aws/aws-sam-cli | tests/integration/telemetry/test_prompt.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/telemetry/test_prompt.py | Apache-2.0 |
def test_prompt_must_not_display_on_second_run(self):
"""
On first run, display the prompt. Do *not* display prompt on subsequent runs.
"""
self.unset_config()
# First Run
process = self.run_cmd()
_, stderrdata = process.communicate()
self.assertIn(EXPECT... |
On first run, display the prompt. Do *not* display prompt on subsequent runs.
| test_prompt_must_not_display_on_second_run | python | aws/aws-sam-cli | tests/integration/telemetry/test_prompt.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/telemetry/test_prompt.py | Apache-2.0 |
def test_must_not_send_metrics_if_disabled_using_envvar(self):
"""
No metrics should be sent if "Enabled via Config file but Disabled via Envvar"
"""
# Enable it via configuration file
self.set_config(telemetry_enabled=True)
with TelemetryServer() as server:
... |
No metrics should be sent if "Enabled via Config file but Disabled via Envvar"
| test_must_not_send_metrics_if_disabled_using_envvar | python | aws/aws-sam-cli | tests/integration/telemetry/test_telemetry_contract.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/telemetry/test_telemetry_contract.py | Apache-2.0 |
def test_must_not_crash_when_offline(self):
"""
Must not crash the process if internet is not available
"""
self.set_config(telemetry_enabled=True)
# DO NOT START Telemetry Server here.
# Try to run the command without it.
# Start the CLI
process = self.... |
Must not crash the process if internet is not available
| test_must_not_crash_when_offline | python | aws/aws-sam-cli | tests/integration/telemetry/test_telemetry_contract.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/telemetry/test_telemetry_contract.py | Apache-2.0 |
def _addMethod(self, effect, verb, resource, conditions):
"""Adds a method to the internal lists of allowed or denied methods. Each object in
the internal list contains a resource ARN and a condition statement. The condition
statement can be null."""
if verb != "*" and not hasattr(HttpVe... | Adds a method to the internal lists of allowed or denied methods. Each object in
the internal list contains a resource ARN and a condition statement. The condition
statement can be null. | _addMethod | python | aws/aws-sam-cli | tests/integration/testdata/start_api/lambda_authorizers/app.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/testdata/start_api/lambda_authorizers/app.py | Apache-2.0 |
def _getEmptyStatement(self, effect):
"""Returns an empty statement object prepopulated with the correct action and the
desired effect."""
statement = {
'Action': 'execute-api:Invoke',
'Effect': effect[:1].upper() + effect[1:].lower(),
'Resource': []
}... | Returns an empty statement object prepopulated with the correct action and the
desired effect. | _getEmptyStatement | python | aws/aws-sam-cli | tests/integration/testdata/start_api/lambda_authorizers/app.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/testdata/start_api/lambda_authorizers/app.py | Apache-2.0 |
def _getStatementForEffect(self, effect, methods):
"""This function loops over an array of objects containing a resourceArn and
conditions statement and generates the array of statements for the policy."""
statements = []
if len(methods) > 0:
statement = self._getEmptyStatem... | This function loops over an array of objects containing a resourceArn and
conditions statement and generates the array of statements for the policy. | _getStatementForEffect | python | aws/aws-sam-cli | tests/integration/testdata/start_api/lambda_authorizers/app.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/testdata/start_api/lambda_authorizers/app.py | Apache-2.0 |
def build(self):
"""Generates the policy document based on the internal lists of allowed and denied
conditions. This will generate a policy with two main statements for the effect:
one statement for Allow and one statement for Deny.
Methods that includes conditions will have their own st... | Generates the policy document based on the internal lists of allowed and denied
conditions. This will generate a policy with two main statements for the effect:
one statement for Allow and one statement for Deny.
Methods that includes conditions will have their own statement in the policy. | build | python | aws/aws-sam-cli | tests/integration/testdata/start_api/lambda_authorizers/app.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/testdata/start_api/lambda_authorizers/app.py | Apache-2.0 |
def lambda_handler(event, context):
"""Sample pure Lambda function that returns a message and a location"""
return {
"statusCode": 200,
"body": json.dumps({
"message": f"{layer_method()+2}",
"message_from_layer": f"{layer_method()}",
"extra_message": np.array... | Sample pure Lambda function that returns a message and a location | lambda_handler | python | aws/aws-sam-cli | tests/integration/testdata/sync/code/after/function/app.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/testdata/sync/code/after/function/app.py | Apache-2.0 |
def lambda_handler(event, context):
"""Sample pure Lambda function that returns a message"""
return {
"statusCode": 200,
"body": json.dumps({
"message": "Hello world!",
}),
} | Sample pure Lambda function that returns a message | lambda_handler | python | aws/aws-sam-cli | tests/integration/testdata/sync/infra/before/Python/function_simple/app.py | https://github.com/aws/aws-sam-cli/blob/master/tests/integration/testdata/sync/infra/before/Python/function_simple/app.py | Apache-2.0 |
def test_cli_base(self):
"""
Just invoke the CLI without any commands and assert that help text was printed
:return:
"""
mock_cfg = Mock()
with patch("samcli.cli.main.GlobalConfig", mock_cfg):
runner = CliRunner()
result = runner.invoke(cli, [])
... |
Just invoke the CLI without any commands and assert that help text was printed
:return:
| test_cli_base | python | aws/aws-sam-cli | tests/unit/cli/test_main.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/cli/test_main.py | Apache-2.0 |
def test_must_return_many_functions_to_build(
self,
ContainerManagerMock,
pathlib_mock,
SamLayerProviderMock,
SamFunctionProviderMock,
get_buildable_stacks_mock,
get_template_data_mock,
):
"""
In this unit test, we also verify
- inlinec... |
In this unit test, we also verify
- inlinecode functions are skipped
- functions with codeuri pointing to a zip file are skipped
- layers without build method are skipped
- layers with codeuri pointing to a zip file are skipped
| test_must_return_many_functions_to_build | python | aws/aws-sam-cli | tests/unit/commands/buildcmd/test_build_context.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/commands/buildcmd/test_build_context.py | Apache-2.0 |
def test_latest_python_fetcher_has_valid_supported_runtimes(self):
"""
Mainly checks if the SUPPORTED_RUNTIMES constant actually has
Python runtime inside of it
"""
result = _get_latest_python_runtime()
self.assertTrue(result, "Python was not found in the SUPPORTED_RUNTIM... |
Mainly checks if the SUPPORTED_RUNTIMES constant actually has
Python runtime inside of it
| test_latest_python_fetcher_has_valid_supported_runtimes | python | aws/aws-sam-cli | tests/unit/commands/init/test_cli.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/commands/init/test_cli.py | Apache-2.0 |
def test_provider_with_multiple_stacks(self, method, func2_api_path, overridden_by_top_level_stack):
"""
Here we test func2 has the same path & method and different path/method
"""
template = {
"Resources": {
"SamFunc1": {
"Type": "AWS::Ser... |
Here we test func2 has the same path & method and different path/method
| test_provider_with_multiple_stacks | python | aws/aws-sam-cli | tests/unit/commands/local/lib/test_sam_api_provider.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/commands/local/lib/test_sam_api_provider.py | Apache-2.0 |
def make_swagger(routes, binary_media_types=None):
"""
Given a list of API configurations named tuples, returns a Swagger document
Parameters
----------
routes : list of samcli.commands.local.agiw.local_agiw_service.Route
binary_media_types : list of str
Returns
-------
dict
... |
Given a list of API configurations named tuples, returns a Swagger document
Parameters
----------
routes : list of samcli.commands.local.agiw.local_agiw_service.Route
binary_media_types : list of str
Returns
-------
dict
Swagger document
| make_swagger | python | aws/aws-sam-cli | tests/unit/commands/local/lib/test_sam_api_provider.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/commands/local/lib/test_sam_api_provider.py | Apache-2.0 |
def test_normalize_resource_path_symlink(self):
"""
template: tmp_dir/some/path/template.yaml
link1 (tmp_dir/symlinks/link1) -> ../some/path/template.yaml
link2 (tmp_dir/symlinks/link1) -> tmp_dir/symlinks/link1
resource_path (tmp_dir/some/path/src), raw path is "src"
The... |
template: tmp_dir/some/path/template.yaml
link1 (tmp_dir/symlinks/link1) -> ../some/path/template.yaml
link2 (tmp_dir/symlinks/link1) -> tmp_dir/symlinks/link1
resource_path (tmp_dir/some/path/src), raw path is "src"
The final expected value is the actual value of resource_path,... | test_normalize_resource_path_symlink | python | aws/aws-sam-cli | tests/unit/commands/local/lib/test_stack_provider.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/commands/local/lib/test_stack_provider.py | Apache-2.0 |
def test_undefined_payload_api_event(self, get_id_sources_mock, mock_lambda_uri):
"""
Tests if the payload version is set to 1.0 if it is not defined for API events
"""
mock_lambda_uri.get_function_name.return_value = "arn"
swagger_doc = {
"swagger": "2.0",
... |
Tests if the payload version is set to 1.0 if it is not defined for API events
| test_undefined_payload_api_event | python | aws/aws-sam-cli | tests/unit/commands/local/lib/swagger/test_parser.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/commands/local/lib/swagger/test_parser.py | Apache-2.0 |
def test_simple_response_override_using_rest_api(self, get_id_sources_mock, mock_lambda_uri):
"""
Tests the the Lambda authorizer's simple response property is set to False
if it is provided in a Swagger 2.0 document.
"""
mock_lambda_uri.get_function_name.return_value = "arn"
... |
Tests the the Lambda authorizer's simple response property is set to False
if it is provided in a Swagger 2.0 document.
| test_simple_response_override_using_rest_api | python | aws/aws-sam-cli | tests/unit/commands/local/lib/swagger/test_parser.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/commands/local/lib/swagger/test_parser.py | Apache-2.0 |
def test_ignore_token_auth_with_empty_id_sources(self, get_id_sources_mock, mock_lambda_uri):
"""
Test if we skip a token authorizer if identity source gathering method returns empty
"""
mock_lambda_uri.get_function_name.return_value = "arn"
get_id_sources_mock.return_value = []
... |
Test if we skip a token authorizer if identity source gathering method returns empty
| test_ignore_token_auth_with_empty_id_sources | python | aws/aws-sam-cli | tests/unit/commands/local/lib/swagger/test_parser.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/commands/local/lib/swagger/test_parser.py | Apache-2.0 |
def only_template_manifest_does_not_exist(args):
"""
Mock every file except the template manifest as its "existence" will
result in errors when it can't actually be read by `InteractiveInitFlow`.
"""
if args == Path("/any/existing/local/path/manifest.yaml"):
... |
Mock every file except the template manifest as its "existence" will
result in errors when it can't actually be read by `InteractiveInitFlow`.
| only_template_manifest_does_not_exist | python | aws/aws-sam-cli | tests/unit/commands/pipeline/init/test_initeractive_init_flow.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/commands/pipeline/init/test_initeractive_init_flow.py | Apache-2.0 |
def samconfig_parameters(cmd_names, config_dir=None, env=None, **kwargs):
"""
ContextManager to write a new SAM Config and remove the file after the contextmanager exists
Parameters
----------
cmd_names : list(str)
Name of the full commnad split as a list: ["generate-event", "s3", "put"]
... |
ContextManager to write a new SAM Config and remove the file after the contextmanager exists
Parameters
----------
cmd_names : list(str)
Name of the full commnad split as a list: ["generate-event", "s3", "put"]
config_dir : str
Path where the SAM config file should be written to. ... | samconfig_parameters | python | aws/aws-sam-cli | tests/unit/commands/samconfig/test_samconfig.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/commands/samconfig/test_samconfig.py | Apache-2.0 |
def assertListSubset(self, l1: Iterable, l2: Union[Iterable, Container], msg=None) -> None:
"""
Assert l2 contains all items in l1.
Just like calling self.assertIn(l1[x], l2) in a loop.
"""
for x in l1:
self.assertIn(x, l2, msg) |
Assert l2 contains all items in l1.
Just like calling self.assertIn(l1[x], l2) in a loop.
| assertListSubset | python | aws/aws-sam-cli | tests/unit/lib/deploy/test_deployer.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/lib/deploy/test_deployer.py | Apache-2.0 |
def test_must_paginate_using_next_token(self):
"""Make three API calls, first two returns a nextToken and last does not."""
token = "token"
expected_params = {"logGroupName": self.log_group_name, "interleaved": True}
expected_params_with_token = {"logGroupName": self.log_group_name, "int... | Make three API calls, first two returns a nextToken and last does not. | test_must_paginate_using_next_token | python | aws/aws-sam-cli | tests/unit/lib/observability/cw_logs/test_cw_log_puller.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/lib/observability/cw_logs/test_cw_log_puller.py | Apache-2.0 |
def test_resource_with_s3_url_dict(self, upload_local_artifacts_mock):
"""
Checks if we properly export from the Resource classc
:return:
"""
self.assertTrue(issubclass(ResourceWithS3UrlDict, Resource))
class MockResource(ResourceWithS3UrlDict):
PROPERTY_NAM... |
Checks if we properly export from the Resource classc
:return:
| test_resource_with_s3_url_dict | python | aws/aws-sam-cli | tests/unit/lib/package/test_artifact_exporter.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/lib/package/test_artifact_exporter.py | Apache-2.0 |
def test_get_current_route_keyerror(self):
"""
When the a HTTP request for given method+path combination is allowed by Flask but not in the list of routes,
something is messed up. Flask should be configured only from the list of routes.
"""
request_mock = Mock()
request_... |
When the a HTTP request for given method+path combination is allowed by Flask but not in the list of routes,
something is messed up. Flask should be configured only from the list of routes.
| test_get_current_route_keyerror | python | aws/aws-sam-cli | tests/unit/local/apigw/test_local_apigw_service.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/local/apigw/test_local_apigw_service.py | Apache-2.0 |
def test_must_create_container_with_required_values(self, mock_resolve_symlinks):
"""
Create a container with only required values. Optional values are not provided
:return:
"""
expected_volumes = {self.host_dir: {"bind": self.working_dir, "mode": "ro,delegated"}}
genera... |
Create a container with only required values. Optional values are not provided
:return:
| test_must_create_container_with_required_values | python | aws/aws-sam-cli | tests/unit/local/docker/test_container.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/local/docker/test_container.py | Apache-2.0 |
def test_must_create_container_including_all_optional_values(self, mock_resolve_symlinks):
"""
Create a container with required and optional values.
:return:
"""
expected_volumes = {
self.host_dir: {"bind": self.working_dir, "mode": "ro,delegated"},
"/som... |
Create a container with required and optional values.
:return:
| test_must_create_container_including_all_optional_values | python | aws/aws-sam-cli | tests/unit/local/docker/test_container.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/local/docker/test_container.py | Apache-2.0 |
def test_must_create_container_translate_volume_path(self, mock_resolve_symlinks, os_mock):
"""
Create a container with required and optional values, with windows style volume mount.
:return:
"""
os_mock.name = "nt"
host_dir = "C:\\Users\\Username\\AppData\\Local\\Temp\\... |
Create a container with required and optional values, with windows style volume mount.
:return:
| test_must_create_container_translate_volume_path | python | aws/aws-sam-cli | tests/unit/local/docker/test_container.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/local/docker/test_container.py | Apache-2.0 |
def test_debug_arg_must_be_split_by_spaces_and_appended_to_bootstrap_based_entrypoint(self, runtime):
"""
Debug args list is appended as arguments to bootstrap-args, which is past the fourth position in the array
"""
expected_debug_args = ["a=b", "c=d", "e=f"]
result, _ = LambdaC... |
Debug args list is appended as arguments to bootstrap-args, which is past the fourth position in the array
| test_debug_arg_must_be_split_by_spaces_and_appended_to_bootstrap_based_entrypoint | python | aws/aws-sam-cli | tests/unit/local/docker/test_lambda_container.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/local/docker/test_lambda_container.py | Apache-2.0 |
def test_with_no_additional_variables(self):
"""
Test assuming user has *not* passed any environment variables. Only AWS variables should be setup
"""
expected = {
"AWS_SAM_LOCAL": "true",
"AWS_LAMBDA_FUNCTION_MEMORY_SIZE": "1024",
"AWS_LAMBDA_FUNCTIO... |
Test assuming user has *not* passed any environment variables. Only AWS variables should be setup
| test_with_no_additional_variables | python | aws/aws-sam-cli | tests/unit/local/lambdafn/test_env_vars.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/local/lambdafn/test_env_vars.py | Apache-2.0 |
def test_with_only_default_values_for_variables(self):
"""
Given only environment variable values, without any shell env values or overridden values
"""
expected = {
"AWS_SAM_LOCAL": "true",
"AWS_LAMBDA_FUNCTION_MEMORY_SIZE": "1024",
"AWS_LAMBDA_FUNCT... |
Given only environment variable values, without any shell env values or overridden values
| test_with_only_default_values_for_variables | python | aws/aws-sam-cli | tests/unit/local/lambdafn/test_env_vars.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/local/lambdafn/test_env_vars.py | Apache-2.0 |
def test_with_shell_env_value(self):
"""
Given values for the variables from shell environment
"""
expected = {
"AWS_SAM_LOCAL": "true",
"AWS_LAMBDA_FUNCTION_MEMORY_SIZE": "1024",
"AWS_LAMBDA_FUNCTION_TIMEOUT": "123",
"AWS_LAMBDA_FUNCTION_... |
Given values for the variables from shell environment
| test_with_shell_env_value | python | aws/aws-sam-cli | tests/unit/local/lambdafn/test_env_vars.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/local/lambdafn/test_env_vars.py | Apache-2.0 |
def test_with_overrides_value(self):
"""
Given values for the variables from user specified overrides
"""
expected = {
"AWS_SAM_LOCAL": "true",
"AWS_LAMBDA_FUNCTION_MEMORY_SIZE": "1024",
"AWS_LAMBDA_FUNCTION_TIMEOUT": "123",
"AWS_LAMBDA_FU... |
Given values for the variables from user specified overrides
| test_with_overrides_value | python | aws/aws-sam-cli | tests/unit/local/lambdafn/test_env_vars.py | https://github.com/aws/aws-sam-cli/blob/master/tests/unit/local/lambdafn/test_env_vars.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.