Dead code removal: meeting models and test_utils.
- Legacy-Id: 12965
This commit is contained in:
parent
73a2d86f12
commit
3c6f00869f
|
@ -5,7 +5,6 @@ import datetime
|
|||
from urlparse import urljoin
|
||||
import copy
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import string
|
||||
|
||||
|
@ -169,17 +168,6 @@ class Meeting(models.Model):
|
|||
qs = qs.filter(type__slug='session')
|
||||
return qs
|
||||
|
||||
def sessions_that_can_be_placed(self):
|
||||
log.unreachable()
|
||||
from django.db.models import Q
|
||||
donotplace_groups = Q(group__acronym="edu")
|
||||
donotplace_groups |= Q(group__acronym="tools")
|
||||
donotplace_groups |= Q(group__acronym="iesg")
|
||||
donotplace_groups |= Q(group__acronym="ietf")
|
||||
donotplace_groups |= Q(group__acronym="iepg")
|
||||
donotplace_groups |= Q(group__acronym="iab")
|
||||
return self.sessions_that_can_meet.exclude(donotplace_groups)
|
||||
|
||||
def json_url(self):
|
||||
return "/meeting/%s.json" % (self.number, )
|
||||
|
||||
|
@ -651,14 +639,6 @@ class Schedule(models.Model):
|
|||
def is_official(self):
|
||||
return (self.meeting.agenda == self)
|
||||
|
||||
@property
|
||||
def official_class(self):
|
||||
log.unreachable()
|
||||
if self.is_official:
|
||||
return "agenda_official"
|
||||
else:
|
||||
return "agenda_unofficial"
|
||||
|
||||
# returns a dictionary {group -> [schedtimesessassignment+]}
|
||||
# and it has [] if the session is not placed.
|
||||
# if there is more than one session for that group,
|
||||
|
@ -702,26 +682,6 @@ class Schedule(models.Model):
|
|||
assignments,sessions,total,scheduled = self.group_session_mapping
|
||||
return assignments
|
||||
|
||||
@property
|
||||
def group_session_mapping(self):
|
||||
log.unreachable()
|
||||
assignments = dict()
|
||||
sessions = dict()
|
||||
total = 0
|
||||
scheduled = 0
|
||||
allschedsessions = self.qs_assignments_with_sessions.filter(timeslot__type = "session").all()
|
||||
for sess in self.meeting.sessions_that_can_meet.all():
|
||||
assignments[sess.group] = []
|
||||
sessions[sess] = None
|
||||
total += 1
|
||||
|
||||
for ss in allschedsessions:
|
||||
assignments[ss.session.group].append(ss)
|
||||
# XXX can not deal with a session in two slots
|
||||
sessions[ss.session] = ss
|
||||
scheduled += 1
|
||||
return assignments,sessions,total,scheduled
|
||||
|
||||
@property
|
||||
def sessions_that_can_meet(self):
|
||||
if not hasattr(self, "_cached_sessions_that_can_meet"):
|
||||
|
@ -735,15 +695,6 @@ class Schedule(models.Model):
|
|||
assignments = self.group_mapping
|
||||
return self.calc_badness1(assignments)
|
||||
|
||||
# calculate badness of entire schedule
|
||||
def calc_badness1(self, assignments):
|
||||
log.unreachable()
|
||||
badness = 0
|
||||
for sess in self.sessions_that_can_meet:
|
||||
badness += sess.badness(assignments)
|
||||
self.badness = badness
|
||||
return badness
|
||||
|
||||
def delete_schedule(self):
|
||||
self.assignments.all().delete()
|
||||
self.delete()
|
||||
|
@ -800,19 +751,6 @@ class SchedTimeSessAssignment(models.Model):
|
|||
return ""
|
||||
return self.session.group.parent.acronym
|
||||
|
||||
@property
|
||||
def group_type_str(self):
|
||||
log.unreachable()
|
||||
if not self.session or not self.session.group:
|
||||
return ""
|
||||
if self.session.group and self.session.group.type_id == "wg":
|
||||
if self.session.group.state_id == "bof":
|
||||
return "BOF"
|
||||
else:
|
||||
return "WG"
|
||||
|
||||
return ""
|
||||
|
||||
@property
|
||||
def slottype(self):
|
||||
log.unreachable()
|
||||
|
@ -915,15 +853,6 @@ class Constraint(models.Model):
|
|||
elif not self.target and self.person:
|
||||
return u"%s " % (self.person)
|
||||
|
||||
|
||||
|
||||
@property
|
||||
def person_conflicted(self):
|
||||
log.unreachable()
|
||||
if self.person is None:
|
||||
return "unknown person"
|
||||
return self.person.name
|
||||
|
||||
def status(self):
|
||||
log.unreachable()
|
||||
if self.active_status is not None:
|
||||
|
@ -931,22 +860,6 @@ class Constraint(models.Model):
|
|||
else:
|
||||
return True
|
||||
|
||||
def __lt__(self, y):
|
||||
log.unreachable()
|
||||
#import sys
|
||||
#sys.stdout.write("me: %s y: %s\n" % (self.name.slug, y.name.slug))
|
||||
if self.name.slug == 'conflict' and y.name.slug == 'conflic2':
|
||||
return True
|
||||
if self.name.slug == 'conflict' and y.name.slug == 'conflic3':
|
||||
return True
|
||||
if self.name.slug == 'conflic2' and y.name.slug == 'conflic3':
|
||||
return True
|
||||
return False
|
||||
|
||||
def constraint_cost(self):
|
||||
log.unreachable()
|
||||
return self.name.penalty;
|
||||
|
||||
def json_url(self):
|
||||
return "/meeting/%s/constraint/%s.json" % (self.meeting.number, self.id)
|
||||
|
||||
|
@ -1266,201 +1179,3 @@ class Session(models.Model):
|
|||
self._agenda_file = "%s/agenda/%s" % (self.meeting.number, filename)
|
||||
|
||||
return self._agenda_file
|
||||
def badness_test(self, num):
|
||||
log.unreachable()
|
||||
from settings import BADNESS_CALC_LOG # pylint: disable=import-error
|
||||
#sys.stdout.write("num: %u / BAD: %u\n" % (num, BADNESS_CALC_LOG))
|
||||
return BADNESS_CALC_LOG >= num
|
||||
|
||||
def badness_log(self, num, msg):
|
||||
log.unreachable()
|
||||
if self.badness_test(num):
|
||||
sys.stdout.write(msg)
|
||||
|
||||
# this evaluates the current session based upon the constraints
|
||||
# given, in the context of the assignments in the array.
|
||||
#
|
||||
# MATH.
|
||||
# each failed conflic3 is worth 1000 points
|
||||
# each failed conflic2 is worth 10000 points
|
||||
# each failed conflic1 is worth 100000 points
|
||||
# being in a room too small than asked is worth 200,000 * (size/50)
|
||||
# being in a room too big by more than 100 is worth 200,000 once.
|
||||
# a conflict where AD must be in two places is worth 500,000.
|
||||
# not being scheduled is worth 10,000,000 points
|
||||
#
|
||||
def badness(self, assignments):
|
||||
log.unreachable()
|
||||
badness = 0
|
||||
|
||||
if not (self.group in assignments):
|
||||
return 0
|
||||
|
||||
conflicts = self.unique_constraints()
|
||||
|
||||
if self.badness_test(2):
|
||||
self.badness_log(2, "badness for group: %s has %u constraints\n" % (self.group.acronym, len(conflicts)))
|
||||
from settings import BADNESS_UNPLACED, BADNESS_TOOSMALL_50, BADNESS_TOOSMALL_100, BADNESS_TOOBIG, BADNESS_MUCHTOOBIG # pylint: disable=import-error
|
||||
count = 0
|
||||
myss_list = assignments[self.group]
|
||||
# for each constraint of this sessions' group, by group
|
||||
if len(myss_list)==0:
|
||||
if self.badness_test(2):
|
||||
self.badness_log(2, " 0group: %s is unplaced\n" % (self.group.acronym))
|
||||
return BADNESS_UNPLACED
|
||||
|
||||
for myss in myss_list:
|
||||
if self.attendees is None or myss.timeslot is None or myss.timeslot.location.capacity is None:
|
||||
continue
|
||||
mismatch = self.attendees - myss.timeslot.location.capacity
|
||||
if mismatch > 100:
|
||||
# the room is too small by 100
|
||||
badness += BADNESS_TOOSMALL_100
|
||||
elif mismatch > 50:
|
||||
# the room is too small by 50
|
||||
badness += BADNESS_TOOSMALL_50
|
||||
elif mismatch < 50:
|
||||
# the room is too big by 50
|
||||
badness += BADNESS_TOOBIG
|
||||
elif mismatch < 100:
|
||||
# the room is too big by 100 (not intimate enough)
|
||||
badness += BADNESS_MUCHTOOBIG
|
||||
|
||||
for group,constraint in conflicts.items():
|
||||
if group is None:
|
||||
# must not be a group constraint.
|
||||
continue
|
||||
count += 1
|
||||
# get the list of sessions for other group.
|
||||
sess_count = 0
|
||||
if group in assignments:
|
||||
sess_count = len(assignments[group])
|
||||
if self.badness_test(4):
|
||||
self.badness_log(4, " [%u] 1group: %s session_count: %u\n" % (count, group.acronym, sess_count))
|
||||
|
||||
# see if the other group which is conflicted, has an assignment,
|
||||
if group in assignments:
|
||||
other_sessions = assignments[group]
|
||||
# and if it does, see if any of it's sessions conflict with any of my sessions
|
||||
# (each group could have multiple slots)
|
||||
#if self.badness_test(4):
|
||||
# self.badness_log(4, " [%u] 9group: other sessions: %s\n" % (count, other_sessions))
|
||||
for ss in other_sessions:
|
||||
# this causes additional database dips
|
||||
#if self.badness_test(4):
|
||||
# self.badness_log(4, " [%u] 9group: ss: %s %s\n" % (count, ss, ss.faked))
|
||||
if ss.session is None:
|
||||
continue
|
||||
if ss.timeslot is None:
|
||||
continue
|
||||
if self.badness_test(3):
|
||||
self.badness_log(3, " [%u] 2group: %s vs ogroup: %s\n" % (count, self.group.acronym, ss.session.group.acronym))
|
||||
if ss.session.group.acronym == self.group.acronym:
|
||||
continue
|
||||
if self.badness_test(3):
|
||||
self.badness_log(3, " [%u] 3group: %s sessions: %s\n" % (count, group.acronym, ss.timeslot.time))
|
||||
# see if they are scheduled at the same time.
|
||||
conflictbadness = 0
|
||||
for myss in myss_list:
|
||||
if myss.timeslot is None:
|
||||
continue
|
||||
if self.badness_test(3):
|
||||
self.badness_log(3, " [%u] 4group: %s my_sessions: %s vs %s\n" % (count, group.acronym, myss.timeslot.time, ss.timeslot.time))
|
||||
if ss.timeslot.time == myss.timeslot.time:
|
||||
newcost = constraint.constraint_cost()
|
||||
if self.badness_test(2):
|
||||
self.badness_log(2, " [%u] 5group: %s conflict(%s): %s on %s cost %u\n" % (count, self.group.acronym, constraint.name_id, ss.session.group.acronym, ss.timeslot.time, newcost))
|
||||
# yes accumulate badness.
|
||||
conflictbadness += newcost
|
||||
ss.badness = conflictbadness
|
||||
ss.save()
|
||||
badness += conflictbadness
|
||||
# done
|
||||
if self.badness_test(1):
|
||||
self.badness_log(1, "badgroup: %s badness = %u\n" % (self.group.acronym, badness))
|
||||
return badness
|
||||
|
||||
def setup_conflicts(self):
|
||||
log.unreachable()
|
||||
conflicts = self.unique_constraints()
|
||||
|
||||
self.session_conflicts = []
|
||||
|
||||
for group,constraint in conflicts.items():
|
||||
if group is None:
|
||||
# must not be a group constraint, people constraints TBD.
|
||||
continue
|
||||
|
||||
# get the list of sessions for other group.
|
||||
for session in self.meeting.session_set.filter(group = group):
|
||||
# make a tuple...
|
||||
conflict = (session.pk, constraint)
|
||||
self.session_conflicts.append(conflict)
|
||||
|
||||
# This evaluates the current session based upon the constraints
|
||||
# given. The conflicts have first been shorted into an array (session_conflicts)
|
||||
# as a tuple, and include the constraint itself.
|
||||
#
|
||||
# While the conflicts are listed by group, the conflicts listed here
|
||||
# have been resolved into pk of session requests that will conflict.
|
||||
# This is to make comparison be a straight integer comparison.
|
||||
#
|
||||
# scheduleslot contains the list of sessions which are at the same time as
|
||||
# this item.
|
||||
#
|
||||
# timeslot is where this item has been scheduled.
|
||||
#
|
||||
# MATH.
|
||||
# each failed conflic3 is worth 1000 points
|
||||
# each failed conflic2 is worth 10000 points
|
||||
# each failed conflic1 is worth 100000 points
|
||||
# being in a room too small than asked is worth 200,000 * (size/50)
|
||||
# being in a room too big by more than 100 is worth 200,000 once.
|
||||
# a conflict where AD must be in two places is worth 500,000.
|
||||
# not being scheduled is worth 10,000,000 points
|
||||
#
|
||||
def badness_fast(self, timeslot, scheduleslot, session_pk_list):
|
||||
log.unreachable()
|
||||
from settings import BADNESS_UNPLACED, BADNESS_TOOSMALL_50, BADNESS_TOOSMALL_100, BADNESS_TOOBIG, BADNESS_MUCHTOOBIG # pylint: disable=import-error
|
||||
|
||||
badness = 0
|
||||
|
||||
# see if item has not been scheduled
|
||||
if timeslot is None:
|
||||
return BADNESS_UNPLACED
|
||||
|
||||
# see if this session is in too small a place.
|
||||
if self.attendees is not None and timeslot.location.capacity is not None:
|
||||
mismatch = self.attendees - timeslot.location.capacity
|
||||
if mismatch > 100:
|
||||
# the room is too small by 100
|
||||
badness += BADNESS_TOOSMALL_100
|
||||
elif mismatch > 50:
|
||||
# the room is too small by 50
|
||||
badness += BADNESS_TOOSMALL_50
|
||||
elif mismatch < 50:
|
||||
# the room is too big by 50
|
||||
badness += BADNESS_TOOBIG
|
||||
elif mismatch < 100:
|
||||
# the room is too big by 100 (not intimate enough)
|
||||
badness += BADNESS_MUCHTOOBIG
|
||||
|
||||
# now go through scheduleslot items and see if any are conflicts
|
||||
# inner loop is the shorter one, usually max 8 rooms.
|
||||
for conflict in self.session_conflicts:
|
||||
for pkt in session_pk_list:
|
||||
pk = pkt[0]
|
||||
if pk == self.pk: # ignore conflicts with self.
|
||||
continue
|
||||
|
||||
if conflict[0] == pk:
|
||||
ss = pkt[1]
|
||||
if ss.timeslot is not None and ss.timeslot.location == timeslot.location:
|
||||
continue # ignore conflicts when two sessions in the same room
|
||||
constraint = conflict[1]
|
||||
badness += constraint.constraint_cost()
|
||||
|
||||
if self.badness_test(1):
|
||||
self.badness_log(1, "badgroup: %s badness = %u\n" % (self.group.acronym, badness))
|
||||
return badness
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ def send_mail_subj(request, to, frm, stemplate, template, context, *args, **kwar
|
|||
Send an email message, exactly as send_mail(), but the
|
||||
subject field is a template.
|
||||
'''
|
||||
unreachable() # 6.46.2
|
||||
unreachable() # 03 Mar 2017
|
||||
subject = render_to_string(stemplate, context ).replace("\n"," ").strip()
|
||||
return send_mail(request, to, frm, subject, template, context, *args, **kwargs)
|
||||
|
||||
|
|
|
@ -32,70 +32,17 @@
|
|||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import html5lib
|
||||
from datetime import datetime
|
||||
import urllib2
|
||||
from difflib import unified_diff
|
||||
from unittest.util import strclass
|
||||
|
||||
import django.test
|
||||
from django.db import connection
|
||||
from django.test.client import Client
|
||||
from django.conf import settings
|
||||
|
||||
import debug # pyflakes:ignore
|
||||
|
||||
real_database_name = settings.DATABASES["default"]["NAME"]
|
||||
|
||||
import traceback
|
||||
|
||||
class RealDatabaseTest:
|
||||
def setUpRealDatabase(self):
|
||||
self._original_testdb = self._getDatabaseName()
|
||||
newdb = real_database_name
|
||||
#print " Switching database from "+self._original_testdb+" to "+newdb
|
||||
self._setDatabaseName(newdb)
|
||||
|
||||
def tearDownRealDatabase(self):
|
||||
#curdb = self._getDatabaseName()
|
||||
#print " Switching database from "+curdb+" to "+self._original_testdb
|
||||
self._setDatabaseName(self._original_testdb)
|
||||
|
||||
def _getDatabaseName(self):
|
||||
return connection.settings_dict['NAME']
|
||||
|
||||
def _setDatabaseName(self, name):
|
||||
connection.close()
|
||||
django.conf.settings.DATABASES["default"]["NAME"] = name
|
||||
connection.settings_dict['NAME'] = name
|
||||
connection.cursor()
|
||||
|
||||
def read_testurls(filename):
|
||||
tuples = []
|
||||
file = open(filename)
|
||||
for line in file:
|
||||
line = line.strip()
|
||||
if line and not line.startswith('#'):
|
||||
line = line.split("#", 1)[0]
|
||||
urlspec = line.split()
|
||||
if len(urlspec) == 2:
|
||||
codes, testurl = urlspec
|
||||
goodurl = None
|
||||
elif len(urlspec) == 3:
|
||||
codes, testurl, goodurl = urlspec
|
||||
else:
|
||||
raise ValueError("Expected 'HTTP_CODE TESTURL [GOODURL]' in %s line, found '%s'." % (filename, line))
|
||||
|
||||
|
||||
codes = dict([ (item, "") for item in codes.split(",") if not":" in item] +
|
||||
[ (item.split(":")[:2]) for item in codes.split(",") if ":" in item] )
|
||||
tuples += [ (codes, testurl, goodurl) ]
|
||||
file.close()
|
||||
return tuples
|
||||
|
||||
def split_url(url):
|
||||
if "?" in url:
|
||||
url, args = url.split("?", 1)
|
||||
|
@ -104,156 +51,6 @@ def split_url(url):
|
|||
args = {}
|
||||
return url, args
|
||||
|
||||
class SimpleUrlTestCase(django.test.TestCase,RealDatabaseTest):
|
||||
|
||||
def setUp(self):
|
||||
self.setUpRealDatabase()
|
||||
self.client = Client()
|
||||
self.ref_prefix = os.environ.get("IETFDB_REF_PREFIX", "")
|
||||
if self.ref_prefix.endswith("/"):
|
||||
self.ref_prefix = self.ref_prefix[:-1]
|
||||
self.skip_heavy_tests = os.environ.get("IETFDB_SKIP_HEAVY", True)
|
||||
self.verbosity = os.environ.get("IETFDB_TESTURL_VERBOSITY", 1)
|
||||
|
||||
def tearDown(self):
|
||||
self.tearDownRealDatabase()
|
||||
|
||||
def doTestUrls(self, test_filename):
|
||||
if test_filename.endswith(".list"):
|
||||
filename = test_filename
|
||||
else:
|
||||
filename = os.path.dirname(os.path.abspath(test_filename))+"/testurl.list"
|
||||
if self.verbosity > 1:
|
||||
print " Reading "+filename
|
||||
tuples = read_testurls(filename)
|
||||
failures = 0
|
||||
for tuple in tuples:
|
||||
try:
|
||||
self.doTestUrl(tuple)
|
||||
except:
|
||||
failures = failures + 1
|
||||
self.assertEqual(failures, 0, "%d URLs failed" % failures)
|
||||
|
||||
def saveBadResponse(self, url, response):
|
||||
msg = "The %s page changed\n" % url
|
||||
url = url.lstrip('/')
|
||||
path = settings.TEST_DIFF_FAILURE_DIR
|
||||
path = os.path.join(path, url)
|
||||
if not os.path.exists(os.path.dirname(path)):
|
||||
os.makedirs(os.path.dirname(path))
|
||||
with open(path, "w") as file:
|
||||
file.write(response.content)
|
||||
msg += "The newly generated page has been saved at:\n %s" % path
|
||||
print msg
|
||||
return msg
|
||||
|
||||
def doTestUrl(self, tuple):
|
||||
(codes, url, master) = tuple
|
||||
baseurl, args = split_url(url)
|
||||
failed = False
|
||||
#enable this to see query counts
|
||||
#settings.DEBUG = True
|
||||
msg = None
|
||||
try:
|
||||
if "heavy" in codes and self.skip_heavy_tests:
|
||||
if self.verbosity > 1:
|
||||
print " Skipping heavy test %s" % (url,)
|
||||
else:
|
||||
sys.stdout.write('-')
|
||||
return
|
||||
now = datetime.utcnow()
|
||||
response = self.client.get(baseurl, args)
|
||||
elapsed_dt = datetime.utcnow()-now
|
||||
elapsed = elapsed_dt.seconds + elapsed_dt.microseconds/1e6
|
||||
code = str(response.status_code)
|
||||
queries = len(connection.queries)
|
||||
if self.verbosity == 1:
|
||||
if code in codes:
|
||||
sys.stdout.write(".")
|
||||
else:
|
||||
sys.stdout.write("F")
|
||||
failed = True
|
||||
elif self.verbosity > 1:
|
||||
if code in codes:
|
||||
print "OK %s %s" % (code, url)
|
||||
else:
|
||||
print "Fail %s %s" % (code, url)
|
||||
failed = True
|
||||
if queries > 0:
|
||||
print " (%.1f s, %d kB, %d queries)" % (elapsed, len(response.content)/1000, queries)
|
||||
else:
|
||||
print " (%.1f s, %d kB)" % (elapsed, len(response.content)/1000)
|
||||
if code in codes and code == "200":
|
||||
diff_result = self.doDiff(tuple, response)
|
||||
if diff_result == False:
|
||||
msg = self.saveBadResponse(url, response)
|
||||
failed = True
|
||||
except:
|
||||
failed = True
|
||||
msg = "Exception for URL '%s'" % url
|
||||
print msg
|
||||
traceback.print_exc()
|
||||
self.assertEqual(failed, False, msg)
|
||||
|
||||
# Override this in subclasses if needed
|
||||
def doCanonicalize(self, url, content):
|
||||
return content
|
||||
|
||||
def doDiff(self, tuple, response):
|
||||
(codes, url, master) = tuple
|
||||
if not self.ref_prefix and not master:
|
||||
return
|
||||
if "skipdiff" in codes:
|
||||
return
|
||||
if master:
|
||||
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(sys.modules["__main__"].__file__)))
|
||||
master = os.path.join(root_dir, master)
|
||||
mfile = open(master)
|
||||
refhtml = mfile.read()
|
||||
mfile.close()
|
||||
else:
|
||||
refurl = self.ref_prefix+url
|
||||
print " Fetching "+refurl
|
||||
refhtml = None
|
||||
try:
|
||||
mfile = urllib2.urlopen(refurl)
|
||||
refhtml = mfile.read()
|
||||
mfile.close()
|
||||
except Exception, e:
|
||||
print " Error retrieving %s: %s" % (refurl, e)
|
||||
return
|
||||
refhtml = self.doCanonicalize(url, refhtml)
|
||||
testhtml = self.doCanonicalize(url, response.content)
|
||||
|
||||
#print "REFERENCE:\n----------------------\n"+refhtml+"\n-------------\n"
|
||||
#print "TEST:\n----------------------\n"+testhtml+"\n-------------\n"
|
||||
|
||||
list0 = refhtml.split("\n")
|
||||
list1 = testhtml.split("\n")
|
||||
diff_list = list(unified_diff(list0, list1, master or refurl, url, "", "", 0, lineterm=""))
|
||||
if len(diff_list):
|
||||
if len(diff_list) > 10:
|
||||
print "\n Differences found. The list is too long to show in its entirety.\n Here are the first 10 lines:\n"
|
||||
print "\n".join(diff_list[:16])
|
||||
print "..."
|
||||
else:
|
||||
print "\n Differences found:"
|
||||
print "\n".join(unified_diff(list0, list1, master or refurl, url, "", "", 0, lineterm=""))
|
||||
return False
|
||||
|
||||
def canonicalize_feed(s):
|
||||
# Django 0.96 handled time zone different -- ignore it for now
|
||||
s = re.sub(r"(<updated>\d\d\d\d-\d\d-\d\dT)\d\d(:\d\d:\d\d)(Z|-08:00)(</updated>)",r"\g<1>00\g<2>Z\g<4>", s)
|
||||
# Insert newline before tags to make diff easier to read
|
||||
s = re.sub("\n*\s*(<[a-zA-Z])", "\n\g<1>", s)
|
||||
return s
|
||||
|
||||
def canonicalize_sitemap(s):
|
||||
s = re.sub("> <", "><", s)
|
||||
# Insert newline before tags to make diff easier to read
|
||||
s = re.sub("\n*\s*(<[a-zA-Z])", "\n\g<1>", s)
|
||||
return s
|
||||
|
||||
def login_testing_unauthorized(test_case, username, url, password=None):
|
||||
r = test_case.client.get(url)
|
||||
test_case.assertIn(r.status_code, (302, 403))
|
||||
|
|
Loading…
Reference in a new issue