From c998e8c0d6003320bab5ed9ded628238a1b11e34 Mon Sep 17 00:00:00 2001 From: claude Date: Thu, 15 Oct 2026 11:16:14 +0200 Subject: [PATCH] Pipelines: tests for the New pipeline page Covers the page, one branch and Enter, and what goes wrong, with the real scheduler and routing underneath: the first test is made from what the page filled in, a pass starts the next test with its own settings, anything else ends the run, and a first test that cannot be made leaves no pipeline behind. The engines of the config are swapped for one the tests know, so they do not depend on what a server has set up. The page is read the way a browser reads it, because the site minifies its pages. The shared test client now sends X-Forwarded-Proto: https, like the proxy in front of the site. With SECURE_SSL_REDIRECT on, as in OpenSite/settings.py, every plain-http request of the test client is otherwise answered with a redirect to https, and no page test can pass. --- OpenBench/tests_pipeline_views.py | 468 +++++++++++++++++++++++++++++- 1 file changed, 466 insertions(+), 2 deletions(-) diff --git a/OpenBench/tests_pipeline_views.py b/OpenBench/tests_pipeline_views.py index 0de3fb0..71380e3 100644 --- a/OpenBench/tests_pipeline_views.py +++ b/OpenBench/tests_pipeline_views.py @@ -24,16 +24,21 @@ # The Pipeline pages, with a real ( test ) database and the real URL routing. As # in tests_pipelines.py, only the call out to Github is replaced. +import copy import json import re +from html.parser import HTMLParser +from unittest import mock + from django.contrib.auth.models import User from django.test import Client +import OpenBench.config import OpenBench.pipelines as pipelines import OpenBench.tests_pipelines as base -from OpenBench.models import LogEvent, Pipeline, PipelineRun, Profile, StepRun, Test +from OpenBench.models import LogEvent, Network, Pipeline, PipelineRun, Profile, StepRun, Test def make_user(name, enabled=True, approver=False): user = User.objects.create_user(name, '%s@example.com' % (name), 'pw') @@ -54,7 +59,10 @@ class PagesTestCase(base.PipelineTestCase): self.dave = make_user('dave', enabled=False) # A disabled account def client_for(self, user=None, **kwargs): - client = Client(**kwargs) + + # The site sends everything to https, as it is behind a proxy that says that it was. So do the tests + client = Client(HTTP_X_FORWARDED_PROTO='https', **kwargs) + if user is not None: client.force_login(user) return client @@ -571,3 +579,459 @@ class PreviewTests(PagesTestCase): self.assertIn('class="pl-graph"', data['svg']) self.assertNotIn(' could not be found'] + page = self.post({ 'dev_branch' : 'zzz', 'name' : 'nn' }).content.decode() + + self.assertNotIn('