Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions packit_service/worker/helpers/testing_farm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,7 @@ def _get_tf_base_payload(self, distro: str, compose: Optional[str]) -> dict:
"tmt": {
"context": {
"distro": distro,
"dist-git-branch": self.koji_build.target,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target isn't always equal to branch name. There can be a eln build from the rawhide branch (and other cases, but those shouldn't really be initiated by Packit, so we can ignore them).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, thanks. Will try to find a better approach.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just noticed there is an alternative solution - #2935 . Is this appproach correct?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say so.

"arch": "x86_64",
"trigger": "commit",
"initiator": "fedora-ci",
Expand Down
50 changes: 50 additions & 0 deletions tests/unit/test_testing_farm.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
)
from packit_service.worker.handlers import TestingFarmHandler
from packit_service.worker.handlers import TestingFarmResultsHandler as TFResultsHandler
from packit_service.worker.helpers.testing_farm import (
DownstreamTestingFarmJobHelper,
)
from packit_service.worker.helpers.testing_farm import (
TestingFarmClient as TFClient,
)
Comment on lines +50 to 55
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve readability and adhere to Python's style guidelines (PEP 8), it's better to combine multiple imports from the same module into a single statement.

from packit_service.worker.helpers.testing_farm import (
    DownstreamTestingFarmJobHelper,
    TestingFarmClient as TFClient,
)

Expand Down Expand Up @@ -2348,3 +2351,50 @@ def test_parse_comment_arguments(
assert helper.comment_arguments.identifier == expected_identifier
assert helper.comment_arguments.labels == expected_labels
assert helper.comment_arguments.envs == expected_envs


def test_downstream_tf_base_payload():
"""Test that _get_tf_base_payload returns the correct payload structure."""
service_config = ServiceConfig.get_service_config()
service_config.testing_farm_api_url = "https://api.testing-farm.io/v0.1/"
service_config.testing_farm_secret = "secret-token"

# Create a mock koji_build with a specific target
koji_build = flexmock(
task_id="12345678",
target="rawhide",
)

# Create the helper with minimal required mocks
helper = DownstreamTestingFarmJobHelper(
service_config=service_config,
project=flexmock(repo="test-package"),
metadata=flexmock(
commit_sha="abcd1234",
),
koji_build=koji_build,
)

# Call the method under test
payload = helper._get_tf_base_payload(distro="fedora-rawhide", compose="Fedora-Rawhide")

# Verify the complete payload structure
assert payload["environments"] == [
{
"arch": "x86_64",
"os": {"compose": "Fedora-Rawhide"},
"tmt": {
"context": {
"distro": "fedora-rawhide",
"arch": "x86_64",
"trigger": "commit",
"initiator": "fedora-ci",
"dist-git-branch": "rawhide",
}
},
"artifacts": [
{"id": "12345678", "type": "fedora-koji-build"},
],
"variables": {"KOJI_TASK_ID": "12345678"},
}
]
Loading