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
This commit is contained in:
Henrik Levkowetz 2020-12-19 22:42:36 +00:00
parent 774e752a54
commit a708bdf895
3 changed files with 205 additions and 196 deletions

View file

@ -2,13 +2,11 @@
# -*- coding: utf-8 -*-
import os
import shutil
import datetime
import io
import lxml
import sys
import bibtexparser
import datetime
import lxml
import os
import sys
if sys.version_info[0] == 2 and sys.version_info[1] < 7:
import unittest2 as unittest
@ -45,7 +43,7 @@ from ietf.person.models import Person
from ietf.person.factories import PersonFactory
from ietf.utils.mail import outbox
from ietf.utils.test_utils import login_testing_unauthorized, unicontent
from ietf.utils.test_utils import TestCase
from ietf.utils.test_utils import TestCase, DraftTestCase
from ietf.utils.text import normalize_text
from ietf.utils.timezone import datetime_today
@ -339,191 +337,12 @@ class SearchTests(TestCase):
self.assertEqual(q('td.status span.label-warning').text(),"for 15 days")
self.assertEqual(q('td.status span.label-danger').text(),"for 29 days")
class DocDraftTestCase(TestCase):
draft_text = """
Martian Special Interest Group (mars) P. Man
Internet-Draft March 21, 2015
Intended status: Informational
Expires: September 22, 2015
Optimizing Martian Network Topologies
draft-ietf-mars-test-02.txt
Abstract
Techniques for achieving near-optimal Martian networks.
Status of This Memo
This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."
This Internet-Draft will expire on September 22, 2015.
Copyright Notice
Copyright (c) 2015 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.
This document may contain material from IETF Documents or IETF
Contributions published or made publicly available before November
10, 2008. The person(s) controlling the copyright in some of this
Man Expires September 22, 2015 [Page 1]
Internet-Draft Optimizing Martian Network Topologies March 2015
material may not have granted the IETF Trust the right to allow
modifications of such material outside the IETF Standards Process.
Without obtaining an adequate license from the person(s) controlling
the copyright in such materials, this document may not be modified
outside the IETF Standards Process, and derivative works of it may
not be created outside the IETF Standards Process, except to format
it for publication as an RFC or to translate it into languages other
than English.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
2. Security Considerations . . . . . . . . . . . . . . . . . . . 2
3. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 2
4. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 3
5. Normative References . . . . . . . . . . . . . . . . . . . . 3
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 3
1. Introduction
This document describes how to make the Martian networks work. The
methods used in Earth do not directly translate to the efficent
networks on Mars, as the topographical differences caused by planets.
For example the avian carriers, cannot be used in the Mars, thus
RFC1149 ([RFC1149]) cannot be used in Mars.
Some optimizations can be done because Mars is smaller than Earth,
thus the round trip times are smaller. Also as Mars has two moons
instead of only one as we have in Earth, we can use both Deimos and
Phobos when using reflecting radio links off the moon.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in [RFC2119].
2. Security Considerations
As Martians are known to listen all traffic in Mars, all traffic in
the Mars MUST be encrypted.
3. IANA Considerations
There is no new IANA considerations in this document.
Man Expires September 22, 2015 [Page 2]
Internet-Draft Optimizing Martian Network Topologies March 2015
4. Acknowledgements
This document is created in the IETF-92 CodeSprint in Dallas, TX.
5. Normative References
[RFC1149] Waitzman, D., "Standard for the transmission of IP
datagrams on avian carriers", RFC 1149, April 1990.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, March 1997.
Author's Address
Plain Man
Deimos street
Mars City MARS-000000
Mars
Email: aliens@example.mars
Man Expires September 22, 2015 [Page 3]
class DocDraftTestCase(DraftTestCase):
"""
Inherits from DraftTestCase, which provides .setUp() and .tearDown()
methods that handles set-up needed by the tests below.
def setUp(self):
self.id_dir = self.tempdir('id')
self.saved_internet_draft_path = settings.INTERNET_DRAFT_PATH
settings.INTERNET_DRAFT_PATH = self.id_dir
self.saved_internet_all_drafts_archive_dir = settings.INTERNET_ALL_DRAFTS_ARCHIVE_DIR
settings.INTERNET_ALL_DRAFTS_ARCHIVE_DIR = self.id_dir
f = io.open(os.path.join(self.id_dir, 'draft-ietf-mars-test-01.txt'), 'w')
f.write(self.draft_text)
f.close()
def tearDown(self):
settings.INTERNET_ALL_DRAFTS_ARCHIVE_DIR = self.saved_internet_all_drafts_archive_dir
settings.INTERNET_DRAFT_PATH = self.saved_internet_draft_path
shutil.rmtree(self.id_dir)
"""
def test_document_draft(self):
draft = WgDraftFactory(name='draft-ietf-mars-test',rev='01')

View file

@ -16,7 +16,7 @@ from django.urls import reverse as urlreverse
from django.contrib.auth.models import User
from django.utils import timezone
from ietf.utils.test_utils import login_testing_unauthorized, TestCase
from ietf.utils.test_utils import login_testing_unauthorized, DraftTestCase
import ietf.stats.views
from ietf.submit.models import Submission
@ -33,7 +33,7 @@ from ietf.stats.utils import get_meeting_registration_data
from ietf.utils.timezone import datetime_today_start
class StatisticsTests(TestCase):
class StatisticsTests(DraftTestCase):
def test_stats_index(self):
url = urlreverse(ietf.stats.views.stats_index)
r = self.client.get(url)

View file

@ -34,11 +34,13 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os
import re
import email
import html5lib
import inspect
import io
import os
import re
import shutil
import sys
from urllib.parse import unquote
@ -240,5 +242,193 @@ class TestCase(django.test.TestCase):
fn = caller.function + '.html'
with open(fn, 'bw') as f:
f.write(r.content)
if sys.stderr.isatty():
sys.stderr.write(f'Wrote response to {fn}\n')
class DraftTestCase(TestCase):
draft_text = """
Martian Special Interest Group (mars) P. Man
Internet-Draft March 21, 2015
Intended status: Informational
Expires: September 22, 2015
Optimizing Martian Network Topologies
draft-ietf-mars-test-02.txt
Abstract
Techniques for achieving near-optimal Martian networks.
Status of This Memo
This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."
This Internet-Draft will expire on September 22, 2015.
Copyright Notice
Copyright (c) 2015 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.
This document may contain material from IETF Documents or IETF
Contributions published or made publicly available before November
10, 2008. The person(s) controlling the copyright in some of this
Man Expires September 22, 2015 [Page 1]
Internet-Draft Optimizing Martian Network Topologies March 2015
material may not have granted the IETF Trust the right to allow
modifications of such material outside the IETF Standards Process.
Without obtaining an adequate license from the person(s) controlling
the copyright in such materials, this document may not be modified
outside the IETF Standards Process, and derivative works of it may
not be created outside the IETF Standards Process, except to format
it for publication as an RFC or to translate it into languages other
than English.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
2. Security Considerations . . . . . . . . . . . . . . . . . . . 2
3. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 2
4. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 3
5. Normative References . . . . . . . . . . . . . . . . . . . . 3
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 3
1. Introduction
This document describes how to make the Martian networks work. The
methods used in Earth do not directly translate to the efficent
networks on Mars, as the topographical differences caused by planets.
For example the avian carriers, cannot be used in the Mars, thus
RFC1149 ([RFC1149]) cannot be used in Mars.
Some optimizations can be done because Mars is smaller than Earth,
thus the round trip times are smaller. Also as Mars has two moons
instead of only one as we have in Earth, we can use both Deimos and
Phobos when using reflecting radio links off the moon.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in [RFC2119].
2. Security Considerations
As Martians are known to listen all traffic in Mars, all traffic in
the Mars MUST be encrypted.
3. IANA Considerations
There is no new IANA considerations in this document.
Man Expires September 22, 2015 [Page 2]
Internet-Draft Optimizing Martian Network Topologies March 2015
4. Acknowledgements
This document is created in the IETF-92 CodeSprint in Dallas, TX.
5. Normative References
[RFC1149] Waitzman, D., "Standard for the transmission of IP
datagrams on avian carriers", RFC 1149, April 1990.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119, March 1997.
Author's Address
Plain Man
Deimos street
Mars City MARS-000000
Mars
Email: aliens@example.mars
Man Expires September 22, 2015 [Page 3]
"""
def setUp(self):
self.id_dir = self.tempdir('id')
self.saved_internet_draft_path = settings.INTERNET_DRAFT_PATH
settings.INTERNET_DRAFT_PATH = self.id_dir
self.saved_internet_all_drafts_archive_dir = settings.INTERNET_ALL_DRAFTS_ARCHIVE_DIR
settings.INTERNET_ALL_DRAFTS_ARCHIVE_DIR = self.id_dir
f = io.open(os.path.join(self.id_dir, 'draft-ietf-mars-test-01.txt'), 'w')
f.write(self.draft_text)
f.close()
def tearDown(self):
settings.INTERNET_ALL_DRAFTS_ARCHIVE_DIR = self.saved_internet_all_drafts_archive_dir
settings.INTERNET_DRAFT_PATH = self.saved_internet_draft_path
shutil.rmtree(self.id_dir)