Skip to content

Commit 7f5fd62

Browse files
committed
Add simple test for ID submission, needs more extensive checking
- Legacy-Id: 3416
1 parent a695aaf commit 7f5fd62

3 files changed

Lines changed: 197 additions & 0 deletions

File tree

ietf/submit/test_submission.txt

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
Informational Test Name
2+
Internet-Draft Test Center Inc.
3+
Intended status: Informational
4+
Expires: %(expire)s %(date)s
5+
6+
7+
Testing tests
8+
%(filename)s
9+
10+
11+
Abstract
12+
13+
This document describes how to test tests.
14+
15+
Status of this Memo
16+
17+
This Internet-Draft is submitted in full conformance with the
18+
provisions of BCP 78 and BCP 79. This document may not be modified,
19+
and derivative works of it may not be created, and it may not be
20+
published except as an Internet-Draft.
21+
22+
Internet-Drafts are working documents of the Internet Engineering
23+
Task Force (IETF). Note that other groups may also distribute
24+
working documents as Internet-Drafts. The list of current Internet-
25+
Drafts is at http://datatracker.ietf.org/drafts/current/.
26+
27+
Internet-Drafts are draft documents valid for a maximum of six months
28+
and may be updated, replaced, or obsoleted by other documents at any
29+
time. It is inappropriate to use Internet-Drafts as reference
30+
material or to cite them other than as "work in progress."
31+
32+
This Internet-Draft will expire on %(expire)s.
33+
34+
Copyright Notice
35+
36+
Copyright (c) %(year)s IETF Trust and the persons identified as the
37+
document authors. All rights reserved.
38+
39+
This document is subject to BCP 78 and the IETF Trust's Legal
40+
Provisions Relating to IETF Documents
41+
(http://trustee.ietf.org/license-info) in effect on the date of
42+
publication of this document. Please review these documents
43+
carefully, as they describe your rights and restrictions with respect
44+
to this document.
45+
46+
This Informational Internet Draft is submitted as an RFC Editor
47+
48+
49+
50+
Name Expires %(expire)s [Page 1]
51+
52+
Internet-Draft Testing tests %(month_year)s
53+
54+
Contribution and/or non-IETF Document (not as a Contribution, IETF
55+
Contribution, nor IETF Document) in accordance with BCP 78 and BCP
56+
79.
57+
58+
59+
Table of Contents
60+
61+
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4
62+
63+
64+
65+
66+
67+
68+
69+
70+
71+
72+
73+
74+
75+
76+
77+
78+
79+
80+
81+
82+
83+
84+
85+
86+
87+
88+
89+
90+
91+
92+
93+
94+
95+
96+
97+
98+
99+
100+
101+
102+
103+
104+
105+
106+
Name Expires %(expire)s [Page 2]
107+
108+
Internet-Draft Testing tests %(month_year)s
109+
110+
1. Introduction
111+
112+
This document describes a protocol for testing tests.
113+

ietf/submit/tests.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import datetime, os, shutil
2+
3+
from django.conf import settings
4+
from django.contrib.auth.models import User
5+
from django.core.urlresolvers import reverse as urlreverse
6+
import django.test
7+
from StringIO import StringIO
8+
from pyquery import PyQuery
9+
10+
from ietf.utils.test_utils import login_testing_unauthorized
11+
from ietf.utils.test_runner import mail_outbox
12+
from ietf.utils.test_data import make_test_data
13+
14+
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
15+
from redesign.person.models import Person, Email
16+
from redesign.group.models import Group, Role
17+
from redesign.doc.models import Document
18+
19+
class SubmitTestCase(django.test.TestCase):
20+
fixtures = ['names']
21+
22+
def setUp(self):
23+
self.staging_dir = os.path.abspath("tmp-submit-staging-dir")
24+
os.mkdir(self.staging_dir)
25+
26+
settings.IDSUBMIT_STAGING_PATH = self.staging_dir
27+
28+
def tearDown(self):
29+
shutil.rmtree(self.staging_dir)
30+
31+
def test_submit(self):
32+
# break early in case of missing configuration
33+
self.assertTrue(os.path.exists(settings.IDSUBMIT_IDNITS_BINARY))
34+
35+
draft = make_test_data()
36+
37+
url = urlreverse('submit_index')
38+
39+
# get
40+
r = self.client.get(url)
41+
self.assertEquals(r.status_code, 200)
42+
q = PyQuery(r.content)
43+
self.assertEquals(len(q('input[type=file][name=txt]')), 1)
44+
45+
# submit text draft
46+
filename = "draft-mars-testing-tests-00"
47+
48+
# construct appropriate text file
49+
f = open(os.path.join(settings.BASE_DIR, "submit", "test_submission.txt"))
50+
template = f.read()
51+
f.close()
52+
submission_text = template % dict(
53+
date=datetime.date.today().strftime("%Y-%m-%d"),
54+
expire=(datetime.date.today() + datetime.timedelta(days=100)).strftime("%Y-%m-%d"),
55+
year=datetime.date.today().strftime("%Y"),
56+
month_year=datetime.date.today().strftime("%B, %Y"),
57+
filename=filename,
58+
)
59+
60+
test_file = StringIO(submission_text)
61+
test_file.name = "somename.txt"
62+
63+
r = self.client.post(url,
64+
dict(txt=test_file))
65+
self.assertEquals(r.status_code, 302)
66+
self.assertTrue(os.path.exists(os.path.join(self.staging_dir, filename + ".txt")))
67+
68+
69+
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
70+
# the above tests only work with the new schema
71+
del SubmitTestCase

ietf/utils/test_data.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from ietf.iesg.models import TelechatDates, WGAction
44
from ietf.ipr.models import IprDetail, IprDocAlias
5+
from ietf.meeting.models import Meeting
56
from redesign.doc.models import *
67
from redesign.name.models import *
78
from redesign.group.models import *
@@ -221,5 +222,17 @@ def make_test_data():
221222
category=13,
222223
telechat_date=dates.date2
223224
)
225+
226+
# Meeting
227+
Meeting.objects.create(
228+
number="42",
229+
type_id="ietf",
230+
date=datetime.date.today() + datetime.timedelta(days=180),
231+
city="New York",
232+
country="United States",
233+
time_zone="US/Eastern",
234+
break_area="Lounge",
235+
reg_area="Lobby",
236+
)
224237

225238
return draft

0 commit comments

Comments
 (0)