Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
backmari committed Aug 30, 2024
1 parent 222d48e commit fc02932
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/test_autoreducer_memory_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
on the memory used by reduction scripts.
"""

import requests
import time

from tests.utils import db_utils
Expand All @@ -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/")

Expand Down

0 comments on commit fc02932

Please sign in to comment.