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

[tor-commits] [stem/master] Add integration tests for testing Controller.get_conf



commit 16d392ac74996ae38a8f3a33191ebc1899a5cf8f
Author: Ravi Chandra Padmala <neenaoffline@xxxxxxxxx>
Date:   Sat Jun 9 09:56:17 2012 +0530

    Add integration tests for testing Controller.get_conf
---
 test/integ/control/controller.py |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index 5c10b3d..479c75b 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -134,4 +134,42 @@ class TestController(unittest.TestCase):
         auth_methods.append(stem.response.protocolinfo.AuthMethod.NONE)
       
       self.assertEqual(tuple(auth_methods), protocolinfo.auth_methods)
+  
+  def test_getconf(self):
+    """
+    Exercises GETCONF with valid and invalid queries.
+    """
+    
+    runner = test.runner.get_runner()
+    
+    with runner.get_tor_controller() as controller:
+      # successful single query
+      
+      control_port = str(runner.get_tor_socket().get_port())
+      torrc_path = runner.get_torrc_path()
+      self.assertEqual(control_port, controller.get_conf("ControlPort"))
+      self.assertEqual(control_port, controller.get_conf("ControlPort", "la-di-dah"))
+      
+      # succeessful batch query
+      
+      expected = {"ControlPort": control_port}
+      self.assertEqual(expected, controller.get_conf(["ControlPort"]))
+      self.assertEqual(expected, controller.get_conf(["ControlPort"], "la-di-dah"))
+      
+      getconf_params = set(["ControlPort", "DirPort", "DataDirectory"])
+      self.assertEqual(getconf_params, set(controller.get_conf(["ControlPort",
+        "DirPort", "DataDirectory"])))
+      
+      # non-existant option
+      
+      self.assertRaises(stem.socket.InvalidRequest, controller.get_conf, "blarg")
+      self.assertEqual("la-di-dah", controller.get_conf("blarg", "la-di-dah"))
+      
+      # empty input
+      
+      self.assertRaises(stem.socket.ControllerError, controller.get_conf, "")
+      self.assertEqual("la-di-dah", controller.get_conf("", "la-di-dah"))
+      
+      self.assertEqual({}, controller.get_conf([]))
+      self.assertEqual({}, controller.get_conf([], {}))
 



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