Skip to content

Commit 18dadc8

Browse files
committed
refactor: setup infra fixture
1 parent feaa491 commit 18dadc8

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

tests/e2e/metrics/conftest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import pytest
2+
3+
from tests.e2e.metrics.infrastructure import MetricsStack
4+
5+
6+
@pytest.fixture(autouse=True)
7+
def setup_infra():
8+
try:
9+
stack = MetricsStack()
10+
yield stack.deploy()
11+
finally:
12+
stack.delete()

tests/e2e/metrics/infrastructure.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ def deploy(self) -> Dict[str, str]:
6161
assets.upload()
6262
return self._deploy_stack(self.stack_name, template)
6363

64+
def delete(self):
65+
self.cf_client.delete_stack(StackName=self.stack_name)
66+
6467
def _synthesize(self) -> Tuple[Dict, Path]:
6568
self.create_functions()
6669
cloud_assembly = self.app.synth()
@@ -84,7 +87,3 @@ def _deploy_stack(self, stack_name: str, template: Dict) -> Dict[str, str]:
8487
stack_details = self.cf_client.describe_stacks(StackName=stack_name)
8588
stack_outputs = stack_details["Stacks"][0]["Outputs"]
8689
return {output["OutputKey"]: output["OutputValue"] for output in stack_outputs if output["OutputKey"]}
87-
88-
89-
metrics = MetricsStack()
90-
metrics.deploy()

0 commit comments

Comments
 (0)