Skip to content

Commit

Permalink
Remove the compile() statement from regexp_match() (#2606)
Browse files Browse the repository at this point in the history
Remove the `compile()` statement from `regexp_match()`

Related to #2596.
Fixes #2605.

Reviewed-by: Laura Barcziová
Reviewed-by: Maja Massarini
  • Loading branch information
softwarefactory-project-zuul[bot] authored Oct 29, 2024
2 parents 23bc167 + bece79a commit 82b48f8
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 10 deletions.
5 changes: 1 addition & 4 deletions packit_service/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
null,
)
from sqlalchemy.dialects.postgresql import array as psql_array
from sqlalchemy.dialects.postgresql import dialect as psql_dialect
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import (
Session as SQLASession,
Expand Down Expand Up @@ -2512,9 +2511,7 @@ def get_all_successful_or_in_progress_by_nvrs(
session.query(BodhiUpdateTargetModel)
.filter(
BodhiUpdateTargetModel.status.in_(("queued", "retry", "success")),
BodhiUpdateTargetModel.koji_nvrs.regexp_match(regexp).compile(
dialect=psql_dialect(),
),
BodhiUpdateTargetModel.koji_nvrs.regexp_match(regexp),
)
.all(),
)
Expand Down
27 changes: 24 additions & 3 deletions tests_openshift/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class SampleValues:
different_dist_git_branch = "f38"
alias = "FEDORA-123"
bodhi_url = "https://bodhi.fedoraproject.org/FEDORA-123"
sidetag = "f39-build-side-12345"

# anitya
anitya_project_id = 12345
Expand Down Expand Up @@ -199,6 +200,7 @@ def clean_db():
session.query(CoprBuildTargetModel).delete()
session.query(CoprBuildGroupModel).delete()
session.query(KojiBuildTargetModel).delete()
session.query(BodhiUpdateTargetModel).delete()
session.query(SRPMBuildModel).delete()
session.query(SyncReleaseTargetModel).delete()
session.query(SyncReleaseModel).delete()
Expand Down Expand Up @@ -2434,16 +2436,35 @@ def bodhi_update_model(branch_project_event_model):
)
model = BodhiUpdateTargetModel.create(
target=SampleValues.dist_git_branch,
koji_nvr=SampleValues.nvr,
koji_nvrs=SampleValues.nvr,
status="queued",
bodhi_update_group=group,
sidetag=SampleValues.sidetag,
)
model.set_alias(SampleValues.alias)
model.set_web_url(SampleValues.bodhi_url)
model.set_status("error")
yield model


@pytest.fixture()
def successful_bodhi_update_model(branch_project_event_model):
group = BodhiUpdateGroupModel.create(
run_model=PipelineModel.create(project_event=branch_project_event_model),
)
model = BodhiUpdateTargetModel.create(
target=SampleValues.dist_git_branch,
koji_nvrs=SampleValues.nvr,
status="queued",
bodhi_update_group=group,
sidetag=SampleValues.sidetag,
)
model.set_alias(SampleValues.alias)
model.set_web_url(SampleValues.bodhi_url)
model.set_status("success")
yield model


@pytest.fixture()
def multiple_bodhi_update_runs(branch_project_event_model):
group = BodhiUpdateGroupModel.create(
Expand All @@ -2452,13 +2473,13 @@ def multiple_bodhi_update_runs(branch_project_event_model):
yield [
BodhiUpdateTargetModel.create(
target=SampleValues.dist_git_branch,
koji_nvr=SampleValues.nvr,
koji_nvrs=SampleValues.nvr,
status="queued",
bodhi_update_group=group,
),
BodhiUpdateTargetModel.create(
target=SampleValues.different_dist_git_branch,
koji_nvr=SampleValues.different_nvr,
koji_nvrs=SampleValues.different_nvr,
status="queued",
bodhi_update_group=group,
),
Expand Down
19 changes: 19 additions & 0 deletions tests_openshift/database/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from sqlalchemy.exc import IntegrityError, ProgrammingError

from packit_service.models import (
BodhiUpdateTargetModel,
BuildStatus,
CoprBuildGroupModel,
CoprBuildTargetModel,
Expand Down Expand Up @@ -1145,3 +1146,21 @@ def test_add_scan_to_copr_build(clean_before_and_after, a_copr_build_for_pr):
a_copr_build_for_pr.add_scan(123)
scan = OSHScanModel.get_by_task_id(123)
assert scan.task_id == 123


def test_bodhi_model_get_last_successful_by_sidetag(
clean_before_and_after, successful_bodhi_update_model
):
assert successful_bodhi_update_model.id

model = BodhiUpdateTargetModel.get_last_successful_by_sidetag(SampleValues.sidetag)
assert model.id == successful_bodhi_update_model.id


def test_bodhi_model_get_all_successful_or_in_progress_by_nvrs(
clean_before_and_after, successful_bodhi_update_model
):
assert successful_bodhi_update_model.id

[model] = BodhiUpdateTargetModel.get_all_successful_or_in_progress_by_nvrs(SampleValues.nvr)
assert model.id == successful_bodhi_update_model.id
6 changes: 3 additions & 3 deletions tests_openshift/service/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,11 +929,11 @@ def test_bodhi_update_list(

response_dict.reverse()
assert response_dict[0]["status"] == "queued"
assert response_dict[0]["koji_nvr"] == SampleValues.nvr
assert response_dict[0]["koji_nvrs"] == SampleValues.nvr
assert response_dict[0]["branch"] == SampleValues.dist_git_branch
assert response_dict[0]["branch_name"] == SampleValues.branch

assert response_dict[1]["koji_nvr"] == SampleValues.different_nvr
assert response_dict[1]["koji_nvrs"] == SampleValues.different_nvr
assert response_dict[1]["branch"] == SampleValues.different_dist_git_branch

assert response_dict[0]["repo_namespace"] == SampleValues.repo_namespace
Expand All @@ -953,7 +953,7 @@ def test_bodhi_update_info(
assert response_dict["alias"] == SampleValues.alias
assert response_dict["branch"] == SampleValues.dist_git_branch
assert response_dict["web_url"] == SampleValues.bodhi_url
assert response_dict["koji_nvr"] == SampleValues.nvr
assert response_dict["koji_nvrs"] == SampleValues.nvr
assert response_dict["branch_name"] == SampleValues.branch
assert response_dict["repo_name"] == SampleValues.repo_name
assert response_dict["repo_namespace"] == SampleValues.repo_namespace
Expand Down

0 comments on commit 82b48f8

Please sign in to comment.