[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Move test for unknown man options to unit tests



commit e43fbf925856b34b84ade0a00d4f31aa88819b93
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Mon Dec 7 07:50:39 2015 -0800

    Move test for unknown man options to unit tests
    
    Both our unit and integ tests have similar tests where we assert against an
    example man page we include. It's a bit fuzzy which area they belong to since
    they include system calls, but should definitely be in the same spot.
---
 test/integ/manual.py           |   28 ----------------------
 test/integ/tor.1_with_unknown  |   51 ----------------------------------------
 test/unit/manual.py            |   31 +++++++++++++++++++++++-
 test/unit/tor_man_with_unknown |   51 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 81 insertions(+), 80 deletions(-)

diff --git a/test/integ/manual.py b/test/integ/manual.py
index 53f9faf..d0b1bf1 100644
--- a/test/integ/manual.py
+++ b/test/integ/manual.py
@@ -122,34 +122,6 @@ class TestManual(unittest.TestCase):
 
     return False
 
-  def test_with_unknown_options(self):
-    """
-    Check that we can read a local mock man page that contains unrecognized
-    options. Unlike most other tests this doesn't require network access.
-    """
-
-    if not stem.util.system.is_available('man'):
-      test.runner.skip(self, '(require man command)')
-      return
-
-    manual = stem.manual.Manual.from_man(os.path.join(os.path.dirname(__file__), 'tor.1_with_unknown'))
-
-    self.assertEqual('tor - The second-generation onion router', manual.name)
-    self.assertEqual('', manual.synopsis)
-    self.assertEqual('', manual.description)
-    self.assertEqual({}, manual.commandline_options)
-    self.assertEqual({}, manual.signals)
-    self.assertEqual({}, manual.files)
-
-    self.assertEqual(2, len(manual.config_options))
-
-    option = [entry for entry in manual.config_options.values() if entry.category == Category.UNKNOWN][0]
-    self.assertEqual(Category.UNKNOWN, option.category)
-    self.assertEqual('SpiffyNewOption', option.name)
-    self.assertEqual('transport exec path-to-binary [options]', option.usage)
-    self.assertEqual('', option.summary)
-    self.assertEqual('Description of this new option.', option.description)
-
   def test_escapes_non_ascii(self):
     """
     Check that our manual parser escapes all non-ascii characters. If this
diff --git a/test/integ/tor.1_with_unknown b/test/integ/tor.1_with_unknown
deleted file mode 100644
index b5e0b82..0000000
--- a/test/integ/tor.1_with_unknown
+++ /dev/null
@@ -1,51 +0,0 @@
-'\" t
-.\"     Title: tor
-.\"    Author: [see the "AUTHORS" section]
-.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
-.\"      Date: 10/03/2015
-.\"    Manual: Tor Manual
-.\"    Source: Tor
-.\"  Language: English
-.\"
-.TH "TOR" "1" "10/03/2015" "Tor" "Tor Manual"
-.\" -----------------------------------------------------------------
-.\" * Define some portability stuff
-.\" -----------------------------------------------------------------
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.\" http://bugs.debian.org/507673
-.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
-.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-.ie \n(.g .ds Aq \(aq
-.el       .ds Aq '
-.\" -----------------------------------------------------------------
-.\" * set default formatting
-.\" -----------------------------------------------------------------
-.\" disable hyphenation
-.nh
-.\" disable justification (adjust text to left margin only)
-.ad l
-.\" -----------------------------------------------------------------
-.\" * MAIN CONTENT STARTS HERE *
-.\" -----------------------------------------------------------------
-.SH "NAME"
-tor \- The second\-generation onion router
-.SH "GENERAL OPTIONS"
-.PP
-\fBBandwidthRate\fR \fIN\fR \fBbytes\fR|\fBKBytes\fR|\fBMBytes\fR|\fBGBytes\fR|\fBKBits\fR|\fBMBits\fR|\fBGBits\fR
-.RS 4
-A token bucket limits the average incoming bandwidth usage on this node to the specified number of bytes per second, and the average outgoing bandwidth usage to that same value\&. If you want to run a relay in the public network, this needs to be
-\fIat the very least\fR
-30 KBytes (that is, 30720 bytes)\&. (Default: 1 GByte)
-
-
-With this option, and in other options that take arguments in bytes, KBytes, and so on, other formats are also supported\&. Notably, "KBytes" can also be written as "kilobytes" or "kb"; "MBytes" can be written as "megabytes" or "MB"; "kbits" can be written as "kilobits"; and so forth\&. Tor also accepts "byte" and "bit" in the singular\&. The prefixes "tera" and "T" are also recognized\&. If no units are given, we default to bytes\&. To avoid confusion, we recommend writing "bytes" or "bits" explicitly, since it\(cqs easy to forget that "B" means bytes, not bits\&.
-.RE
-.PP
-.SH "NEW OPTIONS"
-.PP
-\fBSpiffyNewOption\fR \fItransport\fR exec \fIpath\-to\-binary\fR [options]
-.RS 4
-Description of this new option.
-.RE
-.PP
-
diff --git a/test/unit/manual.py b/test/unit/manual.py
index bb2e2d5..0b9c7cd 100644
--- a/test/unit/manual.py
+++ b/test/unit/manual.py
@@ -33,6 +33,7 @@ except ImportError:
 
 URL_OPEN = 'urllib.request.urlopen' if stem.prereq.is_python_3() else 'urllib2.urlopen'
 EXAMPLE_MAN_PATH = os.path.join(os.path.dirname(__file__), 'tor_man_example')
+UNKNOWN_OPTIONS_MAN_PATH = os.path.join(os.path.dirname(__file__), 'tor_man_with_unknown')
 
 EXPECTED_DESCRIPTION = 'Tor is a connection-oriented anonymizing communication service. Users choose a source-routed path through a set of nodes, and negotiate a "virtual circuit" through the network, in which each node knows its predecessor and successor, but no others. Traffic flowing down the circuit is unwrapped by a symmetric key at each node, which reveals the downstream node.'
 
@@ -111,7 +112,7 @@ class TestManual(unittest.TestCase):
 
     self.assertFalse(stem.manual.is_important('ConstrainedSockSize'))
 
-  def test_parsing_example_man_page(self):
+  def test_parsing_with_example(self):
     """
     Read a trimmed copy of tor's man page. This gives a good exercise of our
     parser with static content. As new oddball man oddities appear feel free to
@@ -132,6 +133,34 @@ class TestManual(unittest.TestCase):
     self.assertEqual(EXPECTED_FILES, manual.files)
     self.assertEqual(EXPECTED_CONFIG_OPTIONS, manual.config_options)
 
+  def test_parsing_with_unknown_options(self):
+    """
+    Check that we can read a local mock man page that contains unrecognized
+    options. Unlike most other tests this doesn't require network access.
+    """
+
+    if not stem.util.system.is_available('man'):
+      test.runner.skip(self, '(require man command)')
+      return
+
+    manual = stem.manual.Manual.from_man(UNKNOWN_OPTIONS_MAN_PATH)
+
+    self.assertEqual('tor - The second-generation onion router', manual.name)
+    self.assertEqual('', manual.synopsis)
+    self.assertEqual('', manual.description)
+    self.assertEqual({}, manual.commandline_options)
+    self.assertEqual({}, manual.signals)
+    self.assertEqual({}, manual.files)
+
+    self.assertEqual(2, len(manual.config_options))
+
+    option = [entry for entry in manual.config_options.values() if entry.category == stem.manual.Category.UNKNOWN][0]
+    self.assertEqual(stem.manual.Category.UNKNOWN, option.category)
+    self.assertEqual('SpiffyNewOption', option.name)
+    self.assertEqual('transport exec path-to-binary [options]', option.usage)
+    self.assertEqual('', option.summary)
+    self.assertEqual('Description of this new option.', option.description)
+
   def test_saving_manual(self):
     """
     Check that we can save and reload manuals.
diff --git a/test/unit/tor_man_with_unknown b/test/unit/tor_man_with_unknown
new file mode 100644
index 0000000..b5e0b82
--- /dev/null
+++ b/test/unit/tor_man_with_unknown
@@ -0,0 +1,51 @@
+'\" t
+.\"     Title: tor
+.\"    Author: [see the "AUTHORS" section]
+.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
+.\"      Date: 10/03/2015
+.\"    Manual: Tor Manual
+.\"    Source: Tor
+.\"  Language: English
+.\"
+.TH "TOR" "1" "10/03/2015" "Tor" "Tor Manual"
+.\" -----------------------------------------------------------------
+.\" * Define some portability stuff
+.\" -----------------------------------------------------------------
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.\" http://bugs.debian.org/507673
+.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
+.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.ie \n(.g .ds Aq \(aq
+.el       .ds Aq '
+.\" -----------------------------------------------------------------
+.\" * set default formatting
+.\" -----------------------------------------------------------------
+.\" disable hyphenation
+.nh
+.\" disable justification (adjust text to left margin only)
+.ad l
+.\" -----------------------------------------------------------------
+.\" * MAIN CONTENT STARTS HERE *
+.\" -----------------------------------------------------------------
+.SH "NAME"
+tor \- The second\-generation onion router
+.SH "GENERAL OPTIONS"
+.PP
+\fBBandwidthRate\fR \fIN\fR \fBbytes\fR|\fBKBytes\fR|\fBMBytes\fR|\fBGBytes\fR|\fBKBits\fR|\fBMBits\fR|\fBGBits\fR
+.RS 4
+A token bucket limits the average incoming bandwidth usage on this node to the specified number of bytes per second, and the average outgoing bandwidth usage to that same value\&. If you want to run a relay in the public network, this needs to be
+\fIat the very least\fR
+30 KBytes (that is, 30720 bytes)\&. (Default: 1 GByte)
+
+
+With this option, and in other options that take arguments in bytes, KBytes, and so on, other formats are also supported\&. Notably, "KBytes" can also be written as "kilobytes" or "kb"; "MBytes" can be written as "megabytes" or "MB"; "kbits" can be written as "kilobits"; and so forth\&. Tor also accepts "byte" and "bit" in the singular\&. The prefixes "tera" and "T" are also recognized\&. If no units are given, we default to bytes\&. To avoid confusion, we recommend writing "bytes" or "bits" explicitly, since it\(cqs easy to forget that "B" means bytes, not bits\&.
+.RE
+.PP
+.SH "NEW OPTIONS"
+.PP
+\fBSpiffyNewOption\fR \fItransport\fR exec \fIpath\-to\-binary\fR [options]
+.RS 4
+Description of this new option.
+.RE
+.PP
+



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits