Skip to content

Commit 2dfd335

Browse files
authored
Merge pull request #5 from opsmill/dga-20240920-sync-stable
Update stable with latest PRs from opsmill/infrahub
2 parents fec58e0 + acbbfb2 commit 2dfd335

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

infrahub_sdk/node.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,12 +725,11 @@ def get_human_friendly_id(self) -> Optional[list[str]]:
725725
if not self._schema.human_friendly_id:
726726
return None
727727

728-
# If all components of an HFID are null, we cannot identify a single node
728+
# If an HFID component is missing we assume that it is invalid and not usable for this node
729729
hfid_components = [self.get_path_value(path=item) for item in self._schema.human_friendly_id]
730-
if all(c is None for c in hfid_components):
730+
if None in hfid_components:
731731
return None
732-
733-
return [str(c) for c in hfid_components]
732+
return [str(hfid) for hfid in hfid_components]
734733

735734
def get_human_friendly_id_as_string(self, include_kind: bool = False) -> Optional[str]:
736735
hfid = self.get_human_friendly_id()

infrahub_sdk/pytest_plugin/plugin.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from pathlib import Path
23
from typing import Optional, Union
34

@@ -34,6 +35,7 @@ def pytest_addoption(parser: Parser) -> None:
3435
action="store",
3536
dest="infrahub_key",
3637
metavar="INFRAHUB_TESTS_API_KEY",
38+
default=os.getenv("INFRAHUB_API_TOKEN"),
3739
help="Key to use when querying the Infrahub instance for live testing",
3840
)
3941
group.addoption(
@@ -74,12 +76,11 @@ def pytest_sessionstart(session: Session) -> None:
7476
"default_branch": session.config.option.infrahub_branch,
7577
}
7678
if hasattr(session.config.option, "infrahub_key"):
77-
client_config = {"api_token": session.config.option.infrahub_key}
79+
client_config["api_token"] = session.config.option.infrahub_key
7880
elif hasattr(session.config.option, "infrahub_username") and hasattr(session.config.option, "infrahub_password"):
79-
client_config = {
80-
"username": session.config.option.infrahub_username,
81-
"password": session.config.option.infrahub_password,
82-
}
81+
client_config.pop("api_token")
82+
client_config["username"] = session.config.option.infrahub_username
83+
client_config["password"] = session.config.option.infrahub_password
8384

8485
infrahub_client = InfrahubClientSync(config=client_config)
8586
session.infrahub_client = infrahub_client # type: ignore[attr-defined]

0 commit comments

Comments
 (0)