Add simple test for ID submission, needs more extensive checking

- Legacy-Id: 3416
This commit is contained in:
Ole Laursen 2011-09-05 17:14:47 +00:00
parent a695aaff2f
commit 7f5fd62a3d
3 changed files with 197 additions and 0 deletions

View file

@ -0,0 +1,113 @@
Informational Test Name
Internet-Draft Test Center Inc.
Intended status: Informational
Expires: %(expire)s %(date)s
Testing tests
%(filename)s
Abstract
This document describes how to test tests.
Status of this Memo
This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79. This document may not be modified,
and derivative works of it may not be created, and it may not be
published except as an Internet-Draft.
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 %(expire)s.
Copyright Notice
Copyright (c) %(year)s 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.
This Informational Internet Draft is submitted as an RFC Editor
Name Expires %(expire)s [Page 1]
Internet-Draft Testing tests %(month_year)s
Contribution and/or non-IETF Document (not as a Contribution, IETF
Contribution, nor IETF Document) in accordance with BCP 78 and BCP
79.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 4
Name Expires %(expire)s [Page 2]
Internet-Draft Testing tests %(month_year)s
1. Introduction
This document describes a protocol for testing tests.

71
ietf/submit/tests.py Normal file
View file

@ -0,0 +1,71 @@
import datetime, os, shutil
from django.conf import settings
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse as urlreverse
import django.test
from StringIO import StringIO
from pyquery import PyQuery
from ietf.utils.test_utils import login_testing_unauthorized
from ietf.utils.test_runner import mail_outbox
from ietf.utils.test_data import make_test_data
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
from redesign.person.models import Person, Email
from redesign.group.models import Group, Role
from redesign.doc.models import Document
class SubmitTestCase(django.test.TestCase):
fixtures = ['names']
def setUp(self):
self.staging_dir = os.path.abspath("tmp-submit-staging-dir")
os.mkdir(self.staging_dir)
settings.IDSUBMIT_STAGING_PATH = self.staging_dir
def tearDown(self):
shutil.rmtree(self.staging_dir)
def test_submit(self):
# break early in case of missing configuration
self.assertTrue(os.path.exists(settings.IDSUBMIT_IDNITS_BINARY))
draft = make_test_data()
url = urlreverse('submit_index')
# get
r = self.client.get(url)
self.assertEquals(r.status_code, 200)
q = PyQuery(r.content)
self.assertEquals(len(q('input[type=file][name=txt]')), 1)
# submit text draft
filename = "draft-mars-testing-tests-00"
# construct appropriate text file
f = open(os.path.join(settings.BASE_DIR, "submit", "test_submission.txt"))
template = f.read()
f.close()
submission_text = template % dict(
date=datetime.date.today().strftime("%Y-%m-%d"),
expire=(datetime.date.today() + datetime.timedelta(days=100)).strftime("%Y-%m-%d"),
year=datetime.date.today().strftime("%Y"),
month_year=datetime.date.today().strftime("%B, %Y"),
filename=filename,
)
test_file = StringIO(submission_text)
test_file.name = "somename.txt"
r = self.client.post(url,
dict(txt=test_file))
self.assertEquals(r.status_code, 302)
self.assertTrue(os.path.exists(os.path.join(self.staging_dir, filename + ".txt")))
if not settings.USE_DB_REDESIGN_PROXY_CLASSES:
# the above tests only work with the new schema
del SubmitTestCase

View file

@ -2,6 +2,7 @@ from django.contrib.auth.models import User
from ietf.iesg.models import TelechatDates, WGAction
from ietf.ipr.models import IprDetail, IprDocAlias
from ietf.meeting.models import Meeting
from redesign.doc.models import *
from redesign.name.models import *
from redesign.group.models import *
@ -221,5 +222,17 @@ def make_test_data():
category=13,
telechat_date=dates.date2
)
# Meeting
Meeting.objects.create(
number="42",
type_id="ietf",
date=datetime.date.today() + datetime.timedelta(days=180),
city="New York",
country="United States",
time_zone="US/Eastern",
break_area="Lounge",
reg_area="Lobby",
)
return draft