Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Remove setup that does not apply to rfc docs #6082

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 54 additions & 45 deletions ietf/doc/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1921,75 +1921,84 @@ def _parse_bibtex_response(self, response) -> dict:
@override_settings(RFC_EDITOR_INFO_BASE_URL='https://www.rfc-editor.ietf.org/info/')
def test_document_bibtex(self):
rfc = WgRfcFactory.create(
#other_aliases = ['rfc6020',],
states = [('draft','rfc'),('draft-iesg','pub')],
std_level_id = 'ps',
time = datetime.datetime(2010, 10, 10, tzinfo=ZoneInfo(settings.TIME_ZONE)),
)
time=datetime.datetime(2010, 10, 10, tzinfo=ZoneInfo(settings.TIME_ZONE))
)
num = rfc.rfc_number
DocEventFactory.create(
doc=rfc,
type='published_rfc',
type="published_rfc",
time=datetime.datetime(2010, 10, 10, tzinfo=RPC_TZINFO),
)
#
url = urlreverse('ietf.doc.views_doc.document_bibtex', kwargs=dict(name=rfc.name))
url = urlreverse("ietf.doc.views_doc.document_bibtex", kwargs=dict(name=rfc.name))
r = self.client.get(url)
entry = self._parse_bibtex_response(r)["rfc%s"%num]
self.assertEqual(entry['series'], 'Request for Comments')
self.assertEqual(int(entry['number']), num)
self.assertEqual(entry['doi'], '10.17487/RFC%s'%num)
self.assertEqual(entry['year'], '2010')
self.assertEqual(entry['month'].lower()[0:3], 'oct')
self.assertEqual(entry['url'], f'https://www.rfc-editor.ietf.org/info/rfc{num}')
entry = self._parse_bibtex_response(r)["rfc%s" % num]
self.assertEqual(entry["series"], "Request for Comments")
self.assertEqual(int(entry["number"]), num)
self.assertEqual(entry["doi"], "10.17487/RFC%s" % num)
self.assertEqual(entry["year"], "2010")
self.assertEqual(entry["month"].lower()[0:3], "oct")
self.assertEqual(entry["url"], f"https://www.rfc-editor.ietf.org/info/rfc{num}")
#
self.assertNotIn('day', entry)

self.assertNotIn("day", entry)
# test for incorrect case - revision for RFC
rfc = WgRfcFactory(name="rfc0000")
url = urlreverse('ietf.doc.views_doc.document_bibtex', kwargs=dict(name=rfc.name, rev='00'))
url = urlreverse(
"ietf.doc.views_doc.document_bibtex", kwargs=dict(name=rfc.name, rev="00")
)
r = self.client.get(url)
self.assertEqual(r.status_code, 404)

april1 = IndividualRfcFactory.create(
stream_id = 'ise',
states = [('draft','rfc'),('draft-iesg','pub')],
std_level_id = 'inf',
time = datetime.datetime(1990, 4, 1, tzinfo=ZoneInfo(settings.TIME_ZONE)),
)
stream_id="ise",
std_level_id="inf",
time=datetime.datetime(1990, 4, 1, tzinfo=ZoneInfo(settings.TIME_ZONE)),
)
num = april1.rfc_number
DocEventFactory.create(
doc=april1,
type='published_rfc',
type="published_rfc",
time=datetime.datetime(1990, 4, 1, tzinfo=RPC_TZINFO),
)
#
url = urlreverse('ietf.doc.views_doc.document_bibtex', kwargs=dict(name=april1.name))
url = urlreverse(
"ietf.doc.views_doc.document_bibtex", kwargs=dict(name=april1.name)
)
r = self.client.get(url)
self.assertEqual(r.get('Content-Type'), 'text/plain; charset=utf-8')
entry = self._parse_bibtex_response(r)["rfc%s"%num]
self.assertEqual(entry['series'], 'Request for Comments')
self.assertEqual(int(entry['number']), num)
self.assertEqual(entry['doi'], '10.17487/RFC%s'%num)
self.assertEqual(entry['year'], '1990')
self.assertEqual(entry['month'].lower()[0:3], 'apr')
self.assertEqual(entry['day'], '1')
self.assertEqual(entry['url'], f'https://www.rfc-editor.ietf.org/info/rfc{num}')

self.assertEqual(r.get("Content-Type"), "text/plain; charset=utf-8")
entry = self._parse_bibtex_response(r)["rfc%s" % num]
self.assertEqual(entry["series"], "Request for Comments")
self.assertEqual(int(entry["number"]), num)
self.assertEqual(entry["doi"], "10.17487/RFC%s" % num)
self.assertEqual(entry["year"], "1990")
self.assertEqual(entry["month"].lower()[0:3], "apr")
self.assertEqual(entry["day"], "1")
self.assertEqual(entry["url"], f"https://www.rfc-editor.ietf.org/info/rfc{num}")
draft = IndividualDraftFactory.create()
docname = '%s-%s' % (draft.name, draft.rev)
bibname = docname[6:] # drop the 'draft-' prefix
url = urlreverse('ietf.doc.views_doc.document_bibtex', kwargs=dict(name=draft.name))
docname = "%s-%s" % (draft.name, draft.rev)
bibname = docname[6:] # drop the 'draft-' prefix
url = urlreverse("ietf.doc.views_doc.document_bibtex", kwargs=dict(name=draft.name))
r = self.client.get(url)
entry = self._parse_bibtex_response(r)[bibname]
self.assertEqual(entry['note'], 'Work in Progress')
self.assertEqual(entry['number'], docname)
self.assertEqual(entry['year'], str(draft.pub_date().year))
self.assertEqual(entry['month'].lower()[0:3], draft.pub_date().strftime('%b').lower())
self.assertEqual(entry['day'], str(draft.pub_date().day))
self.assertEqual(entry['url'], settings.IDTRACKER_BASE_URL + urlreverse("ietf.doc.views_doc.document_main", kwargs=dict(name=draft.name, rev=draft.rev)))
self.assertEqual(entry["note"], "Work in Progress")
self.assertEqual(entry["number"], docname)
self.assertEqual(entry["year"], str(draft.pub_date().year))
self.assertEqual(
entry["month"].lower()[0:3], draft.pub_date().strftime("%b").lower()
)
self.assertEqual(entry["day"], str(draft.pub_date().day))
self.assertEqual(
entry["url"],
settings.IDTRACKER_BASE_URL
+ urlreverse(
"ietf.doc.views_doc.document_main",
kwargs=dict(name=draft.name, rev=draft.rev),
),
)
#
self.assertNotIn('doi', entry)
self.assertNotIn("doi", entry)

def test_document_bibxml(self):
draft = IndividualDraftFactory.create()
Expand Down
Loading