[Pkg-privacy-commits] [pyptlib] 106/136: Unit tests for SMETHOD lines.
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:25:16 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch master
in repository pyptlib.
commit 3783050ab313e58b641ad3efbf2a24bdf7343031
Author: George Kadianakis <desnacked at riseup.net>
Date: Sat Sep 14 13:53:36 2013 +0300
Unit tests for SMETHOD lines.
---
pyptlib/test/test_server.py | 44 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 42 insertions(+), 2 deletions(-)
diff --git a/pyptlib/test/test_server.py b/pyptlib/test/test_server.py
index fbb15cd..2da0475 100644
--- a/pyptlib/test/test_server.py
+++ b/pyptlib/test/test_server.py
@@ -2,7 +2,7 @@ import os
import unittest
from pyptlib.config import EnvError, Config
-from pyptlib.server_config import validate_transport_options
+from pyptlib.server_config import get_transport_options_impl
from pyptlib.server import ServerTransportPlugin
from pyptlib.test.test_core import PluginCoreTestMixin
from pyptlib.core import SUPPORTED_TRANSPORT_VERSIONS
@@ -143,6 +143,46 @@ class testServer(PluginCoreTestMixin, unittest.TestCase):
self.assertEquals(bindaddr["boom"], ('127.0.0.1', 6666))
self.assertOutputLinesStartWith("VERSION ")
+class testServerOutput(PluginCoreTestMixin, unittest.TestCase):
+ """
+ Test the output of pyptlib. That is, test the SMETHOD lines, etc.
+ """
+ pluginType = ServerTransportPlugin
+
+ def test_smethod_line(self):
+ """Test output SMETHOD lines."""
+ os.environ = BASE_ENVIRON
+ self.plugin.init(["dummy", "boom"])
+ for transport, transport_bindaddr in self.plugin.getBindAddresses().items():
+ self.plugin.reportMethodSuccess(transport, transport_bindaddr, None)
+ self.plugin.reportMethodsEnd()
+
+ self.assertIn("SMETHOD dummy 127.0.0.1:5556\n", self.getOutputLines())
+ self.assertIn("SMETHOD boom 127.0.0.1:6666\n", self.getOutputLines())
+ self.assertIn("SMETHODS DONE\n", self.getOutputLines())
+
+ def test_smethod_line_args(self):
+ """Test an SMETHOD line with extra arguments."""
+ TEST_ENVIRON = dict(BASE_ENVIRON)
+ TEST_ENVIRON["TOR_PT_SERVER_TRANSPORT_OPTIONS"] = "boom:roots=culture;random:no=care;boom:first=fire"
+ os.environ = TEST_ENVIRON
+ self.plugin.init(["dummy", "boom"])
+ for transport, transport_bindaddr in self.plugin.getBindAddresses().items():
+ self.plugin.reportMethodSuccess(transport, transport_bindaddr, None)
+ self.plugin.reportMethodsEnd()
+
+ self.assertIn("SMETHOD boom 127.0.0.1:6666 ARGS:roots=culture,first=fire\n", self.getOutputLines())
+
+ def test_smethod_line_explicit_args(self):
+ """Test an SMETHOD line with extra arguments."""
+ os.environ = BASE_ENVIRON
+ self.plugin.init(["dummy", "boom"])
+ for transport, transport_bindaddr in self.plugin.getBindAddresses().items():
+ self.plugin.reportMethodSuccess(transport, transport_bindaddr, "roots=culture,first=fire")
+ self.plugin.reportMethodsEnd()
+
+ self.assertIn("SMETHOD boom 127.0.0.1:6666 ARGS:roots=culture,first=fire\n", self.getOutputLines())
+
class testUtils(unittest.TestCase):
def test_get_transport_options_wrong(self):
"""Invalid options string"""
@@ -159,7 +199,7 @@ class testUtils(unittest.TestCase):
expected = {"trebuchet" : {"secret" : "nou", "cache" : "/tmp/cache"} , "ballista" : {"secret" : "yes", "fun" : "no"}, "archer" : {"bow" : "yes" } }
result = get_transport_options_impl(to_parse)
- self.assertEquals(result, expected) # XXX does this check iteratables?
+ self.assertEquals(result, expected)
if __name__ == '__main__':
unittest.main()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/pyptlib.git
More information about the Pkg-privacy-commits
mailing list