| |
@@ -0,0 +1,98 @@
|
| |
+ import copy
|
| |
+ import json
|
| |
+
|
| |
+ import pytest
|
| |
+ import fedora_messaging.api
|
| |
+ import fedora_messaging.config
|
| |
+
|
| |
+ from compose_tracker import Consumer
|
| |
+
|
| |
+
|
| |
+ EXAMPLE_MESSAGE_BODY = json.loads(
|
| |
+ """
|
| |
+ {
|
| |
+ "status": "DOOMED",
|
| |
+ "release_type": "ga",
|
| |
+ "compose_label": null,
|
| |
+ "compose_respin": 0,
|
| |
+ "compose_date": "20190619",
|
| |
+ "release_version": "Rawhide",
|
| |
+ "location": "https://kojipkgs.fedoraproject.org/compose/rawhide/Fedora-Rawhide-20190619.n.0/compose",
|
| |
+ "compose_type": "nightly",
|
| |
+ "release_is_layered": false,
|
| |
+ "release_name": "Fedora",
|
| |
+ "release_short": "Fedora",
|
| |
+ "compose_id": "Fedora-Rawhide-20190619.n.0"
|
| |
+ }
|
| |
+ """
|
| |
+ )
|
| |
+
|
| |
+
|
| |
+ def test_consumer_message_process(mocker, caplog):
|
| |
+ "Test that we can successfully process a message"
|
| |
+ mocker.patch("compose_tracker.PagureService")
|
| |
+ mocker.patch("compose_tracker.requests")
|
| |
+ mocker.patch(
|
| |
+ "compose_tracker.fedora_messaging.config.conf",
|
| |
+ fedora_messaging.config.conf.load_config("compose-tracker.toml"),
|
| |
+ )
|
| |
+ con = Consumer()
|
| |
+ msg = fedora_messaging.api.Message(
|
| |
+ topic="org.fedoraproject.prod.pungi.compose.status.change",
|
| |
+ body=EXAMPLE_MESSAGE_BODY,
|
| |
+ )
|
| |
+ con.process(msg)
|
| |
+ assert "Fedora-Rawhide-20190619.n.0 DOOMED" in caplog.text
|
| |
+
|
| |
+
|
| |
+ def test_consumer_settings_ignore_compose(mocker, caplog):
|
| |
+ "Test that we ignore the composes specified in the settings"
|
| |
+ mocker.patch("compose_tracker.PagureService")
|
| |
+ mocker.patch("compose_tracker.requests")
|
| |
+ mocker.patch(
|
| |
+ "compose_tracker.fedora_messaging.config.conf",
|
| |
+ fedora_messaging.config.conf.load_config("compose-tracker.toml"),
|
| |
+ )
|
| |
+ con = Consumer()
|
| |
+ body = copy.copy(EXAMPLE_MESSAGE_BODY)
|
| |
+ body["compose_id"] = "Fedora-IoT-20190619.n.0"
|
| |
+ msg = fedora_messaging.api.Message(
|
| |
+ topic="org.fedoraproject.prod.pungi.compose.status.change", body=body,
|
| |
+ )
|
| |
+ con.process(msg)
|
| |
+ assert "Skipping filing issues for IoT composes" in caplog.text
|
| |
+
|
| |
+
|
| |
+ def test_consumer_settings_ignore_compose_2_values(mocker, caplog):
|
| |
+ "Test that we ignore the composes specified in the settings with 2 values"
|
| |
+ mocker.patch("compose_tracker.PagureService")
|
| |
+ mocker.patch("compose_tracker.requests")
|
| |
+ mocker.patch(
|
| |
+ "compose_tracker.fedora_messaging.config.conf",
|
| |
+ {"consumer_config": {"composes_to_skip": ["IoT", "Rawhide"]}},
|
| |
+ )
|
| |
+ con = Consumer()
|
| |
+ msg = fedora_messaging.api.Message(
|
| |
+ topic="org.fedoraproject.prod.pungi.compose.status.change",
|
| |
+ body=EXAMPLE_MESSAGE_BODY,
|
| |
+ )
|
| |
+ con.process(msg)
|
| |
+ assert "Skipping filing issues for Rawhide composes" in caplog.text
|
| |
+
|
| |
+
|
| |
+ def test_consumer_ignore_good_composes(mocker, caplog):
|
| |
+ "Test that we ignore the composes that finished correctly"
|
| |
+ mocker.patch("compose_tracker.PagureService")
|
| |
+ mocker.patch("compose_tracker.requests")
|
| |
+ mocker.patch(
|
| |
+ "compose_tracker.fedora_messaging.config.conf",
|
| |
+ fedora_messaging.config.conf.load_config("compose-tracker.toml"),
|
| |
+ )
|
| |
+ con = Consumer()
|
| |
+ body = copy.copy(EXAMPLE_MESSAGE_BODY)
|
| |
+ body["status"] = "FINISHED"
|
| |
+ msg = fedora_messaging.api.Message(
|
| |
+ topic="org.fedoraproject.prod.pungi.compose.status.change", body=body,
|
| |
+ )
|
| |
+ con.process(msg)
|
| |
+ assert "Fedora-Rawhide-20190619.n.0" not in caplog.text
|
| |
This commit uses the fedora-messaging configuration file to configure a
list of composes to skip.
This commit also add unit tests in order to test that feature.
A brief description on how to run the tests was also added to the README file.
Signed-off-by: Clement Verna cverna@tutanota.com