From 7361c520eb2d292d15397f7b99f5abb29a29b5ac Mon Sep 17 00:00:00 2001 From: Jakub Kadlcik Date: Mon, 18 Nov 2024 15:05:29 +0100 Subject: [PATCH] frontend: test chroot skipping --- .../tests/test_logic/test_builds_logic.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/frontend/coprs_frontend/tests/test_logic/test_builds_logic.py b/frontend/coprs_frontend/tests/test_logic/test_builds_logic.py index faf46529d..76219418c 100644 --- a/frontend/coprs_frontend/tests/test_logic/test_builds_logic.py +++ b/frontend/coprs_frontend/tests/test_logic/test_builds_logic.py @@ -655,3 +655,43 @@ def save_field(_field, file_path): build = models.Build.query.get(1) assert build.source_state == "succeeded" assert not os.path.exists(storage) + + @pytest.mark.parametrize( + "exclusivearch,states", [ + (["x86_64", "i386"], ["waiting", "waiting"]), + (["x86_64"], ["waiting", "skipped"]), + ([], ["waiting", "waiting"]), + ] + ) + @pytest.mark.usefixtures( + "f_users", "f_coprs", "f_builds", "f_mock_chroots", "f_db") + def test_skipping_chroots(self, exclusivearch, states): + build = BuildsLogic.add(self.u2, "foo", self.c2) + self.db.session.commit() + assert len(build.chroots) == 0 + data = { + "builds": [{ + "id": 5, + "task_id": 5, + "srpm_url": "http://foo", + "status": 1, + "pkg_name": "foo", + "pkg_version": 1, + "chroot": "srpm-builds", + "results": { + "epoch": None, + "excludearch": [], + "exclusivearch": exclusivearch, + "name": "biosdevname", + "release": "17", + "version": "0.7.3" + }, + }] + } + response = self.tc.post( + "/backend/update/", + headers=self.auth_header, + json=data, + ) + assert response.status_code == 200 + assert [x.state for x in build.build_chroots] == states