From fc0293227826400d25f4b40984213197f2151102 Mon Sep 17 00:00:00 2001 From: Marie Backman Date: Fri, 30 Aug 2024 14:06:52 -0400 Subject: [PATCH] debug --- tests/test_autoreducer_memory_limit.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/test_autoreducer_memory_limit.py b/tests/test_autoreducer_memory_limit.py index fbb8e0ff..444d5390 100644 --- a/tests/test_autoreducer_memory_limit.py +++ b/tests/test_autoreducer_memory_limit.py @@ -3,6 +3,7 @@ on the memory used by reduction scripts. """ +import requests import time from tests.utils import db_utils @@ -15,13 +16,25 @@ class TestAutoreducerMemoryLimit: IPTS = "IPTS-4321" run_number = 54321 + def login(self, next, username, password): + # taken from test_RunPageView.py - consolidate as helper somewhere? + URL = "http://localhost/users/login?next=" + client = requests.session() + + # Retrieve the CSRF token first + client.get(URL) # sets the cookie + csrftoken = client.cookies["csrftoken"] + + login_data = dict(username=username, password=password, csrfmiddlewaretoken=csrftoken) + return client.post(URL + next, data=login_data, timeout=None) + def test_reduction_script_exceeds_memory_limit(self, db_connection, request_page): """test that the reduction is terminated and an error is logged""" run_id = db_utils.add_instrument_data_run(db_connection, self.instrument, self.IPTS, self.run_number) db_utils.clear_previous_runstatus(db_connection, run_id) # login and send reduction request - response = request_page("/report/pg3/54321/reduce/", self.user, self.pwd) + response = self.login("/report/pg3/54321/reduce/", self.user, self.pwd) assert response.status_code == 200 assert response.url.endswith("/report/pg3/54321/")