[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Rewrite Controller.repurpose_circuit test to use a newly created circuit.
commit 86d6b6114ad0929ee787cf454c9d93f1af3f9033
Author: Ravi Chandra Padmala <neenaoffline@xxxxxxxxx>
Date: Thu Nov 1 23:20:25 2012 +0530
Rewrite Controller.repurpose_circuit test to use a newly created circuit.
Attempting to fix https://trac.torproject.org/projects/tor/ticket/7259 by
using a newly created circuit instead of parsing the GETINFO circuit-status
output.
---
test/integ/control/controller.py | 29 ++++++++++++++---------------
1 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/test/integ/control/controller.py b/test/integ/control/controller.py
index 4def79d..2f7d15c 100644
--- a/test/integ/control/controller.py
+++ b/test/integ/control/controller.py
@@ -382,32 +382,31 @@ class TestController(unittest.TestCase):
self.assertRaises(stem.socket.InvalidRequest, controller.extend_circuit, 0, "thisroutershouldntexistbecausestemexists!@##$%#", "foo")
def test_repurpose_circuit(self):
+ """
+ Tests Controller.repurpose_circuit with valid and invalid input.
+ """
+
if test.runner.require_control(self): return
+ elif test.runner.require_online(self): return
runner = test.runner.get_runner()
with runner.get_tor_controller() as controller:
- circuit_output = controller.get_info('circuit-status')
-
- # the circuit-status results will be empty if we don't have a connection
- if circuit_output == '':
- if test.runner.require_online(self): return
+ circ_id = controller.new_circuit()
+ controller.repurpose_circuit(circ_id, "CONTROLLER")
+ circuit_output = controller.get_info("circuit-status")
+ circ = filter(re.compile("^%i " % circ_id).match, circuit_output.splitlines())[0]
+ self.assertTrue("PURPOSE=CONTROLLER" in circ)
- first_circ = circuit_output.splitlines()[0].split()
- circ_id = int(first_circ[0])
- purpose = "CONTROLLER"
- if "PURPOSE=CONTROLLER" in first_circ:
- purpose = "GENERAL"
- controller.repurpose_circuit(circ_id, purpose)
- purpose_arg = "PURPOSE=%s" % purpose
- circ = filter(lambda line: int(line.split()[0]) == circ_id, controller.get_info('circuit-status').splitlines())[0]
- self.assertTrue(purpose_arg in circ)
+ controller.repurpose_circuit(circ_id, "GENERAL")
+ circuit_output = controller.get_info("circuit-status")
+ circ = filter(re.compile("^%i " % circ_id).match, circuit_output.splitlines())[0]
+ self.assertTrue("PURPOSE=GENERAL" in circ)
self.assertRaises(stem.socket.InvalidRequest, controller.repurpose_circuit, 'f934h9f3h4', "fooo")
self.assertRaises(stem.socket.InvalidRequest, controller.repurpose_circuit, '4', "fooo")
def test_mapaddress(self):
-
if test.runner.require_control(self): return
elif test.runner.require_online(self): return
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits