def assert_resolved(handler: str, *, expected: str) -> None:
     addr = Address("src/python/project")
     rule_runner.create_file("src/python/project/lambda.py")
     rule_runner.create_file("src/python/project/f2.py")
     field = PythonAwsLambdaHandlerField(handler, address=addr)
     result = rule_runner.request(ResolvedPythonAwsHandler,
                                  [ResolvePythonAwsHandlerRequest(field)])
     assert result.val == expected
Exemple #2
0
 def assert_resolved(handler: str, *, expected: str, is_file: bool) -> None:
     addr = Address("src/python/project")
     rule_runner.write_files(
         {"src/python/project/lambda.py": "", "src/python/project/f2.py": ""}
     )
     field = PythonAwsLambdaHandlerField(handler, addr)
     result = rule_runner.request(
         ResolvedPythonAwsHandler, [ResolvePythonAwsHandlerRequest(field)]
     )
     assert result.val == expected
     assert result.file_name_used == is_file
def test_handler_filespec(handler: str, expected: List[str]) -> None:
    field = PythonAwsLambdaHandlerField(handler,
                                        address=Address("project/dir"))
    assert field.filespec == {"includes": expected}
def test_handler_validation(invalid_handler: str) -> None:
    with pytest.raises(InvalidFieldException):
        PythonAwsLambdaHandlerField(invalid_handler,
                                    address=Address("", target_name="t"))