Skip to content

Commit

Permalink
Fix the get_artefacts_by_family_name function
Browse files Browse the repository at this point in the history
  • Loading branch information
nadzyah committed Jun 15, 2023
1 parent ca8a4d6 commit 61a2a1c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions backend/test_observer/data_access/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def get_artefacts_by_family_name(
Artefact.source,
func.max(Artefact.created_at).label("max_created"),
)
.join(Stage)
.filter(Stage.family.has(Family.name == family_name))
.group_by(Artefact.stage_id, Artefact.name, Artefact.source)
.subquery()
)
Expand Down
3 changes: 1 addition & 2 deletions backend/test_observer/external_apis/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ def get_deb_version(self, debname: str) -> str | None:
pkg_ver = re.search("Version: (.+)", pkg)
if pkg_name and pkg_ver:
# Periods in json keys are bad, convert them to _
pkg_name_key = pkg_name.group(1).replace(".", "_")
json_data[pkg_name_key] = pkg_ver.group(1)
json_data[pkg_name.group(1)] = pkg_ver.group(1)
return json_data.get(debname)

def _create_download_and_extract_filepaths(self) -> None:
Expand Down
5 changes: 3 additions & 2 deletions backend/tests/data_access/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,15 @@ def test_get_artefacts_by_family_name(db_session: Session):


def test_get_artefacts_by_family_name_latest(db_session: Session):
"""We should get a only latest artefacts in each stage"""
"""We should get a only latest artefacts in each stage for the specified family"""
# Arrange
artefact_name_stage_pair = [
("core20", "edge", datetime.utcnow()),
("oem-jammy", "proposed", datetime.utcnow()),
("core20", "edge", datetime.utcnow() - timedelta(days=10)),
("core20", "beta", datetime.utcnow() - timedelta(days=20)),
]
expected_artefacts = {artefact_name_stage_pair[0], artefact_name_stage_pair[2]}
expected_artefacts = {artefact_name_stage_pair[0], artefact_name_stage_pair[-1]}

for name, stage, created_at in artefact_name_stage_pair:
create_artefact(
Expand Down

0 comments on commit 61a2a1c

Please sign in to comment.