Mercurial > p > roundup > code
comparison test/test_cgi.py @ 6651:da6c9050a79e
Fix modification of Cache_Control
The previous code modified the Cache_Control dictionary in the Client
class (in one of the cgi tests) which made a later test in
test_liveserver fail
| author | Ralf Schlatterbeck <rsc@runtux.com> |
|---|---|
| date | Mon, 02 May 2022 14:25:15 +0200 |
| parents | 154f286061e2 |
| children | ab2ed11c021e |
comparison
equal
deleted
inserted
replaced
| 6650:5be4f9104cf7 | 6651:da6c9050a79e |
|---|---|
| 10 | 10 |
| 11 from __future__ import print_function | 11 from __future__ import print_function |
| 12 import unittest, os, shutil, errno, sys, difflib, cgi, re, io | 12 import unittest, os, shutil, errno, sys, difflib, cgi, re, io |
| 13 | 13 |
| 14 import pytest | 14 import pytest |
| 15 import copy | |
| 15 | 16 |
| 16 from roundup.cgi import client, actions, exceptions | 17 from roundup.cgi import client, actions, exceptions |
| 17 from roundup.cgi.exceptions import FormError, NotFound, Redirect | 18 from roundup.cgi.exceptions import FormError, NotFound, Redirect |
| 18 from roundup.exceptions import UsageError, Reject | 19 from roundup.exceptions import UsageError, Reject |
| 19 from roundup.cgi.templating import HTMLItem, HTMLRequest, NoTemplate | 20 from roundup.cgi.templating import HTMLItem, HTMLRequest, NoTemplate |
| 1082 print("result of subtest 6a:", out[0], match_at) | 1083 print("result of subtest 6a:", out[0], match_at) |
| 1083 self.assertEqual(match_at, 33) | 1084 self.assertEqual(match_at, 33) |
| 1084 del(out[0]) | 1085 del(out[0]) |
| 1085 cl.db.config['WEB_CSRF_ENFORCE_TOKEN'] = 'yes' | 1086 cl.db.config['WEB_CSRF_ENFORCE_TOKEN'] = 'yes' |
| 1086 | 1087 |
| 1087 import copy | |
| 1088 form2 = copy.copy(form) | 1088 form2 = copy.copy(form) |
| 1089 form2.update({'@csrf': 'booogus'}) | 1089 form2.update({'@csrf': 'booogus'}) |
| 1090 # add a bogus csrf field to the form and rerun the inner_main | 1090 # add a bogus csrf field to the form and rerun the inner_main |
| 1091 cl.form = db_test_base.makeForm(form2) | 1091 cl.form = db_test_base.makeForm(form2) |
| 1092 | 1092 |
| 1761 os.remove(SENDMAILDEBUG) | 1761 os.remove(SENDMAILDEBUG) |
| 1762 | 1762 |
| 1763 def testserve_static_files(self): | 1763 def testserve_static_files(self): |
| 1764 # make a client instance | 1764 # make a client instance |
| 1765 cl = self._make_client({}) | 1765 cl = self._make_client({}) |
| 1766 # Make local copy in cl to not modify value in class | |
| 1767 cl.Cache_Control = copy.copy (cl.Cache_Control) | |
| 1766 | 1768 |
| 1767 # hijack _serve_file so I can see what is found | 1769 # hijack _serve_file so I can see what is found |
| 1768 output = [] | 1770 output = [] |
| 1769 def my_serve_file(a, b, c, d): | 1771 def my_serve_file(a, b, c, d): |
| 1770 output.append((a,b,c,d)) | 1772 output.append((a,b,c,d)) |
