Open alex-harvey-z3q opened 3 years ago
This could be me but I ran into an edge case where I seem to be required to have placebo statements in my application code.
I have a project structure like this:
▶ find . . ./tests ./tests/test_lambda_function.py ./src ./src/lib ./src/lib/__init__.py ./src/lib/foo.py ./src/lambda_function.py
The call to AWS occurs in src/lib/foo.py.
src/lib/foo.py
I initialise placebo in tests/test_lambda_function.py.
tests/test_lambda_function.py
This did not work until I moved these lines into src/lib/foo.py:
boto3.setup_default_session() session = boto3.DEFAULT_SESSION pill = placebo.attach(session, data_path="tests/fixtures") if "BOTO_RECORD" in os.environ: pill.record() elif "BOTO_PLAYBACK" in os.environ: pill.playback()
The file foo has content in it like:
import boto3 client = boto3.client("route53") def get_policy_instance_id(policy_id: str) -> Union[str, None]: response = client.list_traffic_policy_instances() for policy_instance in response["TrafficPolicyInstances"]: if policy_instance["TrafficPolicyId"] == policy_id: return policy_instance["Id"] return None def create(hosted_zone_id: str, ttl: int, domain_name: str, traffic_policy_id: str, traffic_policy_version: int) -> dict: return client.create_traffic_policy_instance( HostedZoneId=hosted_zone_id, Name=domain_name, TTL=ttl, TrafficPolicyId=traffic_policy_id, TrafficPolicyVersion=traffic_policy_version ) ...
Is this a known issue, or am I doing something wrong?
I guess this is not related to https://github.com/garnaat/placebo/issues/33 ? That one says it was fixed.
This could be me but I ran into an edge case where I seem to be required to have placebo statements in my application code.
I have a project structure like this:
The call to AWS occurs in
src/lib/foo.py
.I initialise placebo in
tests/test_lambda_function.py
.This did not work until I moved these lines into
src/lib/foo.py
:The file foo has content in it like:
Is this a known issue, or am I doing something wrong?