chore: apply black to GenerateDraftAliasesTests

This commit is contained in:
Robert Sparks 2023-07-07 13:53:37 -05:00
parent 78b6f06519
commit d3f1794fd4
No known key found for this signature in database
GPG key ID: 6E2A6A5775F91318

View file

@ -2045,138 +2045,168 @@ class ReferencesTest(TestCase):
self.assertContains(r, doc1.name)
class GenerateDraftAliasesTests(TestCase):
def setUp(self):
super().setUp()
self.doc_aliases_file = NamedTemporaryFile(delete=False, mode='w+')
self.doc_aliases_file.close()
self.doc_virtual_file = NamedTemporaryFile(delete=False, mode='w+')
self.doc_virtual_file.close()
self.saved_draft_aliases_path = settings.DRAFT_ALIASES_PATH
self.saved_draft_virtual_path = settings.DRAFT_VIRTUAL_PATH
settings.DRAFT_ALIASES_PATH = self.doc_aliases_file.name
settings.DRAFT_VIRTUAL_PATH = self.doc_virtual_file.name
def setUp(self):
super().setUp()
self.doc_aliases_file = NamedTemporaryFile(delete=False, mode="w+")
self.doc_aliases_file.close()
self.doc_virtual_file = NamedTemporaryFile(delete=False, mode="w+")
self.doc_virtual_file.close()
self.saved_draft_aliases_path = settings.DRAFT_ALIASES_PATH
self.saved_draft_virtual_path = settings.DRAFT_VIRTUAL_PATH
settings.DRAFT_ALIASES_PATH = self.doc_aliases_file.name
settings.DRAFT_VIRTUAL_PATH = self.doc_virtual_file.name
def tearDown(self):
settings.DRAFT_ALIASES_PATH = self.saved_draft_aliases_path
settings.DRAFT_VIRTUAL_PATH = self.saved_draft_virtual_path
os.unlink(self.doc_aliases_file.name)
os.unlink(self.doc_virtual_file.name)
super().tearDown()
def tearDown(self):
settings.DRAFT_ALIASES_PATH = self.saved_draft_aliases_path
settings.DRAFT_VIRTUAL_PATH = self.saved_draft_virtual_path
os.unlink(self.doc_aliases_file.name)
os.unlink(self.doc_virtual_file.name)
super().tearDown()
def testManagementCommand(self):
a_month_ago = (timezone.now() - datetime.timedelta(30)).astimezone(RPC_TZINFO)
a_month_ago = a_month_ago.replace(hour=0, minute=0, second=0, microsecond=0)
ad = RoleFactory(name_id='ad', group__type_id='area', group__state_id='active').person
shepherd = PersonFactory()
author1 = PersonFactory()
author2 = PersonFactory()
author3 = PersonFactory()
author4 = PersonFactory()
author5 = PersonFactory()
author6 = PersonFactory()
mars = GroupFactory(type_id='wg', acronym='mars')
marschairman = PersonFactory(user__username='marschairman')
mars.role_set.create(name_id='chair', person=marschairman, email=marschairman.email())
doc1 = IndividualDraftFactory(authors=[author1], shepherd=shepherd.email(), ad=ad)
doc2 = WgDraftFactory(name='draft-ietf-mars-test', group__acronym='mars', authors=[author2], ad=ad)
doc3 = WgDraftFactory.create(name='draft-ietf-mars-finished', group__acronym='mars', authors=[author3], ad=ad, std_level_id='ps', states=[('draft','rfc'),('draft-iesg','pub')], time=a_month_ago)
rfc3 = WgRfcFactory()
DocEventFactory.create(doc=rfc3, type='published_rfc', time=a_month_ago)
doc3.relateddocument_set.create(relationship_id="became_rfc", target=rfc3.docalias.first())
doc4 = WgDraftFactory.create(authors=[author4,author5], ad=ad, std_level_id='ps', states=[('draft','rfc'),('draft-iesg','pub')], time=datetime.datetime(2010,10,10, tzinfo=ZoneInfo(settings.TIME_ZONE)))
rfc4 = WgRfcFactory()
DocEventFactory.create(doc=rfc4, type='published_rfc', time=datetime.datetime(2010, 10, 10, tzinfo=RPC_TZINFO))
doc4.relateddocument_set.create(relationship_id="became_rfc", target=rfc4.docalias.first())
doc5 = IndividualDraftFactory(authors=[author6])
def testManagementCommand(self):
a_month_ago = (timezone.now() - datetime.timedelta(30)).astimezone(RPC_TZINFO)
a_month_ago = a_month_ago.replace(hour=0, minute=0, second=0, microsecond=0)
ad = RoleFactory(
name_id="ad", group__type_id="area", group__state_id="active"
).person
shepherd = PersonFactory()
author1 = PersonFactory()
author2 = PersonFactory()
author3 = PersonFactory()
author4 = PersonFactory()
author5 = PersonFactory()
author6 = PersonFactory()
mars = GroupFactory(type_id="wg", acronym="mars")
marschairman = PersonFactory(user__username="marschairman")
mars.role_set.create(
name_id="chair", person=marschairman, email=marschairman.email()
)
doc1 = IndividualDraftFactory(
authors=[author1], shepherd=shepherd.email(), ad=ad
)
doc2 = WgDraftFactory(
name="draft-ietf-mars-test", group__acronym="mars", authors=[author2], ad=ad
)
doc3 = WgDraftFactory.create(
name="draft-ietf-mars-finished",
group__acronym="mars",
authors=[author3],
ad=ad,
std_level_id="ps",
states=[("draft", "rfc"), ("draft-iesg", "pub")],
time=a_month_ago,
)
rfc3 = WgRfcFactory()
DocEventFactory.create(doc=rfc3, type="published_rfc", time=a_month_ago)
doc3.relateddocument_set.create(
relationship_id="became_rfc", target=rfc3.docalias.first()
)
doc4 = WgDraftFactory.create(
authors=[author4, author5],
ad=ad,
std_level_id="ps",
states=[("draft", "rfc"), ("draft-iesg", "pub")],
time=datetime.datetime(2010, 10, 10, tzinfo=ZoneInfo(settings.TIME_ZONE)),
)
rfc4 = WgRfcFactory()
DocEventFactory.create(
doc=rfc4,
type="published_rfc",
time=datetime.datetime(2010, 10, 10, tzinfo=RPC_TZINFO),
)
doc4.relateddocument_set.create(
relationship_id="became_rfc", target=rfc4.docalias.first()
)
doc5 = IndividualDraftFactory(authors=[author6])
args = [ ]
kwargs = { }
out = io.StringIO()
call_command("generate_draft_aliases", *args, **kwargs, stdout=out, stderr=out)
self.assertFalse(out.getvalue())
args = []
kwargs = {}
out = io.StringIO()
call_command("generate_draft_aliases", *args, **kwargs, stdout=out, stderr=out)
self.assertFalse(out.getvalue())
with open(settings.DRAFT_ALIASES_PATH) as afile:
acontent = afile.read()
for x in [
'xfilter-' + doc1.name,
'xfilter-' + doc1.name + '.ad',
'xfilter-' + doc1.name + '.authors',
'xfilter-' + doc1.name + '.shepherd',
'xfilter-' + doc1.name + '.all',
'xfilter-' + doc2.name,
'xfilter-' + doc2.name + '.ad',
'xfilter-' + doc2.name + '.authors',
'xfilter-' + doc2.name + '.chairs',
'xfilter-' + doc2.name + '.all',
'xfilter-' + doc3.name,
'xfilter-' + doc3.name + '.ad',
'xfilter-' + doc3.name + '.authors',
'xfilter-' + doc3.name + '.chairs',
'xfilter-' + doc5.name,
'xfilter-' + doc5.name + '.authors',
'xfilter-' + doc5.name + '.all',
]:
self.assertIn(x, acontent)
with open(settings.DRAFT_ALIASES_PATH) as afile:
acontent = afile.read()
for x in [
"xfilter-" + doc1.name,
"xfilter-" + doc1.name + ".ad",
"xfilter-" + doc1.name + ".authors",
"xfilter-" + doc1.name + ".shepherd",
"xfilter-" + doc1.name + ".all",
"xfilter-" + doc2.name,
"xfilter-" + doc2.name + ".ad",
"xfilter-" + doc2.name + ".authors",
"xfilter-" + doc2.name + ".chairs",
"xfilter-" + doc2.name + ".all",
"xfilter-" + doc3.name,
"xfilter-" + doc3.name + ".ad",
"xfilter-" + doc3.name + ".authors",
"xfilter-" + doc3.name + ".chairs",
"xfilter-" + doc5.name,
"xfilter-" + doc5.name + ".authors",
"xfilter-" + doc5.name + ".all",
]:
self.assertIn(x, acontent)
for x in [
'xfilter-' + doc1.name + '.chairs',
'xfilter-' + doc2.name + '.shepherd',
'xfilter-' + doc3.name + '.shepherd',
'xfilter-' + doc4.name,
'xfilter-' + doc5.name + '.shepherd',
'xfilter-' + doc5.name + '.ad',
]:
self.assertNotIn(x, acontent)
for x in [
"xfilter-" + doc1.name + ".chairs",
"xfilter-" + doc2.name + ".shepherd",
"xfilter-" + doc3.name + ".shepherd",
"xfilter-" + doc4.name,
"xfilter-" + doc5.name + ".shepherd",
"xfilter-" + doc5.name + ".ad",
]:
self.assertNotIn(x, acontent)
with open(settings.DRAFT_VIRTUAL_PATH) as vfile:
vcontent = vfile.read()
for x in [
ad.email_address(),
shepherd.email_address(),
marschairman.email_address(),
author1.email_address(),
author2.email_address(),
author3.email_address(),
author6.email_address(),
]:
self.assertIn(x, vcontent)
with open(settings.DRAFT_VIRTUAL_PATH) as vfile:
vcontent = vfile.read()
for x in [
ad.email_address(),
shepherd.email_address(),
marschairman.email_address(),
author1.email_address(),
author2.email_address(),
author3.email_address(),
author6.email_address(),
]:
self.assertIn(x, vcontent)
for x in [
author4.email_address(),
author5.email_address(),
]:
self.assertNotIn(x, vcontent)
for x in [
author4.email_address(),
author5.email_address(),
]:
self.assertNotIn(x, vcontent)
for x in [
'xfilter-' + doc1.name,
'xfilter-' + doc1.name + '.ad',
'xfilter-' + doc1.name + '.authors',
'xfilter-' + doc1.name + '.shepherd',
'xfilter-' + doc1.name + '.all',
'xfilter-' + doc2.name,
'xfilter-' + doc2.name + '.ad',
'xfilter-' + doc2.name + '.authors',
'xfilter-' + doc2.name + '.chairs',
'xfilter-' + doc2.name + '.all',
'xfilter-' + doc3.name,
'xfilter-' + doc3.name + '.ad',
'xfilter-' + doc3.name + '.authors',
'xfilter-' + doc3.name + '.chairs',
'xfilter-' + doc5.name,
'xfilter-' + doc5.name + '.authors',
'xfilter-' + doc5.name + '.all',
]:
self.assertIn(x, vcontent)
for x in [
"xfilter-" + doc1.name,
"xfilter-" + doc1.name + ".ad",
"xfilter-" + doc1.name + ".authors",
"xfilter-" + doc1.name + ".shepherd",
"xfilter-" + doc1.name + ".all",
"xfilter-" + doc2.name,
"xfilter-" + doc2.name + ".ad",
"xfilter-" + doc2.name + ".authors",
"xfilter-" + doc2.name + ".chairs",
"xfilter-" + doc2.name + ".all",
"xfilter-" + doc3.name,
"xfilter-" + doc3.name + ".ad",
"xfilter-" + doc3.name + ".authors",
"xfilter-" + doc3.name + ".chairs",
"xfilter-" + doc5.name,
"xfilter-" + doc5.name + ".authors",
"xfilter-" + doc5.name + ".all",
]:
self.assertIn(x, vcontent)
for x in [
'xfilter-' + doc1.name + '.chairs',
'xfilter-' + doc2.name + '.shepherd',
'xfilter-' + doc3.name + '.shepherd',
'xfilter-' + doc4.name,
'xfilter-' + doc5.name + '.shepherd',
'xfilter-' + doc5.name + '.ad',
]:
self.assertNotIn(x, vcontent)
for x in [
"xfilter-" + doc1.name + ".chairs",
"xfilter-" + doc2.name + ".shepherd",
"xfilter-" + doc3.name + ".shepherd",
"xfilter-" + doc4.name,
"xfilter-" + doc5.name + ".shepherd",
"xfilter-" + doc5.name + ".ad",
]:
self.assertNotIn(x, vcontent)
class EmailAliasesTests(TestCase):