From 630a5beee83bb3ad17fb5b27c653560978596f9c Mon Sep 17 00:00:00 2001 From: Jiri Podivin Date: Fri, 6 Feb 2026 11:15:41 +0100 Subject: [PATCH 1/2] Removing dead code in tests and utils Signed-off-by: Jiri Podivin --- packit_dashboard/utils.py | 29 ------------ tests/tests_requre/__init__.py | 25 ----------- tests/tests_requre/test_requre.py | 73 ------------------------------- tests/unit/test_views.py | 5 --- 4 files changed, 132 deletions(-) delete mode 100644 packit_dashboard/utils.py delete mode 100644 tests/tests_requre/__init__.py delete mode 100644 tests/tests_requre/test_requre.py diff --git a/packit_dashboard/utils.py b/packit_dashboard/utils.py deleted file mode 100644 index 329d34e6..00000000 --- a/packit_dashboard/utils.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright Contributors to the Packit project. -# SPDX-License-Identifier: MIT - -from flask import jsonify, Response as FlaskResponse -from requests import request, Response as RequestsResponse - - -""" Common utility functions used in multiple files in the packit_dashboard package. """ - - -def make_response(url, method="GET", **kwargs) -> FlaskResponse: - """Returns a response from URL - - :param url: API URL to request - :param method: HTTP method - :return: Flask Response - """ - tries = 6 - for i in range(tries): - try: - req_response: RequestsResponse = request(method=method, url=url, **kwargs) - response: FlaskResponse = jsonify(req_response.json()) - except Exception: - if i < tries - 1: - continue - raise - break - - return response diff --git a/tests/tests_requre/__init__.py b/tests/tests_requre/__init__.py deleted file mode 100644 index 0eb57813..00000000 --- a/tests/tests_requre/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright Contributors to the Packit project. -# SPDX-License-Identifier: MIT - -""" -from requre.helpers.requests_response import RequestResponseHandling -from requre.import_system import upgrade_import_system - -dashboard_import_system = ( - upgrade_import_system(debug_file="modules.out") - .log_imports(what="^requests$", who_name=["packit_dashboard"]) - .decorate( - where="^requests$", - what="Session.send", - who_name=["packit_dashboard"], - decorator=RequestResponseHandling.decorator(item_list=[]), - ) -) -""" - -# NOTE: -# To run tests in write mode, delete the test_data folder. -# requre will then run the to-be-tested functions properly -# and store the output from all 'requests' called within the -# function to a yaml file in test_data -# When you run the tests again, it will run them in read mode. diff --git a/tests/tests_requre/test_requre.py b/tests/tests_requre/test_requre.py deleted file mode 100644 index ab78ba37..00000000 --- a/tests/tests_requre/test_requre.py +++ /dev/null @@ -1,73 +0,0 @@ -# Copyright Contributors to the Packit project. -# SPDX-License-Identifier: MIT - -""" - -from requre.storage import PersistentObjectStorage -from requre.utils import StorageMode -from requre import RequreTestCase - -from packit_dashboard.packagewide_utils import return_json -from packit_dashboard.projects.utils import all_from - - -# Can be any json link that supports pagination, not necessarily packit's. -API_URL = "https://stg.packit.dev/api/tasks" - - -class TestUtilsUsingRequre(RequreTestCase): - def setUp(self): - super().setUp() - - if PersistentObjectStorage().mode == StorageMode.write: - # Placeholder for whenever we wanna check if requre is in write/record mode - # Can be used to initialize api keys, etc - pass - - # Other pre-tests setup code - - # NOTE: If you delete tests_data to run requre it in write/record mode, - # you will have to modify the assertions below accordingly - - # It should return a json object from a given url. - - def test_return_json(self): - tasks_list = return_json(API_URL) - # Returns 10 items by default - assert len(tasks_list) == 10 - # Check if its iterable and parsable - assert tasks_list[0]["date_done"] == "2020-03-13T18:55:15.493578" - assert tasks_list[0]["status"] == "SUCCESS" - assert tasks_list[0]["task_id"] == "e16a0972-4003-42de-a6ca-c73e9426d278" - assert tasks_list[9]["date_done"] == "2020-03-13T12:49:44.092613" - assert tasks_list[9]["status"] == "SUCCESS" - assert tasks_list[9]["task_id"] == "c93e97ff-da3d-4d4e-9e6a-6ea9bb2702ca" - - - - # This test was disabled because - # a) right now this function isnt being used anywhere - # b) not sure if it should be used because fetching 1000 entries but displaying - # only 20 seems inefficient - # c) requre wants to recreate this, it would require a example API with paginatiion - # and the example I used previously would now lead to a huge file with - # like a hundred thousand lines - - - # Should return one huge json after combining all pages - def test_all_from(self): - tasks_list = list(all_from(API_URL)) - # if its working properly then length of list will be way greater than 50 - # (35 pages and 50 items per page) - assert len(tasks_list) > 100 - # Check if its iterable and parsable - assert tasks_list[0]["date_done"] == "2020-03-13T18:55:15.493578" - assert tasks_list[0]["status"] == "SUCCESS" - assert tasks_list[0]["task_id"] == "e16a0972-4003-42de-a6ca-c73e9426d278" - # Check some random object thats definitely not on the first page - assert tasks_list[165]["date_done"] == "2020-03-13T15:39:08.924273" - assert tasks_list[165]["status"] == "SUCCESS" - assert tasks_list[165]["task_id"] == "c09dfbda-8dea-4a09-bd17-4a0fd7c292b1" - - -""" diff --git a/tests/unit/test_views.py b/tests/unit/test_views.py index 7ddda6e5..8b65c6cb 100644 --- a/tests/unit/test_views.py +++ b/tests/unit/test_views.py @@ -29,8 +29,3 @@ def _setup_app_context_for_test(): ctx.push() yield # tests will run here ctx.pop() - - -def test_architecture_image(client): - response = client.get("/api/images/architecture.svg") - assert response.status_code == 200 From af314ce043adfd3e88b9fe3745f7263010adc973 Mon Sep 17 00:00:00 2001 From: Jiri Podivin Date: Fri, 6 Feb 2026 11:18:54 +0100 Subject: [PATCH 2/2] Fixing paths in test image dockerfile Signed-off-by: Jiri Podivin --- Dockerfile.tests | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile.tests b/Dockerfile.tests index 89b29a77..5a4e5160 100644 --- a/Dockerfile.tests +++ b/Dockerfile.tests @@ -8,7 +8,7 @@ ENV HOME=/home/packit_dashboard \ RUN dnf install -y ansible COPY ./files /src/files -COPY ./package.json /src +COPY ./frontend/package.json /src COPY ./Makefile /src/Makefile WORKDIR "/src" @@ -18,5 +18,4 @@ RUN ansible-playbook -vv -c local -i localhost, ./files/ansible/recipe-tests.yam && dnf clean all COPY ./packit_dashboard /src/packit_dashboard -COPY ./templates /src/templates COPY ./tests /src/tests