Skip to content

Commit 4395949

Browse files
committed
Fixed up to use perma_fixtures instead of fixtures. Changed diff of html-agenda so it disregards the changing datatracker version information embedded in the html file. Changed dumping of agenda page results to file to not use a code constant, but instead happen if the test fails. Added an announcement of this to the test exception string.
- Legacy-Id: 6319
1 parent a07f47a commit 4395949

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

ietf/meeting/tests/view.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import re
22
import sys
33
from django.test.client import Client
4-
from django.test import TestCase
4+
from ietf.utils import TestCase
55
#from ietf.person.models import Person
66
from django.contrib.auth.models import User
77
from settings import BASE_DIR
@@ -11,10 +11,9 @@
1111
from django.core.urlresolvers import reverse
1212
from ietf.meeting.views import edit_agenda
1313

14-
capture_output = True
15-
1614
class ViewTestCase(TestCase):
17-
fixtures = [ 'names.xml', # ietf/names/fixtures/names.xml for MeetingTypeName, and TimeSlotTypeName
15+
# See ietf.utils.test_utils.TestCase for the use of perma_fixtures vs. fixtures
16+
perma_fixtures = [ 'names.xml', # ietf/names/fixtures/names.xml for MeetingTypeName, and TimeSlotTypeName
1817
'meeting83.json',
1918
'constraint83.json',
2019
'workinggroups.json',
@@ -28,24 +27,32 @@ def test_agenda83txt(self):
2827
agenda83txt = agenda83txtio.read(); # read entire file
2928
resp = self.client.get('/meeting/83/agenda.txt')
3029
# to capture new output (and check it for correctness)
31-
if capture_output:
32-
out = open("%s/meeting/tests/agenda-83-txt-output-out.txt" % BASE_DIR, "w")
30+
fn = ""
31+
if resp.content != agenda83.txt:
32+
fn = "%s/meeting/tests/agenda-83-txt-output-out.txt" % BASE_DIR
33+
out = open(fn, "w")
3334
out.write(resp.content)
3435
out.close()
35-
self.assertEqual(resp.content, agenda83txt, "agenda83 txt changed")
36+
self.assertEqual(resp.content, agenda83txt, "The /meeting/83/agenda.txt page changed.\nThe newly generated agenda has been written to file: %s" % fn)
3637

3738
def test_agenda83utc(self):
3839
# verify that the generated html has not changed.
3940
import io
4041
agenda83utcio = open("%s/meeting/tests/agenda-83-utc-output.html" % BASE_DIR, "r")
41-
agenda83utc = agenda83utcio.read(); # read entire file
42+
agenda83utc_valid = agenda83utcio.read(); # read entire file
4243
resp = self.client.get('/meeting/83/agenda-utc.html')
43-
# to capture new output (and check it for correctness set capture_output above)
44-
if capture_output:
45-
out = open("%s/meeting/tests/agenda-83-utc-output-out.html" % BASE_DIR, "w")
44+
# both agendas will have a software version indication inside a
45+
# comment. This will change. Remove comments before comparing.
46+
agenda83utc_valid = re.sub("<!-- v.*-->","", agenda83utc_valid)
47+
agenda83utc_response = re.sub("<!-- v.*-->","", resp.content)
48+
fn = ""
49+
# to capture new output (and check it for correctness)
50+
if agenda83utc_valid != agenda83utc_response:
51+
fn = "%s/meeting/tests/agenda-83-utc-output-out.html" % BASE_DIR
52+
out = open(fn, "w")
4653
out.write(resp.content)
4754
out.close()
48-
self.assertEqual(resp.content, agenda83utc, "agenda83 utc changed")
55+
self.assertEqual(agenda83utc_valid, agenda83utc_response, "The /meeting/83/agenda-utc.html page changed.\nThe newly generated agenda has been written to file: %s" % fn)
4956

5057
def test_nameOfClueWg(self):
5158
clue_session = Session.objects.get(pk=2194)

0 commit comments

Comments
 (0)