From patchwork Sun Oct 18 01:43:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Orling X-Patchwork-Id: 101158 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85D53CCF2C4 for ; Sun, 18 Oct 2026 01:45:46 +0000 (UTC) Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.7817.1792287939520625106 for ; Sat, 17 Oct 2026 18:45:39 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=cuBKoJe3; spf=pass (domain: gmail.com, ip: 209.85.214.171, mailfrom: ticotimo@gmail.com) Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2e9d7791b00so510325ad.0 for ; Sat, 17 Oct 2026 18:45:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792287939; x=1792892739; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=V0r5m4fMMokRuOowxLJ+PtuDJMMZd0xIgAOQ/+ls8rw=; b=cuBKoJe32senmmEbnLEuCui1Os+87eQfglW+R7tyBL0MiNmpQWmIWGL/a7VJNQ1E3/ d14/akSq22AwdWBqvJd/xH9sqg4S0K3Jl2U2LHLwhZMKjLzrid4v4faK/lV58XjviGeP Ey7P61i8cVueCSsmPB4NoAVx8oATM6RPCYzmFoXvZDBd2YXJAQmkU8xtmoG79mvNWq/3 N0wV8pDaUf+Ym2bFyabC6ZRvKDyJNr6NdjzqCQdSO7rNxaD9FHdNqpTSniz7V9Bfb+HJ POSWeHMdlnlfrnuI8lOMmbjzULbe1xmV+LV0gKIBUIXuicArApjLVBBHzo5PnRVyQ6AL X9QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792287939; x=1792892739; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=V0r5m4fMMokRuOowxLJ+PtuDJMMZd0xIgAOQ/+ls8rw=; b=ZduI+dDa1tr3iS73YwOuKaYS32mo5HmGqT7RoIrodYoUwZKryf7LWmqJ7/jt95UpdK jgatIZO1nWQvtPhiasISsVJtAbLyeRM9uFGFLMRw3qb5QlHBCU53/WqXE9YpPUJ/6v3N H4HCpcPonf/uQ0bd1MHKqtyVUYiNECQGXJyepZnT/8JdnmE0iI30lKF0BqmlQVBBAwUB YdxdpMXRGdn9XaDo13bUr7M1xzZVvBlly6pqVuWv1Sbcx3BS2iOwpACX8wJjRKKpTDlh w59YgCqau+eYNCjqZqrnlukim8AS25eZpF+ZUB3/PH9Q4+HO8OoeNyFdB8lYxhHbr7s+ h/yQ== X-Gm-Message-State: AFq9FYKBCb+nZlY/wP7vgxE+Imi/uXiDitT7BgPC/4Z5WvUsPTRc4CL9 XJzvCQiyqzb871NK16gUWP+0Yk9HJd/ru5HCZC32vZj/L0ukBNfZC37tqKvZsw== X-Gm-Gg: AYBFou2YhWKkPNt6agw0OeRgTS4LRk8FwXJCzFNQKpuXAy4wTjPlJ+YvlxP+4XYROm1 gV09+PwiHMLCq2cztp9lw6WPdk+mL7BmfaavmA2OhXKSXflqYnfNFqd+xqKH/7mMefuql7sXmYT lHBTDTS8in4hTa8quFGOsWjlqbuUHFl42pssoc8c3glb3wFrhNZPdJ8xTeiWNrYQvb2rNl9U0HP 6qB0e0E32n/ublyjvtbit0StPcpEuYEKWKKG75z6egKgRGM7GwreLe9L+mn/fooLLi/BkLrxOpb 0X+LYJGcbpes7sqcMlVigOvorbxYdKQ0iv43TjP70NYLzYf7TUYA+whBSXoh4+QjYTzKtDEe9rY +MPsYiuEqFbaOiiVR+6eeMUpjlSLNLGTFt8HTa83HaATZW5qKb5NIdap44pnUhVVJZN/KHYAy5e QbuYgUZR/mkQZgCCGXOfJbO5JZlcaKB2jR2U852FXId0H1RP5M3a90p/Zqf8V/9yLPDw6zRaHuu nadFJT1rwR4C0C3L4OPP8RyxLM38vEKzq9Do3j2+w== X-Received: by 2002:a17:902:e5cf:b0:2e7:8d:89bd with SMTP id d9443c01a7336-2e9a73557edmr33309325ad.73.1792287938893; Sat, 17 Oct 2026 18:45:38 -0700 (PDT) Received: from localhost.localdomain ([69.9.132.159]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2e97e87836bsm25935655ad.47.2026.10.17.18.45.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 17 Oct 2026 18:45:38 -0700 (PDT) From: Tim Orling X-Google-Original-From: Tim Orling To: yocto-patches@lists.yoctoproject.org Cc: Tim Orling Subject: [error-report-web][PATCH 1/5] Use django.test.TestCase so tests run against a test database. Date: Sat, 17 Oct 2026 18:43:56 -0700 Message-ID: <20261018014510.72203-3-tim.orling@konsulko.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261018014510.72203-1-tim.orling@konsulko.com> References: <20261018014510.72203-1-tim.orling@konsulko.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sun, 18 Oct 2026 01:45:46 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/5045 unittest.TestCase gets no test database, so the tests used the configured one and failed against a fresh database. Also allow CSPTest's "testhost" in ALLOWED_HOSTS. AI-Generated: Claude Opus 5.5 Signed-off-by: Tim Orling --- Post/test.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Post/test.py b/Post/test.py index 6afb0a6..734b99c 100755 --- a/Post/test.py +++ b/Post/test.py @@ -1,8 +1,7 @@ -import unittest import urllib.request, urllib.parse, urllib.error import json import re -from django.test import Client, override_settings +from django.test import Client, TestCase, override_settings from Post.models import BuildFailure, Build from Post.validators import clean_link_back @@ -64,7 +63,7 @@ def compare_db_obj_with_payload(self, bf_object): f.close() -class SimpleTest(unittest.TestCase): +class SimpleTest(TestCase): def setUp(self): # The test clients submit with HTTP_HOST="testhost", so allow it here # instead of hardcoding a test host into the project settings. @@ -248,7 +247,8 @@ class SimpleTest(unittest.TestCase): response = self.client.get("/Errors/Details/9898989898/") self.assertEqual(response.status_code, 200) -class CSPTest(unittest.TestCase): +@override_settings(ALLOWED_HOSTS=["testhost"]) +class CSPTest(TestCase): def setUp(self): self.client = Client(HTTP_HOST="testhost") @@ -307,7 +307,7 @@ class CSPTest(unittest.TestCase): Build.objects.all().delete() -class LinkBackValidatorTest(unittest.TestCase): +class LinkBackValidatorTest(TestCase): def test_allows_http(self): self.assertEqual(clean_link_back("http://example.com/build/1"), @@ -350,7 +350,7 @@ class LinkBackValidatorTest(unittest.TestCase): self.assertIsNone(clean_link_back(123)) -class LinkBackSubmissionTest(unittest.TestCase): +class LinkBackSubmissionTest(TestCase): def setUp(self): # The test client submits with HTTP_HOST="testhost"; allow it here. @@ -358,9 +358,6 @@ class LinkBackSubmissionTest(unittest.TestCase): override.enable() self.addCleanup(override.disable) self.client = Client(HTTP_HOST="testhost") - # Start from a clean slate; other unittest.TestCase tests commit rows. - Build.objects.all().delete() - BuildFailure.objects.all().delete() with open("test-data/test-payload.json") as f: self.base_payload = json.loads(f.read()) From patchwork Sun Oct 18 01:43:58 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Orling X-Patchwork-Id: 101159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 840FECCF2C7 for ; Sun, 18 Oct 2026 01:46:16 +0000 (UTC) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.7822.1792287968826022476 for ; Sat, 17 Oct 2026 18:46:08 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=AR/IQvuS; spf=pass (domain: gmail.com, ip: 209.85.214.178, mailfrom: ticotimo@gmail.com) Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2dd76b1361dso4516565ad.1 for ; Sat, 17 Oct 2026 18:46:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792287968; x=1792892768; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=XiJGn5apn5u4JMa0QLznlKt0ZItDuecqbsRsua8szQE=; b=AR/IQvuSMPWqKufgao5dxhL4QFQAYw/j5hr8jNxRYEZffe5OISt7UnAx6vOVNGBdE9 JxEksLnheOwC0LP0whoByF0HsW1zKRZQtO9Z52MObI/jcvKb88g9k6quZrVb09AItryo UPKB65bURzaofrcCxg+D3LVqjPfgUCXjllpyw/H0Vv+DHRIu6YsG9Nq8BFhSvmcroRuq S8ePyCTZFN6cU5J+5lWOiYjgIfQ3VHpSCXx8waZrYKYfVs06e+91/ulUm516GHqo3oz+ blmkotrEMrwDtVQcqTOfFRVtvxWNldDeZckq7RJHvpf9MxvXfGPYgUhkyk/zi2emzYgH vO5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792287968; x=1792892768; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=XiJGn5apn5u4JMa0QLznlKt0ZItDuecqbsRsua8szQE=; b=2V46rwBlNgAVLOpwgWDQFsNUFXZdYfhDFnjZDhMtjnafXNg3dSYZPJam5HOfF9R4mZ arFkb8uE1wJ0vnVnwABXus1xRWl/4Z/tr7q5fY6PpwPQmSR9zTRofT43GYe80sTZ3huA rYNHIqDbo6vK8l0xg4sy5eO9fDCg+xJT5WeZiR8irMszjKwoN9Oozpb2H9zvxSSxs3oq S78C63b6fs/Pv2PlwNJt4/NL2Angumjw92Mnolg4BDz7qaYKCIkJn6/LiCeDv4swgJqV 2V7Inax/FEZJBdoi3OZ0HL7HeXfCyLTihuaV2U4sz2n+VojY74G9ZEQEsTiugqY3E4yb Itzg== X-Gm-Message-State: AFq9FYJtvonwygIakjckpZBuPRVwljlZLN+JyeQk6CGoH/Jq5P0fYfSJ DRT9cEyqgYjP6wudivlpXpYHmb6uBM5yXkLWXBPruVzddVcWFoOLH7xo8hAzFQ== X-Gm-Gg: AYBFou2FxVnQMdlnF55KR65p9MUA5qIzOeUg1Qd2IF2NvaRaH77XR2Gmn9D2PTRNOd2 o4k6LKlrEtZeNEf0eem545N5G7JNggxTxUoqowXgEU9KqHke8td3KbsFOw6xcsIGqvh826lNQw/ 8egcHvfloSsFp5ihe5r78VSI6FyhCMn2gZn50l8v6LQiKp52aZTMrPNH1NmgGumrLTxg3D0SYfH wL/k6ETypde67OZVav7Ycinqw/+AJmgR3srg06CLsT4v+Vm972HSvKAWaWKlLmElCQd+Scz9GQX tTspZYEekj4n8JgAvkRnT6RTPLqE1wi77vF1W9G0TOqJfkYeSAPATYB/V04uLdlXpV4HfH5gXbs lGq8zHKuynuCH3eUZdrE2xoPxDhK3vr+AJ2tWHRzBfQ2wS1xNhRbpPHYd3JtEcd1+ZSWt5D9enR k9d+CbsDKgPzTH/+ib97sCu9LVAVBECiwpg96Ws5348NGvH8CHOVPmp7XoTjBegNlQwVHV4EjA9 63ShWXFFOUYxeODHSRCRAIGaiUidmF3El1APpPYJA== X-Received: by 2002:a17:903:2c8b:b0:2e9:5c55:c46a with SMTP id d9443c01a7336-2e9a6834a18mr34639815ad.7.1792287967822; Sat, 17 Oct 2026 18:46:07 -0700 (PDT) Received: from localhost.localdomain ([69.9.132.159]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2e97e87836bsm25935655ad.47.2026.10.17.18.46.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 17 Oct 2026 18:46:07 -0700 (PDT) From: Tim Orling X-Google-Original-From: Tim Orling To: yocto-patches@lists.yoctoproject.org Cc: Tim Orling Subject: [error-report-web][PATCH 2/5] Add docker/run-tests.sh to run the tests in a container. Date: Sat, 17 Oct 2026 18:43:58 -0700 Message-ID: <20261018014510.72203-5-tim.orling@konsulko.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261018014510.72203-1-tim.orling@konsulko.com> References: <20261018014510.72203-1-tim.orling@konsulko.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sun, 18 Oct 2026 01:46:16 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/5046 Build the image and test against a throwaway MySQL, as layerindex-web does. -Wa shows deprecation warnings. Read SECRET_KEY from the environment in settings.py.docker, and keep .git and .env out of the image and .env out of git. AI-Generated: Claude Opus 5.5 Signed-off-by: Tim Orling --- .dockerignore | 10 ++++++++++ .gitignore | 1 + docker/run-tests.sh | 32 ++++++++++++++++++++++++++++++++ project/settings.py.docker | 2 +- 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100755 docker/run-tests.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..adce5c5 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +.git +.env +.devcontainer +.ruff_cache +__pycache__ +*.pyc +*.sqlite3 +*.patch +venv +.venv diff --git a/.gitignore b/.gitignore index a6c3d2d..2b8f143 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ pull-*/ venv *.sqlite3 +.env diff --git a/docker/run-tests.sh b/docker/run-tests.sh new file mode 100755 index 0000000..54aaa8b --- /dev/null +++ b/docker/run-tests.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Run the tests in the app image against a throwaway MySQL. Used by CI. +# +# SPDX-License-Identifier: MIT + +set -e + +IMAGE=${IMAGE:-error-report-web-test} +NET=error-report-web-test +DB=error-report-web-test-db + +docker build -t "$IMAGE" . + +docker network create $NET >/dev/null +trap 'docker rm -f $DB >/dev/null; docker network rm $NET >/dev/null' EXIT + +# Root so Django can create the test database; testingpw isn't a secret. +docker run -d --name $DB --network $NET --network-alias db \ + -e MYSQL_ROOT_PASSWORD=testingpw -e MYSQL_DATABASE=errorreport \ + mysql:8.0.36 >/dev/null +until docker exec $DB mysql -h127.0.0.1 -uroot -ptestingpw -e 'SELECT 1' >/dev/null 2>&1; do + if [ "$(docker inspect -f '{{.State.Running}}' $DB)" != true ]; then + docker logs $DB | tail -5; exit 1 + fi + sleep 1 +done + +# -Wa shows deprecation warnings, i.e. what breaks on the next Django. +docker run --rm --network $NET \ + -e SECRET_KEY=ci-only \ + -e MYSQL_DATABASE=errorreport -e MYSQL_USER=root -e MYSQL_PASSWORD=testingpw \ + "$IMAGE" python3 -Wa manage.py test --noinput Post diff --git a/project/settings.py.docker b/project/settings.py.docker index b7ff669..9f98715 100644 --- a/project/settings.py.docker +++ b/project/settings.py.docker @@ -127,7 +127,7 @@ STATICFILES_FINDERS = ( ) # Make this unique, and don't share it with anybody. -SECRET_KEY = 'changeme' +SECRET_KEY = os.environ.get('SECRET_KEY', 'changeme') MIDDLEWARE = [ 'django.middleware.common.CommonMiddleware', From patchwork Sun Oct 18 01:44:00 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Orling X-Patchwork-Id: 101160 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81924CCF2C4 for ; Sun, 18 Oct 2026 01:46:36 +0000 (UTC) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.7793.1792287988209821647 for ; Sat, 17 Oct 2026 18:46:28 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=VDml63jQ; spf=pass (domain: gmail.com, ip: 209.85.214.181, mailfrom: ticotimo@gmail.com) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2e98798cbddso3505005ad.0 for ; Sat, 17 Oct 2026 18:46:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792287987; x=1792892787; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=3rIrMo220QotMJQgy8K0MRCyV17OJ0Bxjt04sRaO+Ug=; b=VDml63jQ36ihoP+5ltly6wSyqalLXi41o6AIzyJYQqpezbTj3VAWIxGtDcfYoIRiKK ympOhTVBfBBSZv51/Dr1DKTd4qOy0QyEeYOQ/0Nvv6XxAR9wOJWvVU5HcsN8O7MuKNSs q47X8isHhy0cA3F+Q/5Qq6qt3wK/gYRwsnEcpgXKHdHeibR3a1iVGEdSNkfkfxiYGv+v rjEhARQaadhMOYFNWWvtsunLcFQgN+EvBrnPCirtI9Ow/sum768c4sPd9FF/Lm+Rk+Ui D0y4mcfDFuO3+P5Xx5qYDOJlqYinki2MPxk5hPQ3H35SiV/RlSIF/qXWlKaziCGRXd6H gw5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792287987; x=1792892787; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=3rIrMo220QotMJQgy8K0MRCyV17OJ0Bxjt04sRaO+Ug=; b=G21YUvLFRgJh7Ty/CKeQ2A+ce/3XW9HzCD4NkU+EQyAgdQaezxPrQyIA9GVH4UFtZt ZmPn1JEWvu4NtenX64jnL5LnsliybnOEKdMT5gyn5Yfd7XKMaE/DDvFKOJjsz8k8m0YL 3Gb5R9vrIIYPrnqEjXHT3z1M9DdfdBU0i/taAqPRhQ4MQ3tvalBGVJ6tv9FWyKRnb3Ec 4tZMC/QSauY59skL1r8pFYpMMRtj7q7SWWe0SfkBqBuQJ4WwCKPIcXjyBUNap3KA9seO QgCGTF+jHv2LrFlmthkptqeNnRTh72D0WtSGIntwwisXPfpNplfxbfp4CGoS6b4KbR/r IGKg== X-Gm-Message-State: AFq9FYJ56N7IOexmwOjuvCRGII7oKDpabS5cmb7IzwmnauPXLjuNsLpW HQYnloUDzERPnV2VtfWs9T5GJSNPlBxsstHjEyGXwikirvWhQsz2gHFUa1bjUQ== X-Gm-Gg: AYBFou3tLtpGEBW6E7hJybjKK7a7Ivi/eKNoANV8+30++fbAXTiDnDIt+EJtj11x0wd HpvbdCvGvDhj8vKyJ5otY3MAcKv4N01wXad2r/+ej8iUj6k9oHcIDOWTDmXw9H+EUCwBEwMkgF/ wcuVUB3w0vyot7DKZqLc032N+tGvAXqop1wLfQslBF4p7A8V/raMvzshm3xKTs0mkK18u3/r5RK FkVDT/9By4yBEYwAya8u7D6+DwOvZ0WRRJnb4MVbiFuXfE5q7ZK8To4K8zrRqRkK7SnHJWTXJ4h aH3e/gnqxM3JEK4U5FrIBOLrhgfba1lGHK2i4oXOI2h1Y0Wt4nLYwhNl4SyPu8BekBDh7ZobHn1 6jM9xNVSe1gIVrR40DwvamIyPpOHo3CeaL1tR8hJwZ7ec8sxtb6H/1Q9wJoVHQknJgeFcWP5AAl emu7Bis8JlPfDUMszNrXLhX5sUnb5/LkbtOsGI85k/l+prfImAHZeOI8nwxLCNzBTlbQcJL6OMl YB+4E83j064hJZNKLgc1o5VxTLRrOM= X-Received: by 2002:a17:903:1b4c:b0:2e9:734c:5027 with SMTP id d9443c01a7336-2e9a69e9de2mr34324265ad.15.1792287987464; Sat, 17 Oct 2026 18:46:27 -0700 (PDT) Received: from localhost.localdomain ([69.9.132.159]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2e97e87836bsm25935655ad.47.2026.10.17.18.46.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 17 Oct 2026 18:46:26 -0700 (PDT) From: Tim Orling X-Google-Original-From: Tim Orling To: yocto-patches@lists.yoctoproject.org Cc: Tim Orling Subject: [error-report-web][PATCH 3/5] Add a GitHub Actions workflow to run the tests. Date: Sat, 17 Oct 2026 18:44:00 -0700 Message-ID: <20261018014510.72203-7-tim.orling@konsulko.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261018014510.72203-1-tim.orling@konsulko.com> References: <20261018014510.72203-1-tim.orling@konsulko.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sun, 18 Oct 2026 01:46:36 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/5047 Runs docker/run-tests.sh, as layerindex-web does. AI-Generated: Claude Opus 5.5 Signed-off-by: Tim Orling --- .github/workflows/ci.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..74405ac --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: MIT + +name: CI + +on: + push: + branches: [master,master-next] + pull_request: + branches: [master] + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v5 + + - name: Build image and run tests + run: docker/run-tests.sh From patchwork Sun Oct 18 01:44:02 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Orling X-Patchwork-Id: 101161 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85FB5CCF2C7 for ; Sun, 18 Oct 2026 01:46:56 +0000 (UTC) Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.7826.1792288013472378239 for ; Sat, 17 Oct 2026 18:46:53 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=cswkRFFL; spf=pass (domain: gmail.com, ip: 209.85.214.171, mailfrom: ticotimo@gmail.com) Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2e9ae391a05so5458015ad.1 for ; Sat, 17 Oct 2026 18:46:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792288013; x=1792892813; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=NW3RIhbnXW7SLXrcJiKOnmH5XQGzdcPXNW3PuAb0Jqo=; b=cswkRFFLNI3wEEg6sA7xBe9Et5ymoHv72HJSMCHXhAWptS4bgyhQdq+suGbauiHkBK Tou2P/tn8JOnBTxRky/M12xgpABb+v5lheJI0ns80V5bM/lZdvqgVuU72GMwZrTTz4h8 DvOJoa7DYbB796Lc8+jK19wG9sfhJIOp5ceDBdytEua25d1gYH/c5mTrGfwLL+08pJQq nXKEMukdFfB8DvwWdCSrDAMpYnjKE1gj46ZxOah8DmWxtGK9zkfOQ2jef2ZNKH75yjAv sFwAyGdLseSssc+n2xYkibwalOmkYI4iTAFB2xs+Q0MOMkv8vdKLvDz8wdC5NY9Dth1R SDkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792288013; x=1792892813; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=NW3RIhbnXW7SLXrcJiKOnmH5XQGzdcPXNW3PuAb0Jqo=; b=gDFlFYwt8mZC0Usy75mcWSV3uebj8yd7+0ANuBamJDlYrzEqTS5B/Fd88FqdSygHBE CgqhFJHH0OQNdf20G+y1700FJH6QHBKTPZi9jcHZ2GSYh6rFQYvwurPYuPJHDTlIMrg0 9OGUZLoQNo1/WAlhzooUIRKJAyqahpN92AXH3jH6G2I/82Rd5lT9+GQuz5XDe1ocn3O5 L+H17orpRPX+OHb078cNziCbL8ahKrumBbc7jRfx8u38Ik87Lnkemo8Le+PN8+UPpYbx 5MODpmEogK4rawFQbgEr+zSlXmrU+7a6b6jenLqanMQhUtspXECMjEdFreipPrNmsX0d vqKw== X-Gm-Message-State: AFq9FYK22jsMlOBCgsCTPcOfcYjU6PvtfloedFNkemXFbsoCWlQnVHZn gscBZ5q7+vFBjYxOcTpMgpUlCqWRqawJDiOnBrQ36WFzFT/IEv+Hhr12hWeaZQ== X-Gm-Gg: AYBFou10fnl7gchF+uDKXDLs7L/35wcCrjOMK6RwyJdWDIUrtU77i+GXQnBqFg2fdU8 8CS9W079rrPbGVhomkLuEsUysYGNe+URFnxE0hB/eNm4mXcI8CjAeu9uBDMhE1GfVuieLWQgyFQ TqsApiwzQ2F2C7Y0RH/J8oeSyBebgkprtehJkKOi5Ict8/XWFl/Q8UggA+rdLg+4AoJXakIQOc3 x5oRE+aJhlPxFRjafyHA93ak6Me5bbvW1JBKp7A7e+AUncQPua+pFKAZP6tWc9czpN9d6YlI7MU PrGyngsqfAENSBdAGZZxSLdlOojwFuzLK+ep2uh37WjRwEDu82SpkK7nml5Ac67ueIdOC7efmbq cPW4TvyKMLXoxpUFWxOs4EXSdHhz9nDvyAiW+1RrovVIzzCqBstQD4vd8lhLOS9HrF5IVnIFHBA HJSj/THwTq+GNbg1NT4LJGET0DGaeE2Zg3RPSrNCpC2IXDjjlRnuHaiQohw6Jn9Vv14ICuZcjlY l57K8anGJh6I0WUTeXwkJkMUYE3GR0= X-Received: by 2002:a17:903:32c2:b0:2e8:5431:d18c with SMTP id d9443c01a7336-2e9a6e43863mr27050885ad.40.1792288012825; Sat, 17 Oct 2026 18:46:52 -0700 (PDT) Received: from localhost.localdomain ([69.9.132.159]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2e97e87836bsm25935655ad.47.2026.10.17.18.46.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 17 Oct 2026 18:46:52 -0700 (PDT) From: Tim Orling X-Google-Original-From: Tim Orling To: yocto-patches@lists.yoctoproject.org Cc: Tim Orling Subject: [error-report-web][PATCH 4/5] Port culldb and purge.py to Python 3. Date: Sat, 17 Oct 2026 18:44:02 -0700 Message-ID: <20261018014510.72203-9-tim.orling@konsulko.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261018014510.72203-1-tim.orling@konsulko.com> References: <20261018014510.72203-1-tim.orling@konsulko.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sun, 18 Oct 2026 01:46:56 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/5048 Both used Python 2 print and failed with SyntaxError. culldb also used option_list and optparse, removed in Django 1.10; declare the same arguments with add_arguments(). Add culldb tests. Found by ruff. AI-Generated: Claude Opus 5.5 Signed-off-by: Tim Orling --- Post/management/commands/culldb.py | 36 +++++++++++++----------------- Post/purge.py | 2 +- Post/test.py | 21 +++++++++++++++++ 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/Post/management/commands/culldb.py b/Post/management/commands/culldb.py index bd70ffc..46c586d 100644 --- a/Post/management/commands/culldb.py +++ b/Post/management/commands/culldb.py @@ -9,44 +9,38 @@ # Create your views here. # vi: tabstop=8 expandtab shiftwidth=4 softtabstop=4 -from django.core.management.base import BaseCommand, CommandError -from Post.models import Build, BuildFailure -from optparse import make_option +from django.core.management.base import BaseCommand +from Post.models import Build import time import sys class Command(BaseCommand): help = 'Culls the database to size in rows' - args = '' - option_list = BaseCommand.option_list + ( - make_option('-i', - '--info', - dest='info', - action="store_true", - help='Show the current database size'), - ) + + def add_arguments(self, parser): + parser.add_argument('size', nargs='?', type=int, + help='Number of builds to keep') + parser.add_argument('-i', + '--info', + action="store_true", + help='Show the current database size') def handle(self, *args, **options): count = Build.objects.count() if options['info']: - print "Current builds table size: %d" % Build.objects.count() + print("Current builds table size: %d" % Build.objects.count()) return - if len(args) > 0 and args[0]: - try: - new_size = int(args[0]) - except ValueError: - print "Not a valid size" - return - + if options['size'] is not None: + new_size = options['size'] num_to_delete = count - new_size - print "\nReducing the database size to %d which will DELETE %d rows" % (new_size, num_to_delete) + print("\nReducing the database size to %d which will DELETE %d rows" % (new_size, num_to_delete)) i = 1 while i != 0: i = i-1 - print 'Ctrl+c TO CANCEL. Executing in... %d \r' % i, + print('Ctrl+c TO CANCEL. Executing in... %d \r' % i, end='') sys.stdout.flush() time.sleep(1) diff --git a/Post/purge.py b/Post/purge.py index dd58441..f4989fb 100644 --- a/Post/purge.py +++ b/Post/purge.py @@ -20,7 +20,7 @@ def main(): #print query items = BuildFailure.objects.raw(query) for item in items: - print "Deleting: ", item.id + print("Deleting: ", item.id) item.delete() if __name__ == "__main__": diff --git a/Post/test.py b/Post/test.py index 734b99c..9527a9f 100755 --- a/Post/test.py +++ b/Post/test.py @@ -1,5 +1,7 @@ import urllib.request, urllib.parse, urllib.error import json +from unittest.mock import patch +from django.core.management import call_command import re from django.test import Client, TestCase, override_settings from Post.models import BuildFailure, Build @@ -385,3 +387,22 @@ class LinkBackSubmissionTest(TestCase): bf = self._submit("http://example.com/build/42") self.assertEqual(bf.BUILD.LINK_BACK, "http://example.com/build/42") + + +@patch("Post.management.commands.culldb.time.sleep") +class CullDbTest(TestCase): + def setUp(self): + for _ in range(3): + Build.objects.create() + + def test_culls_to_size(self, _sleep): + call_command("culldb", "1") + self.assertEqual(Build.objects.count(), 1) + + def test_zero_culls_everything(self, _sleep): + call_command("culldb", "0") + self.assertEqual(Build.objects.count(), 0) + + def test_info_deletes_nothing(self, _sleep): + call_command("culldb", "--info") + self.assertEqual(Build.objects.count(), 3) From patchwork Sun Oct 18 01:44:04 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Orling X-Patchwork-Id: 101162 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 829F2CCF2C7 for ; Sun, 18 Oct 2026 01:47:36 +0000 (UTC) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.7808.1792288046527817754 for ; Sat, 17 Oct 2026 18:47:26 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20251104 header.b=c31xDJOL; spf=pass (domain: gmail.com, ip: 209.85.214.169, mailfrom: ticotimo@gmail.com) Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2e95bd1c14cso8432915ad.2 for ; Sat, 17 Oct 2026 18:47:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792288046; x=1792892846; darn=lists.yoctoproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=n/S5sPXsIyRmIGUnwhuuvERiQrBb3PRHHUebft2nC6I=; b=c31xDJOLi08oSkWeJj7U3cdaa1J4CFgNZy6jCOdKRePwT0kRoYuiQse+Z9m1J65ihH xdv4rb1HO+l6xU9ApsaHCSRzUWnEdVH/tquzuz3sWGN2XZGmsgcSeTJd06VWVSI3wC/y NN4rDtxhB34vnNFiDmoplmpYYny4fDJRxc2X87c8V9uSmbCqXhp6sZW+dT9lAB3VPKOM XZv7/XlUSKxHa1Z4Y+flfeW8S59QX41wrYdk2aQolP5euQ+h8nfBk1Kugh8iKH4FwXo9 P9k2jNhoY0zqpHdWNFOMvnkQq6akRUg4Cfw7+/TS9o4upubM8rctdjF108oDCesYky8K EadQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792288046; x=1792892846; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=n/S5sPXsIyRmIGUnwhuuvERiQrBb3PRHHUebft2nC6I=; b=yDhHiUQ65ChO+nyFNQ4Vqjms9ArKSiZeOGOCy08iBI76XtTXX8cDLqEO3iC9F13m8v ihVSFK1D/klxSlUMyUufhlLk+ryNJ4fpbKql186gisCa+mgQswM60c02KSjXZwx8uD3X vKGkzNXmy3NGNjDrzMjDNSOWXg5DRfr1GDMrE8TSizx0Ibq3MWKm8npPtfdyRO2IiSNP 0QWKcireR2Vu6TNBUO4Qt+zPVS8E2x2JrG/JGK++CFzk7EH7FfIM+OqZDExNGoB518U4 BdSd9rOPb7djSy81nKdeCMcsFmVARg3RJFCl/VFiBxJi52YJJgZJMoMM12zvesdGiuIi jkzw== X-Gm-Message-State: AFq9FYJp1NUk6JhjsISxvv8ylg6sNQ3jIAjbmqSrQdPyQrYITzdOTzfE eXdIoo2EX8QWy+ITo/AmoFywxHLw7ySDln2vzuA8pKMCboU0r7GHSis30jp0dQ== X-Gm-Gg: AYBFou37CySZ/YWnpfQLpuhJTwTfBej/YFYbhUO6q51lBXXLEdXopsI8Ca+qxNx/JTp l1sNdAwq2SZnFS/M4ZqkZVSDyGP4pP++OZeVHgQMlQlvD1p8yw62mJqz7P+6HDriX6IYVxQLgT0 LFpHuwIug+x+RprTOljWh7AtPcK/dn3LhnKXtzrfyC+XKiSU8kFE9e52YqjKxBzJriUkTQJLt6i XErNcFdDb10fg4ezQVxXXlvcSA0vnh5isrlGnDoQS0/mDqeDoIWhyyw6TYoQVESKo9p9XUj/e5E MgJy6Ia4X4SkpefWCo0/NPaj/i1isz8eC+tz6erihpS+6dXAgr58Q/v9tubDaYC1QLaCCrTMjT7 l4xBsX7dm4qH/3nbXsGSu7vOEj7nyTSMtvSmqnJPmb2rUrJczT1wSPfgtd+QwKgWtB0uSTwyTw2 9i/zcF6vJtWamIVGqQ5OhSLeYKvWDT0S+slclEQGI0yTRfB2vORMHGCTArDjymKUvHFHxn+q3WC CUhjGnpE4ibGcAeJH+LjKgDuM96O0M= X-Received: by 2002:a17:903:22c3:b0:2e9:9846:2da7 with SMTP id d9443c01a7336-2e9a68437f0mr38901305ad.5.1792288045820; Sat, 17 Oct 2026 18:47:25 -0700 (PDT) Received: from localhost.localdomain ([69.9.132.159]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2e97e87836bsm25935655ad.47.2026.10.17.18.47.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 17 Oct 2026 18:47:25 -0700 (PDT) From: Tim Orling X-Google-Original-From: Tim Orling To: yocto-patches@lists.yoctoproject.org Cc: Tim Orling Subject: [error-report-web][PATCH 5/5] Add a ruff lint job to CI and fix its findings. Date: Sat, 17 Oct 2026 18:44:04 -0700 Message-ID: <20261018014510.72203-11-tim.orling@konsulko.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261018014510.72203-1-tim.orling@konsulko.com> References: <20261018014510.72203-1-tim.orling@konsulko.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Sun, 18 Oct 2026 01:47:36 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/yocto-patches/message/5049 Pin ruff and select its classic rules, which find bugs; newer defaults are mostly style. Fix the findings. The paginator now catches InvalidPage, and the JSON parser Exception, so deeply nested JSON (RecursionError) is still reported as invalid. Test bad page numbers. AI-Generated: Claude Opus 5.5 Signed-off-by: Tim Orling --- .github/workflows/ci.yml | 9 +++++++++ Post/createStatistics.py | 6 ++---- Post/models.py | 4 +--- Post/parser.py | 5 +++-- Post/purge.py | 2 +- Post/templatetags/projecttags.py | 4 ---- Post/test.py | 13 ++++++++++++- Post/views.py | 10 ++++------ ruff.toml | 5 +++++ test-data/test-send-error.py | 4 +++- 10 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 ruff.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74405ac..f53ae69 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,3 +20,12 @@ jobs: - name: Build image and run tests run: docker/run-tests.sh + + lint: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v5 + + - name: Ruff + run: pipx run ruff==0.17.0 check --output-format=github . diff --git a/Post/createStatistics.py b/Post/createStatistics.py index 09d098e..6ecab0a 100644 --- a/Post/createStatistics.py +++ b/Post/createStatistics.py @@ -8,11 +8,9 @@ # # Licensed under the MIT license, see COPYING.MIT for details -import sys, os from Post.models import Build, BuildFailure from django.db.models import Count -import re -from datetime import datetime, timedelta +from datetime import timedelta from django import utils class Statistics: @@ -52,7 +50,7 @@ class Statistics: elif string == "NATIVELSBSTRING": errors = Build.objects.filter(DATE__range=[enddate, startdate]).values('NATIVELSBSTRING').annotate(dcount=Count('NATIVELSBSTRING')).order_by('-dcount')[:6] items = list(errors) - return items; + return items elif string == "TARGET_SYS": errors = Build.objects.filter(DATE__range=[enddate, startdate]).values('TARGET_SYS').annotate(dcount=Count('TARGET_SYS')).order_by('-dcount')[:6] items = list(errors) diff --git a/Post/models.py b/Post/models.py index 541f394..eef0c0c 100644 --- a/Post/models.py +++ b/Post/models.py @@ -7,9 +7,7 @@ # Licensed under the MIT license, see COPYING.MIT for details from django.db import models -from django.db.models.signals import post_save from django.conf import settings -from datetime import datetime import Levenshtein @@ -117,7 +115,7 @@ class BuildFailure(models.Model): recalc_lev_distance = kwargs.pop('recalc_lev_distance', False) - if self.LEV_DISTANCE == None or recalc_lev_distance: + if self.LEV_DISTANCE is None or recalc_lev_distance: self.LEV_DISTANCE = self.calc_lev_distance() super(BuildFailure, self).save(*args, **kwargs) diff --git a/Post/parser.py b/Post/parser.py index b6740d0..092ce24 100644 --- a/Post/parser.py +++ b/Post/parser.py @@ -8,7 +8,8 @@ # # Licensed under the MIT license, see COPYING.MIT for details -import json, re +import json +import re import bleach from Post.models import Build, BuildFailure, ErrorType from Post.validators import clean_link_back @@ -26,7 +27,7 @@ class Parser: try: jsondata = json.loads(self.data) - except: + except Exception: return { 'error' : 'Invalid json' } # Bleach data going directly into the database so that diff --git a/Post/purge.py b/Post/purge.py index f4989fb..eb2ee7b 100644 --- a/Post/purge.py +++ b/Post/purge.py @@ -1,4 +1,4 @@ -from datetime import datetime, timedelta +from datetime import timedelta from django.utils import timezone import os import sys diff --git a/Post/templatetags/projecttags.py b/Post/templatetags/projecttags.py index a01989f..838b8f7 100644 --- a/Post/templatetags/projecttags.py +++ b/Post/templatetags/projecttags.py @@ -1,8 +1,4 @@ -from datetime import datetime, timedelta -import re from django import template -from django.utils import timezone -from django.template.defaultfilters import filesizeformat from Post.validators import clean_link_back register = template.Library() diff --git a/Post/test.py b/Post/test.py index 9527a9f..2a98bfc 100755 --- a/Post/test.py +++ b/Post/test.py @@ -1,4 +1,6 @@ -import urllib.request, urllib.parse, urllib.error +import urllib.request +import urllib.parse +import urllib.error import json from unittest.mock import patch from django.core.management import call_command @@ -389,6 +391,15 @@ class LinkBackSubmissionTest(TestCase): +@override_settings(ALLOWED_HOSTS=["testhost"]) +class PaginationTest(TestCase): + def test_invalid_page_shows_last_page(self): + client = Client(HTTP_HOST="testhost") + for page in ("999", "abc"): + response = client.get("/Errors/Latest/", {"page": page}) + self.assertEqual(response.status_code, 200) + + @patch("Post.management.commands.culldb.time.sleep") class CullDbTest(TestCase): def setUp(self): diff --git a/Post/views.py b/Post/views.py index add68d5..9b6656d 100644 --- a/Post/views.py +++ b/Post/views.py @@ -10,19 +10,17 @@ # vi: tabstop=8 expandtab shiftwidth=4 softtabstop=4 from __future__ import division -from django.shortcuts import get_object_or_404 from django.shortcuts import HttpResponse, render from django.views.decorators.csrf import csrf_exempt from django.shortcuts import redirect -from Post.models import BuildFailure, Build, ErrorType +from Post.models import BuildFailure, ErrorType from Post.parser import Parser from django.conf import settings from Post.createStatistics import Statistics -from django.core.paginator import Paginator, EmptyPage +from django.core.paginator import InvalidPage, Paginator from django.core.exceptions import FieldError, ObjectDoesNotExist, RequestDataTooBig from django.http import JsonResponse from django.db.models import Q -import json import re import urllib from urllib.parse import urlparse @@ -76,7 +74,7 @@ def addData(request, return_json=False): if return_json: response = JsonResponse(result) else: - if not 'error' in result: + if 'error' not in result: response = HttpResponse("Your entry can be found here: "+result['build_url']) else: response = HttpResponse(result['error']) @@ -252,7 +250,7 @@ def search(request, mode=results_mode.LATEST, **kwargs): try: build_failures = build_failures.page(page) - except: + except InvalidPage: build_failures = build_failures.page(build_failures.num_pages) context['build_failures'] = build_failures diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000..cd9662d --- /dev/null +++ b/ruff.toml @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: MIT + +[lint] +# Ruff's classic defaults: bugs, not style. +select = ["E4", "E7", "E9", "F"] diff --git a/test-data/test-send-error.py b/test-data/test-send-error.py index de2fc49..7a8067f 100755 --- a/test-data/test-send-error.py +++ b/test-data/test-send-error.py @@ -3,7 +3,9 @@ # test/example script for sending data to error-report-web -import urllib.request, urllib.error, urllib.parse +import urllib.request +import urllib.error +import urllib.parse import sys def send_data (url, data_file):