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

[tor-commits] [stem/master] Basic integ test for stem.util.conf



commit 382bc5627b8d4f29645207628ca224f08f7b6883
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Nov 13 16:13:33 2011 -0800

    Basic integ test for stem.util.conf
    
    Adding an integ test for the example given by the conf utility. There's a whole
    lot more that could be tested in that class (especially parsing and type
    inferences) but this doesn't seem too worth while so just adding this basic
    test for now. I might expand it later.
---
 run_tests.py            |    2 +
 test/integ/util/conf.py |   54 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/run_tests.py b/run_tests.py
index 7dcffaf..774c130 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -18,6 +18,7 @@ import test.unit.types.version
 import test.unit.connection.protocolinfo_response
 import test.unit.util.enum
 import test.integ.types.control_message
+import test.integ.util.conf
 import test.integ.util.system
 
 import stem.util.enum
@@ -36,6 +37,7 @@ UNIT_TESTS = (("stem.types.ControlMessage", test.unit.types.control_message.Test
              )
 
 INTEG_TESTS = (("stem.types.ControlMessage", test.integ.types.control_message.TestControlMessage),
+               ("stem.util.conf", test.integ.util.conf.TestConf),
                ("stem.util.system", test.integ.util.system.TestSystem),
               )
 
diff --git a/test/integ/util/conf.py b/test/integ/util/conf.py
new file mode 100644
index 0000000..03ac4a1
--- /dev/null
+++ b/test/integ/util/conf.py
@@ -0,0 +1,54 @@
+"""
+Integration tests for the stem.util.conf class and functions.
+"""
+
+import os
+import tempfile
+import unittest
+
+import stem.util.conf
+
+CONF_PATH = tempfile.mktemp("-conf-test")
+CONF_HEADER = """# Demo configuration for integration tests to run against. Nothing to see here,
+# move along, move along.
+"""
+
+EXAMPLE_CONF = """%s
+destination.ip 1.2.3.4
+destination.port blarg
+
+startup.run export PATH=$PATH:~/bin
+startup.run alias l=ls
+""" % CONF_HEADER
+
+class TestConf(unittest.TestCase):
+  def tearDown(self):
+    # cleans up test configurations we made
+    if os.path.exists(CONF_PATH):
+      os.remove(CONF_PATH)
+  
+  def test_example(self):
+    """
+    Checks that the pydoc example is correct.
+    """
+    
+    test_conf_file = open(CONF_PATH, "w")
+    test_conf_file.write(EXAMPLE_CONF)
+    test_conf_file.close()
+    
+    ssh_config = {"login.user": "atagar",
+                  "login.password": "pepperjack_is_awesome!",
+                  "destination.ip": "127.0.0.1",
+                  "destination.port": 22,
+                  "startup.run": []}
+    
+    user_config = stem.util.conf.get_config("integ-ssh_login")
+    user_config.load(CONF_PATH)
+    user_config.update(ssh_config)
+    
+    self.assertEquals("atagar", ssh_config["login.user"])
+    self.assertEquals("pepperjack_is_awesome!", ssh_config["login.password"])
+    self.assertEquals("1.2.3.4", ssh_config["destination.ip"])
+    self.assertEquals(22, ssh_config["destination.port"])
+    self.assertEquals(["export PATH=$PATH:~/bin", "alias l=ls"], ssh_config["startup.run"])
+



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