Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename charms.yaml file to interface.yaml #18

Merged
merged 3 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Interface-tester-pytest
# pytest-interface-tester

This repository contains a library meant to facilitate compliance testing of charm relation interfaces.
The problem is best stated as follows:
Expand Down Expand Up @@ -74,7 +74,7 @@ The flow is (from the POV of the spec repo):


## Customizing the fixture's address
You can customize name and location of the fixture, but you will need to include that data when registering your charm with the interface. In `charms.yaml`, you can then specify:
You can customize name and location of the fixture, but you will need to include that data when registering your charm with the interface. In `interface.yaml`, you can then specify:
```yaml
- name: my-charm-name # required
url: https://github.com/foo/my-charm-name # required
Expand Down
19 changes: 10 additions & 9 deletions interface_tester/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
schemas for one, you can execute this file to ascertain that all relevant data is being gathered
correctly.
"""

import dataclasses
import importlib
import inspect
Expand Down Expand Up @@ -61,7 +62,7 @@ def __hash__(self):


class _CharmsDotYamlSpec(TypedDict):
"""Specification of the `charms.yaml` file each interface/version dir should contain."""
"""Specification of the `interface.yaml` file each interface/version dir should contain."""
IronCore864 marked this conversation as resolved.
Show resolved Hide resolved

providers: List[_CharmTestConfig]
requirers: List[_CharmTestConfig]
Expand Down Expand Up @@ -152,19 +153,19 @@ def get_schemas(file: Path) -> Dict[Literal["requirer", "provider"], Type[DataBa


def _gather_charms_for_version(version_dir: Path) -> Optional[_CharmsDotYamlSpec]:
"""Attempt to read the `charms.yaml` for this version sudir.
"""Attempt to read the `interface.yaml` for this version sudir.
IronCore864 marked this conversation as resolved.
Show resolved Hide resolved

On failure, return None.
"""
charms_yaml = version_dir / "charms.yaml"
if not charms_yaml.exists():
interface_yaml = version_dir / "interface.yaml"
if not interface_yaml.exists():
return None

charms = None
try:
charms = yaml.safe_load(charms_yaml.read_text())
charms = yaml.safe_load(interface_yaml.read_text())
except (json.JSONDecodeError, yaml.YAMLError) as e:
logger.error("failed to decode %s: verify that it is valid yaml: %s" % (charms_yaml, e))
logger.error("failed to decode %s: verify that it is valid yaml: %s" % (interface_yaml, e))
except FileNotFoundError as e:
logger.error("not found: %s" % e)
if not charms:
Expand All @@ -175,10 +176,10 @@ def _gather_charms_for_version(version_dir: Path) -> Optional[_CharmsDotYamlSpec

if not isinstance(providers, list) or not isinstance(requirers, list):
raise TypeError(
f"{charms_yaml} file has unexpected providers/requirers spec; "
f"{interface_yaml} file has unexpected providers/requirers spec; "
f"expected two lists of dicts (yaml mappings); "
f"got {type(providers)}/{type(requirers)}. "
f"Invalid charms.yaml format."
f"Invalid interface.yaml format."
)

provider_configs = []
Expand All @@ -190,7 +191,7 @@ def _gather_charms_for_version(version_dir: Path) -> Optional[_CharmsDotYamlSpec
except TypeError:
logger.error(
"failure parsing %s to _CharmTestConfig; invalid charm test "
"configuration in %s/charms.yaml:providers" % (item, version_dir)
"configuration in %s/interface.yaml:providers" % (item, version_dir)
)
continue
destination.append(cfg)
Expand Down
Loading