Example #1
0
def test_add_files_to_zip():
    packer = Packer()
    files_paths = [
        os.path.join(os.path.dirname(os.path.abspath(__file__)), "build",
                     "files_list_test", file_name)
        for file_name in ["dependency_1.py", "entrypoint.py"]
    ]
    packer.add_files_to_zip(f"{ZIP_FILE_NAME}.zip", files_paths)
Example #2
0
def test_provision_lambda():
    packer = Packer()
    aws_api = AWSAPI()

    files_paths = [
        os.path.join(os.path.dirname(os.path.abspath(__file__)), "build",
                     "files_list_test", file_name)
        for file_name in ["dependency_1.py", "entrypoint.py"]
    ]
    packer.add_files_to_zip(f"{ZIP_FILE_NAME}.zip", files_paths)
    aws_lambda = AWSLambda({})
    aws_lambda.region = Region.get_region("us-west-2")
    aws_lambda.name = "horey-test-lambda"
    aws_lambda.role = mock_values["lambda:execution_role"]
    aws_lambda.handler = "entrypoint.main"
    aws_lambda.runtime = "python3.8"
    aws_lambda.tags = {"lvl": "tst", "name": "horey-test"}
    aws_lambda.policy = {
        "Version":
        "2012-10-17",
        "Id":
        "default",
        "Statement": [{
            "Sid": aws_lambda.name + "_" + "sid",
            "Effect": "Allow",
            "Principal": {
                "Service": "events.amazonaws.com"
            },
            "Action": "lambda:InvokeFunction",
            "Resource": None,
            "Condition": {
                "ArnLike": {
                    "AWS:SourceArn":
                    mock_values["lambda:policy_events_rule_arn"]
                }
            }
        }]
    }

    aws_api.provision_aws_lambda(aws_lambda, force=True)

    assert aws_lambda.state == "Active"
Example #3
0
def test_zip_venv_site_packages():
    packer = Packer()
    packer.zip_venv_site_packages(ZIP_FILE_NAME, VENV_DIR, "python3.8")
Example #4
0
def test_create_lambda_package():
    packer = Packer()
    packer.create_lambda_package("lambda_name", DEPLOYMENT_DIR,
                                 PACKAGE_SETUP_DIR)
Example #5
0
def test_install_requirements():
    packer = Packer()
    ret = packer.install_requirements(PACKAGE_SETUP_DIR, VENV_DIR)
    print(ret.stdout)
Example #6
0
def test_execute_in_venv():
    packer = Packer()
    ret = packer.execute_in_venv("ls", VENV_DIR)
    print(ret.stdout)
Example #7
0
def test_create_venv():
    packer = Packer()
    packer.create_venv(VENV_DIR)