Skip to content

Commit a708bdf

Browse files
committed
Refactored out a new test case DrafTestCase in order to re-use it to set up test directories with draft content, and updated the StatisticsTest to subclass it.
- Legacy-Id: 18783
1 parent 774e752 commit a708bdf

3 files changed

Lines changed: 203 additions & 194 deletions

File tree

ietf/doc/tests.py

Lines changed: 8 additions & 189 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22
# -*- coding: utf-8 -*-
33

44

5-
import os
6-
import shutil
5+
import bibtexparser
76
import datetime
8-
import io
97
import lxml
8+
import os
109
import sys
11-
import bibtexparser
1210

1311
if sys.version_info[0] == 2 and sys.version_info[1] < 7:
1412
import unittest2 as unittest
@@ -45,7 +43,7 @@
4543
from ietf.person.factories import PersonFactory
4644
from ietf.utils.mail import outbox
4745
from ietf.utils.test_utils import login_testing_unauthorized, unicontent
48-
from ietf.utils.test_utils import TestCase
46+
from ietf.utils.test_utils import TestCase, DraftTestCase
4947
from ietf.utils.text import normalize_text
5048
from ietf.utils.timezone import datetime_today
5149

@@ -339,191 +337,12 @@ def test_recent_drafts(self):
339337
self.assertEqual(q('td.status span.label-warning').text(),"for 15 days")
340338
self.assertEqual(q('td.status span.label-danger').text(),"for 29 days")
341339

342-
class DocDraftTestCase(TestCase):
343-
draft_text = """
344-
345-
346-
347-
Martian Special Interest Group (mars) P. Man
348-
Internet-Draft March 21, 2015
349-
Intended status: Informational
350-
Expires: September 22, 2015
351-
352-
353-
Optimizing Martian Network Topologies
354-
draft-ietf-mars-test-02.txt
355-
356-
Abstract
357-
358-
Techniques for achieving near-optimal Martian networks.
359-
360-
Status of This Memo
361-
362-
This Internet-Draft is submitted in full conformance with the
363-
provisions of BCP 78 and BCP 79.
364-
365-
Internet-Drafts are working documents of the Internet Engineering
366-
Task Force (IETF). Note that other groups may also distribute
367-
working documents as Internet-Drafts. The list of current Internet-
368-
Drafts is at http://datatracker.ietf.org/drafts/current/.
369-
370-
Internet-Drafts are draft documents valid for a maximum of six months
371-
and may be updated, replaced, or obsoleted by other documents at any
372-
time. It is inappropriate to use Internet-Drafts as reference
373-
material or to cite them other than as "work in progress."
374-
375-
This Internet-Draft will expire on September 22, 2015.
376-
377-
Copyright Notice
378-
379-
Copyright (c) 2015 IETF Trust and the persons identified as the
380-
document authors. All rights reserved.
381-
382-
This document is subject to BCP 78 and the IETF Trust's Legal
383-
Provisions Relating to IETF Documents
384-
(http://trustee.ietf.org/license-info) in effect on the date of
385-
publication of this document. Please review these documents
386-
carefully, as they describe your rights and restrictions with respect
387-
to this document. Code Components extracted from this document must
388-
include Simplified BSD License text as described in Section 4.e of
389-
the Trust Legal Provisions and are provided without warranty as
390-
described in the Simplified BSD License.
391-
392-
This document may contain material from IETF Documents or IETF
393-
Contributions published or made publicly available before November
394-
10, 2008. The person(s) controlling the copyright in some of this
395-
396-
397-
398-
Man Expires September 22, 2015 [Page 1]
399-
400-
Internet-Draft Optimizing Martian Network Topologies March 2015
401-
402-
403-
material may not have granted the IETF Trust the right to allow
404-
modifications of such material outside the IETF Standards Process.
405-
Without obtaining an adequate license from the person(s) controlling
406-
the copyright in such materials, this document may not be modified
407-
outside the IETF Standards Process, and derivative works of it may
408-
not be created outside the IETF Standards Process, except to format
409-
it for publication as an RFC or to translate it into languages other
410-
than English.
411-
412-
Table of Contents
413-
414-
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
415-
2. Security Considerations . . . . . . . . . . . . . . . . . . . 2
416-
3. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 2
417-
4. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 3
418-
5. Normative References . . . . . . . . . . . . . . . . . . . . 3
419-
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 3
420-
421-
1. Introduction
422-
423-
This document describes how to make the Martian networks work. The
424-
methods used in Earth do not directly translate to the efficent
425-
networks on Mars, as the topographical differences caused by planets.
426-
For example the avian carriers, cannot be used in the Mars, thus
427-
RFC1149 ([RFC1149]) cannot be used in Mars.
428-
429-
Some optimizations can be done because Mars is smaller than Earth,
430-
thus the round trip times are smaller. Also as Mars has two moons
431-
instead of only one as we have in Earth, we can use both Deimos and
432-
Phobos when using reflecting radio links off the moon.
433-
434-
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
435-
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
436-
document are to be interpreted as described in [RFC2119].
437-
438-
2. Security Considerations
439-
440-
As Martians are known to listen all traffic in Mars, all traffic in
441-
the Mars MUST be encrypted.
442-
443-
3. IANA Considerations
444-
445-
There is no new IANA considerations in this document.
446-
447-
448-
449-
450-
451-
452-
453-
454-
Man Expires September 22, 2015 [Page 2]
455-
456-
Internet-Draft Optimizing Martian Network Topologies March 2015
340+
class DocDraftTestCase(DraftTestCase):
341+
"""
342+
Inherits from DraftTestCase, which provides .setUp() and .tearDown()
343+
methods that handles set-up needed by the tests below.
457344
458-
459-
4. Acknowledgements
460-
461-
This document is created in the IETF-92 CodeSprint in Dallas, TX.
462-
463-
5. Normative References
464-
465-
[RFC1149] Waitzman, D., "Standard for the transmission of IP
466-
datagrams on avian carriers", RFC 1149, April 1990.
467-
468-
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
469-
Requirement Levels", BCP 14, RFC 2119, March 1997.
470-
471-
Author's Address
472-
473-
Plain Man
474-
Deimos street
475-
Mars City MARS-000000
476-
Mars
477-
478-
Email: aliens@example.mars
479-
480-
481-
482-
483-
484-
485-
486-
487-
488-
489-
490-
491-
492-
493-
494-
495-
496-
497-
498-
499-
500-
501-
502-
503-
504-
505-
506-
507-
508-
509-
510-
Man Expires September 22, 2015 [Page 3]
511-
"""
512-
513-
def setUp(self):
514-
self.id_dir = self.tempdir('id')
515-
self.saved_internet_draft_path = settings.INTERNET_DRAFT_PATH
516-
settings.INTERNET_DRAFT_PATH = self.id_dir
517-
self.saved_internet_all_drafts_archive_dir = settings.INTERNET_ALL_DRAFTS_ARCHIVE_DIR
518-
settings.INTERNET_ALL_DRAFTS_ARCHIVE_DIR = self.id_dir
519-
f = io.open(os.path.join(self.id_dir, 'draft-ietf-mars-test-01.txt'), 'w')
520-
f.write(self.draft_text)
521-
f.close()
522-
523-
def tearDown(self):
524-
settings.INTERNET_ALL_DRAFTS_ARCHIVE_DIR = self.saved_internet_all_drafts_archive_dir
525-
settings.INTERNET_DRAFT_PATH = self.saved_internet_draft_path
526-
shutil.rmtree(self.id_dir)
345+
"""
527346

528347
def test_document_draft(self):
529348
draft = WgDraftFactory(name='draft-ietf-mars-test',rev='01')

ietf/stats/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from django.contrib.auth.models import User
1717
from django.utils import timezone
1818

19-
from ietf.utils.test_utils import login_testing_unauthorized, TestCase
19+
from ietf.utils.test_utils import login_testing_unauthorized, DraftTestCase
2020
import ietf.stats.views
2121

2222
from ietf.submit.models import Submission
@@ -33,7 +33,7 @@
3333
from ietf.utils.timezone import datetime_today_start
3434

3535

36-
class StatisticsTests(TestCase):
36+
class StatisticsTests(DraftTestCase):
3737
def test_stats_index(self):
3838
url = urlreverse(ietf.stats.views.stats_index)
3939
r = self.client.get(url)

0 commit comments

Comments
 (0)