[stem/master] Unit test for misordered fields

commit bc09f1e697f4a34475b4b9b55bcb91c14494427b Author: Damian Johnson <atagar@torproject.org> Date: Sat Sep 8 10:51:51 2012 -0700 Unit test for misordered fields To be valid a network status document's fiends need to appear in a particular order. I'm about to add vaidation for this, but the parser is being finicky. I'm tired of trying to fix incrementally fix it, so skipping this test for now and moving on to the parser rewrite. --- test/unit/descriptor/networkstatus/document.py | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/test/unit/descriptor/networkstatus/document.py b/test/unit/descriptor/networkstatus/document.py index 8f770bb..d2bbe90 100644 --- a/test/unit/descriptor/networkstatus/document.py +++ b/test/unit/descriptor/networkstatus/document.py @@ -167,4 +167,23 @@ class TestNetworkStatusDocument(unittest.TestCase): content = get_network_status_document(attr, exclude = (field,)) self.assertRaises(ValueError, NetworkStatusDocument, content) NetworkStatusDocument(content, False) # constructs without validation + + def test_misordered_fields(self): + """ + Rearranges our descriptor fields. + """ + + self.skipTest("Needs a parser rewrite first") + for is_consensus in (True, False): + attr = {"vote-status": "consensus"} if is_consensus else {"vote-status": "vote"} + lines = get_network_status_document(attr).split("\n") + + for i in xrange(len(lines) - 1): + # swaps this line with the one after it + test_lines = list(lines) + test_lines[i], test_lines[i + 1] = test_lines[i + 1], test_lines[i] + + content = "\n".join(test_lines) + self.assertRaises(ValueError, NetworkStatusDocument, content) + NetworkStatusDocument(content, False) # constructs without validation
participants (1)
-
atagar@torproject.org