|
12 | 12 | from StringIO import StringIO |
13 | 13 | from textwrap import dedent |
14 | 14 | from unittest import skipIf |
| 15 | +from tempfile import mkdtemp |
15 | 16 |
|
16 | 17 | from django.apps import apps |
17 | 18 | from django.contrib.auth.models import User |
|
25 | 26 |
|
26 | 27 | import debug # pyflakes:ignore |
27 | 28 |
|
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 |
29 | 32 | from ietf.utils.mail import send_mail_text, send_mail_mime, outbox |
| 33 | +from ietf.utils.management.commands import pyflakes |
30 | 34 | from ietf.utils.test_data import make_test_data |
31 | 35 | from ietf.utils.test_runner import get_template_paths, set_coverage_checking |
32 | 36 | from ietf.utils.test_utils import TestCase |
33 | | -from ietf.group.models import Group |
34 | 37 |
|
35 | 38 | skip_wiki_glue_testing = False |
36 | 39 | skip_message = "" |
@@ -333,3 +336,27 @@ def test_all_model_admins_exist(self): |
333 | 336 | # self.assertEqual(r.status_code, 200) |
334 | 337 |
|
335 | 338 |
|
| 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