|
| 1 | +import os |
1 | 2 | import datetime |
2 | 3 | import sys |
3 | 4 | if sys.version_info[0] == 2 and sys.version_info[1] < 7: |
4 | 5 | import unittest2 as unittest |
5 | 6 | else: |
6 | 7 | import unittest |
7 | 8 | from pyquery import PyQuery |
| 9 | +from tempfile import NamedTemporaryFile |
8 | 10 |
|
9 | 11 | from django.core.urlresolvers import reverse as urlreverse |
| 12 | +from django.conf import settings |
10 | 13 |
|
11 | 14 | from ietf.doc.models import ( Document, DocAlias, DocRelationshipName, RelatedDocument, State, |
12 | 15 | DocEvent, BallotPositionDocEvent, LastCallDocEvent, WriteupDocEvent, save_document_in_history ) |
@@ -472,3 +475,46 @@ def test_references(self): |
472 | 475 | self.assertEquals(r.status_code, 200) |
473 | 476 | self.assertTrue(doc1.name in r.content) |
474 | 477 |
|
| 478 | + |
| 479 | +class EmailAliasesTests(TestCase): |
| 480 | + |
| 481 | + def setUp(self): |
| 482 | + make_test_data() |
| 483 | + self.doc_alias_file = NamedTemporaryFile(delete=False) |
| 484 | + self.doc_alias_file.write("""# Generated by hand at 2015-02-12_16:26:45 |
| 485 | +virtual.ietf.org anything |
| 486 | +draft-ietf-mars-test@ietf.org xfilter-draft-ietf-mars-test |
| 487 | +expand-draft-ietf-mars-test@virtual.ietf.org mars-author@example.com, mars-collaborator@example.com |
| 488 | +draft-ietf-mars-test.authors@ietf.org xfilter-draft-ietf-mars-test.authors |
| 489 | +expand-draft-ietf-mars-test.authors@virtual.ietf.org mars-author@example.mars, mars-collaborator@example.mars |
| 490 | +draft-ietf-mars-test.chairs@ietf.org xfilter-draft-ietf-mars-test.chairs |
| 491 | +expand-draft-ietf-mars-test.chairs@virtual.ietf.org mars-chair@example.mars |
| 492 | +draft-ietf-mars-test.all@ietf.org xfilter-draft-ietf-mars-test.all |
| 493 | +expand-draft-ietf-mars-test.all@virtual.ietf.org mars-author@example.mars, mars-collaborator@example.mars, mars-chair@example.mars |
| 494 | +draft-ietf-ames-test@ietf.org xfilter-draft-ietf-ames-test |
| 495 | +expand-draft-ietf-ames-test@virtual.ietf.org ames-author@example.com, ames-collaborator@example.com |
| 496 | +draft-ietf-ames-test.authors@ietf.org xfilter-draft-ietf-ames-test.authors |
| 497 | +expand-draft-ietf-ames-test.authors@virtual.ietf.org ames-author@example.ames, ames-collaborator@example.ames |
| 498 | +draft-ietf-ames-test.chairs@ietf.org xfilter-draft-ietf-ames-test.chairs |
| 499 | +expand-draft-ietf-ames-test.chairs@virtual.ietf.org ames-chair@example.ames |
| 500 | +draft-ietf-ames-test.all@ietf.org xfilter-draft-ietf-ames-test.all |
| 501 | +expand-draft-ietf-ames-test.all@virtual.ietf.org ames-author@example.ames, ames-collaborator@example.ames, ames-chair@example.ames |
| 502 | +
|
| 503 | +""") |
| 504 | + self.doc_alias_file.close() |
| 505 | + settings.DRAFT_VIRTUAL_PATH = self.doc_alias_file.name |
| 506 | + |
| 507 | + def tearDown(self): |
| 508 | + os.unlink(self.doc_alias_file.name) |
| 509 | + |
| 510 | + def testAliases(self): |
| 511 | + url = urlreverse('ietf.doc.views_doc.email_aliases', kwargs=dict()) |
| 512 | + r = self.client.get(url) |
| 513 | + self.assertTrue(all([x in r.content for x in ['mars-test@','mars-test.authors@','mars-test.chairs@']])) |
| 514 | + self.assertTrue(all([x in r.content for x in ['ames-test@','ames-test.authors@','ames-test.chairs@']])) |
| 515 | + |
| 516 | + url = urlreverse('ietf.doc.views_doc.email_aliases', kwargs=dict(name="draft-ietf-mars-test")) |
| 517 | + r = self.client.get(url) |
| 518 | + self.assertTrue(all([x in r.content for x in ['mars-test@','mars-test.authors@','mars-test.chairs@']])) |
| 519 | + self.assertFalse(any([x in r.content for x in ['ames-test@','ames-test.authors@','ames-test.chairs@']])) |
| 520 | + |
0 commit comments