Skip to content

Commit 655a763

Browse files
committed
remove sorting code; change test cases names
Sorting will be implemented in #19
1 parent 68952bd commit 655a763

File tree

4 files changed

+2
-27
lines changed

4 files changed

+2
-27
lines changed

rfc_bibtex/rfc_bibtex.py

-16
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,6 @@ def __init__(self, id_names=None, in_file_name=None, out_file_name=None):
7676
if in_file_name is not None:
7777
self._id_names += self._read_ids_from_file(in_file_name)
7878

79-
@staticmethod
80-
def _rfc_key_function(name):
81-
"""Turn RFC32 into RFC00032 for sorting. This needs to be a staticmethod because it is called as a function from sorted()."""
82-
try:
83-
if name.upper().startswith('RFC'):
84-
return "RFC{:05d}".format( int(name[3:]))
85-
except (ValueError,TypeError) as e:
86-
raise BadRFCNumberException(name)
87-
return name
88-
8979
@property
9080
def bibtex_entries(self):
9181
# remove Nones (errors returned by urllib), so that they're not printed
@@ -96,19 +86,13 @@ def _read_ids_from_plain_file(self, filename):
9686
return [line.strip() for line in f ]
9787

9888
def _read_ids_from_aux_file(self, filename):
99-
sort_entries = False # TODO: not yet implemented
10089
with open(filename, 'r') as f:
10190
rfcs = list([m.group(1) for line in f for m in [self.AUX_CITATION_RE.search(line)] if m])
102-
if sort_entries:
103-
rfcs = sorted(rfcs, key=self._rfc_key_function)
10491
return rfcs
10592

10693
def _read_ids_from_tex_file(self, filename):
107-
sort_entries = False # TODO: not yet implemented
10894
with open(filename, 'r') as f:
10995
rfcs = list([m.group(1) for line in f for m in [self.TEX_CITATION_RE.search(line)] if m])
110-
if sort_entries:
111-
rfcs = sorted(rfcs, key=self._rfc_key_function)
11296
return rfcs
11397

11498
def _read_ids_from_file(self, filename):

tests/integration/test_obtained_bibtex_from_raw_input.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
tests were adapted to work in both of them. This is why some assertions might
1414
seem like incomplete. Later, the tests should and will be refactored.
1515
"""
16-
class TestObtainedBibtexFromRawRFCInput(BaseRFCBibTexIntegrationTestCase):
16+
class ObtainedBibtexFromRawRFCInputTestCase(BaseRFCBibTexIntegrationTestCase):
1717
TLS_RFCS_FILE = BaseRFCBibTexIntegrationTestCase.TEST_RESOURCES_PATH + "tls_rfcs.txt"
1818
TLS_RFCS_INVALID_IDS_FILE = BaseRFCBibTexIntegrationTestCase.TEST_RESOURCES_PATH + "tls_rfcs_invalid_ids.txt"
1919
TLS_RFCS_NON_EXISTING_IDS_FILE = BaseRFCBibTexIntegrationTestCase.TEST_RESOURCES_PATH + "tls_rfcs_non_existing_ids.txt"

tests/integration/test_obtained_bibtex_from_tex_and_aux.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
tests were adapted to work in both of them. This is why some assertions might
1414
seem like incomplete. Later, the tests should and will be refactored.
1515
"""
16-
class TestObtainedBibtexFromTexAndAuxFiles(BaseRFCBibTexIntegrationTestCase):
16+
class ObtainedBibtexFromTexAndAuxFilesTestCase(BaseRFCBibTexIntegrationTestCase):
1717
TLS_RFCS_FILE_AUX = BaseRFCBibTexIntegrationTestCase.TEST_RESOURCES_PATH + "tls_rfcs.aux"
1818
TLS_RFCS_FILE_INVALID_IDS_AUX = BaseRFCBibTexIntegrationTestCase.TEST_RESOURCES_PATH + "tls_rfcs_invalid_ids.aux"
1919
TLS_RFCS_FILE_NON_EXISTING_IDS_AUX = BaseRFCBibTexIntegrationTestCase.TEST_RESOURCES_PATH + "tls_rfcs_non_existing_ids.aux"

tests/unit/test_regex.py

-9
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,3 @@ def test_re(self):
88
self.assertTrue(RFCBibtex.AUX_CITATION_RE.search(r"\citation{RFC32}"))
99
self.assertTrue(RFCBibtex.AUX_CITATION_RE.search(r"\citation{draft-tls-nothing}"))
1010
self.assertFalse(RFCBibtex.AUX_CITATION_RE.search(r"\citation{nothing}"))
11-
12-
def test_rfc_keyfunction(self):
13-
self.assertEqual(RFCBibtex._rfc_key_function("RFC32"), "RFC00032")
14-
self.assertEqual(RFCBibtex._rfc_key_function("draft-nothing"), "draft-nothing")
15-
try:
16-
self.assertEqual(RFCBibtex._rfc_key_function("RFC32a"), "RFC32a")
17-
except BadRFCNumberException:
18-
pass
19-

0 commit comments

Comments
 (0)