Skip to content

Commit 341c391

Browse files
committed
PYTHON-305 updated replica pair test.
Connection syntax has changed. Removed old auto reconnect test in tools as lots of testcases for auto reconnect.
1 parent 95974a2 commit 341c391

File tree

2 files changed

+17
-78
lines changed

2 files changed

+17
-78
lines changed

test/test_paired.py

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""Test pairing support.
1616
1717
These tests are skipped by nose by default (since they depend on having a
18-
paired setup. To run the tests just run this file manually.
18+
paired setup. To run the tests just run this file manually).
1919
2020
Left and right nodes will be $DB_IP:$DB_PORT and $DB_IP2:$DB_PORT2 or
2121
localhost:27017 and localhost:27018 by default.
@@ -39,11 +39,11 @@ class TestPaired(unittest.TestCase):
3939
def setUp(self):
4040
left_host = os.environ.get("DB_IP", "localhost")
4141
left_port = int(os.environ.get("DB_PORT", 27017))
42-
self.left = (left_host, left_port)
42+
self.left = "%s:%s" % (left_host, left_port)
4343
right_host = os.environ.get("DB_IP2", "localhost")
4444
right_port = int(os.environ.get("DB_PORT2", 27018))
45-
self.right = (right_host, right_port)
46-
self.bad = ("somedomainthatdoesntexist.org", 12345)
45+
self.right = "%s:%s" % (right_host, right_port)
46+
self.bad = "%s:%s" % ("somedomainthatdoesntexist.org", 12345)
4747

4848
def tearDown(self):
4949
pass
@@ -53,55 +53,40 @@ def skip(self):
5353
from nose.plugins.skip import SkipTest
5454
raise SkipTest()
5555

56-
def test_types(self):
57-
self.skip()
58-
self.assertRaises(TypeError, Connection.paired, 5)
59-
self.assertRaises(TypeError, Connection.paired, "localhost")
60-
self.assertRaises(TypeError, Connection.paired, None)
61-
self.assertRaises(TypeError, Connection.paired, 5, self.right)
62-
self.assertRaises(TypeError, Connection.paired,
63-
"localhost", self.right)
64-
self.assertRaises(TypeError, Connection.paired, None, self.right)
65-
self.assertRaises(TypeError, Connection.paired, self.left, 5)
66-
self.assertRaises(TypeError, Connection.paired, self.left, "localhost")
67-
self.assertRaises(TypeError, Connection.paired, self.left, "localhost")
6856

6957
def test_connect(self):
7058
self.skip()
71-
self.assertRaises(ConnectionFailure, Connection.paired,
72-
self.bad, self.bad)
59+
self.assertRaises(ConnectionFailure, Connection,
60+
[self.bad, self.bad])
7361

74-
connection = Connection.paired(self.left, self.right)
62+
connection = Connection([self.left, self.right])
7563
self.assert_(connection)
7664

7765
host = connection.host
7866
port = connection.port
7967

80-
connection = Connection.paired(self.right, self.left)
68+
connection = Connection([self.right, self.left])
8169
self.assert_(connection)
8270
self.assertEqual(host, connection.host)
8371
self.assertEqual(port, connection.port)
8472

8573
slave = self.left == (host, port) and self.right or self.left
86-
self.assertRaises(ConnectionFailure, Connection.paired,
87-
slave, self.bad)
88-
self.assertRaises(ConnectionFailure, Connection.paired,
89-
self.bad, slave)
74+
self.assertRaises(ConnectionFailure, Connection,
75+
[slave, self.bad])
76+
self.assertRaises(ConnectionFailure, Connection,
77+
[self.bad, slave])
9078

9179
def test_repr(self):
9280
self.skip()
93-
connection = Connection.paired(self.left, self.right)
81+
connection = Connection([self.left, self.right])
9482

9583
self.assertEqual(repr(connection),
96-
"Connection(['%s:%s', '%s:%s'])" %
97-
(self.left[0],
98-
self.left[1],
99-
self.right[0],
100-
self.right[1]))
84+
"Connection(['%s', '%s'])" %
85+
(self.left, self.right))
10186

10287
def test_basic(self):
10388
self.skip()
104-
connection = Connection.paired(self.left, self.right)
89+
connection = Connection([self.left, self.right])
10590

10691
db = connection.pymongo_test
10792

@@ -112,7 +97,7 @@ def test_basic(self):
11297

11398
def test_end_request(self):
11499
self.skip()
115-
connection = Connection.paired(self.left, self.right)
100+
connection = Connection([self.left, self.right])
116101
db = connection.pymongo_test
117102

118103
for _ in range(100):

tools/auto_reconnect_test.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)