Skip to content

Commit a485c74

Browse files
committed
Merged in [14880] from rjsparks@nostrum.com:
Added a Draft test suite. - Legacy-Id: 14901 Note: SVN reference [14880] has been migrated to Git commit e09a28c
1 parent c8ebcf1 commit a485c74

2 files changed

Lines changed: 31 additions & 4 deletions

File tree

ietf/utils/draft.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,8 +1125,8 @@ def old_get_refs( self ):
11251125
refline = None
11261126
for i in range(len(self.lines)-1, 15, -1):
11271127
if re.search(r"(?i)^ *[0-9.]+ *(((normative|informative|informational|non-normative) )?references|references\W+(normative|informative))", self.lines[i]):
1128-
refline = i
1129-
break
1128+
if not '. . .' in self.lines[i] and not '...' in self.lines[i]:
1129+
refline = i
11301130
if refline:
11311131
for i in range(refline, len(self.lines)):
11321132
line = self.lines[i].strip()

ietf/utils/tests.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from StringIO import StringIO
1313
from textwrap import dedent
1414
from unittest import skipIf
15+
from tempfile import mkdtemp
1516

1617
from django.apps import apps
1718
from django.contrib.auth.models import User
@@ -25,12 +26,14 @@
2526

2627
import debug # pyflakes:ignore
2728

28-
from ietf.utils.management.commands import pyflakes
29+
from ietf.group.models import Group
30+
from ietf.submit.tests import submission_file
31+
from ietf.utils.draft import Draft, getmeta
2932
from ietf.utils.mail import send_mail_text, send_mail_mime, outbox
33+
from ietf.utils.management.commands import pyflakes
3034
from ietf.utils.test_data import make_test_data
3135
from ietf.utils.test_runner import get_template_paths, set_coverage_checking
3236
from ietf.utils.test_utils import TestCase
33-
from ietf.group.models import Group
3437

3538
skip_wiki_glue_testing = False
3639
skip_message = ""
@@ -333,3 +336,27 @@ def test_all_model_admins_exist(self):
333336
# self.assertEqual(r.status_code, 200)
334337

335338

339+
class DraftTests(TestCase):
340+
341+
def setUp(self):
342+
file,_ = submission_file(name='draft-test-draft-class',rev='00',format='txt',templatename='test_submission.txt',group=None)
343+
self.draft = Draft(text=file.getvalue(),source='draft-test-draft-class-00.txt',name_from_source=False)
344+
345+
def test_get_status(self):
346+
self.assertEqual(self.draft.get_status(),'Informational')
347+
348+
def test_get_authors(self):
349+
self.assertTrue(all([u'@' in author for author in self.draft.get_authors()]))
350+
351+
def test_get_authors_with_firm(self):
352+
self.assertTrue(all([u'@' in author for author in self.draft.get_authors_with_firm()]))
353+
354+
def test_old_get_refs(self):
355+
self.assertEqual(self.draft.old_get_refs()[1][0],u'rfc2119')
356+
357+
def test_get_meta(self):
358+
tempdir = mkdtemp()
359+
filename = os.path.join(tempdir,self.draft.source)
360+
with open(filename,'w') as file:
361+
file.write(self.draft.text)
362+
self.assertEqual(getmeta(filename)['docdeststatus'],'Informational')

0 commit comments

Comments
 (0)