-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
63 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import logging | ||
import os | ||
import platform | ||
from pathlib import Path | ||
|
||
|
@@ -10,19 +9,13 @@ | |
|
||
log = logging.getLogger(__name__) | ||
|
||
BASES = { | ||
"[email protected]": "focal", | ||
"[email protected]": "jammy", | ||
"[email protected]": "noble", | ||
} | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption( | ||
"--base", | ||
type=str.lower, | ||
default="[email protected]", | ||
choices=BASES.keys(), | ||
choices=["[email protected]", "[email protected]", "[email protected]"], | ||
help="Set base for the applications.", | ||
) | ||
|
||
|
@@ -157,18 +150,12 @@ def required_resources(resources: list[Resource], provided_collectors: set) -> l | |
|
||
|
||
@pytest.fixture() | ||
def charm_path(base: str) -> Path: | ||
def charm_path(base: str, architecture: str) -> Path: | ||
"""Fixture to determine the charm path based on the base.""" | ||
env_charm_path = f"CHARM_PATH_{BASES[base].upper()}" | ||
path = os.getenv(env_charm_path) | ||
glob_path = f"hardware-observer_*{base.replace('@', '-')}-{architecture}*.charm" | ||
paths = list(Path(".").glob(glob_path)) | ||
|
||
if not path: | ||
raise EnvironmentError( | ||
f"Environment variable '{env_charm_path}' is not set for base '{base}'." | ||
) | ||
if not Path(path).exists(): | ||
raise FileNotFoundError( | ||
f"The path specified in '{env_charm_path}' ({path}) does not exist." | ||
) | ||
if not paths: | ||
raise FileNotFoundError(f"The path for the charm for {base}-{architecture} is not found.") | ||
|
||
return Path(path) | ||
return paths[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters