Skip to content

Commit

Permalink
split out endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
PietroPasotti committed Nov 14, 2024
1 parent e984c35 commit 8f1baf3
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions interface_tester/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def configure(
meta: Optional[Dict[str, Any]] = None,
actions: Optional[Dict[str, Any]] = None,
config: Optional[Dict[str, Any]] = None,
endpoint: Optional[str] = None,
):
"""
Expand All @@ -84,8 +83,6 @@ def configure(
:param meta: charm metadata.yaml contents.
:param actions: charm actions.yaml contents.
:param config: charm config.yaml contents.
:param endpoint: endpoint to test. In case there are multiple
endpoints with the same interface.
:param juju_version: juju version that Scenario will simulate (also sets JUJU_VERSION
envvar at charm runtime.)
"""
Expand All @@ -99,8 +96,6 @@ def configure(
self._config = config
if repo:
self._repo = repo
if endpoint:
self._endpoint = endpoint
if interface_name:
self._interface_name = interface_name
if interface_version is not None:
Expand Down Expand Up @@ -284,13 +279,14 @@ def _yield_tests(
raise RuntimeError(f"this charm does not declare any endpoint using {interface_name}.")

role: RoleLiteral
for role in supported_endpoints:
for role, endpoints in supported_endpoints.items():
logger.debug(f"collecting scenes for {role}")

spec = tests[role]
schema = spec["schema"]
for test in spec["tests"]:
yield test, role, schema
for endpoint in endpoints:
yield test, role, schema, endpoint

def __repr__(self):
return f"""<Interface Tester:
Expand All @@ -301,7 +297,6 @@ def __repr__(self):
\tmeta={self._meta}
\tactions={self._actions}
\tconfig={self._config}
\tendpoint={self._endpoint}
\tinterface_name={self._interface_name}
\tinterface_version={self._interface_version}
\tjuju_version={self._juju_version}
Expand All @@ -317,7 +312,7 @@ def run(self) -> bool:
errors = []
ran_some = False

for test_fn, role, schema in self._yield_tests():
for test_fn, role, schema, endpoint in self._yield_tests():
ctx = _InterfaceTestContext(
role=role,
schema=schema,
Expand All @@ -331,7 +326,7 @@ def run(self) -> bool:
supported_endpoints=self._gather_supported_endpoints(),
test_fn=test_fn,
juju_version=self._juju_version,
endpoint=self._endpoint,
endpoint=endpoint,
)
try:
with tester_context(ctx):
Expand Down

0 comments on commit 8f1baf3

Please sign in to comment.