Skip to content

Commit

Permalink
don't allow slave_okay on paired connections. update gridfs tests for…
Browse files Browse the repository at this point in the history
… name -> filename change
  • Loading branch information
Mike Dirolf committed Apr 19, 2010
1 parent b700ba2 commit 8a71a35
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
3 changes: 3 additions & 0 deletions pymongo/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ def paired(cls, left, right=None, **connection_args):
warnings.warn("The %s parameter to Connection.paired is "
"deprecated" % param, DeprecationWarning)

if "slave_okay" in connection_args:
raise TypeError("cannot specify slave_okay on paired connections")

connection_args['_connect'] = False

connection = cls(left[0], left[1], **connection_args)
Expand Down
10 changes: 5 additions & 5 deletions test/test_grid_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ def test_grid_in_default_opts(self):
self.assert_(isinstance(a._id, ObjectId))
self.assertRaises(AttributeError, setattr, a, "_id", 5)

self.assertEqual(None, a.name)
a.name = "my_file"
self.assertEqual("my_file", a.name)
self.assertEqual(None, a.filename)
a.filename = "my_file"
self.assertEqual("my_file", a.filename)

self.assertEqual(None, a.content_type)
a.content_type = "text/html"
Expand Down Expand Up @@ -134,7 +134,7 @@ def test_grid_in_default_opts(self):
self.assert_(isinstance(a._id, ObjectId))
self.assertRaises(AttributeError, setattr, a, "_id", 5)

self.assertEqual("my_file", a.name)
self.assertEqual("my_file", a.filename)
self.assertRaises(AttributeError, setattr, a, "name", "foo")

self.assertEqual("text/html", a.content_type)
Expand Down Expand Up @@ -166,7 +166,7 @@ def test_grid_in_custom_opts(self):
metadata={"foo": 1, "bar": 2}, bar=3, baz="hello")

self.assertEqual(5, a._id)
self.assertEqual("my_file", a.name)
self.assertEqual("my_file", a.filename)
self.assertEqual("text/html", a.content_type)
self.assertEqual(1000, a.chunk_size)
self.assertEqual(["foo"], a.aliases)
Expand Down
10 changes: 5 additions & 5 deletions test/test_paired.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,20 @@ def test_end_request(self):
def test_deprecation_warnings_paired_connections(self):
warnings.simplefilter("error")
try:
self.assertRaises(DeprecationWarning, Connection.paired,
self.assertRaises(DeprecationWarning, Connection.paired,
self.left, self.right, timeout=3)
self.assertRaises(DeprecationWarning, Connection.paired,
self.assertRaises(DeprecationWarning, Connection.paired,
self.left, self.right, auto_start_request=True)
self.assertRaises(DeprecationWarning, Connection.paired,
self.assertRaises(DeprecationWarning, Connection.paired,
self.left, self.right, pool_size=20)
finally:
warnings.resetwarnings()
warnings.simplefilter('ignore')


def test_paired_connections_pass_individual_connargs(self):
c = Connection.paired(self.left, self.right, slave_okay=True)
self.assertTrue(c.__slave_okay)
c = Connection.paired(self.left, self.right, network_timeout=5)
self.assertEqual(5, c._Connection__network_timeout)



Expand Down

0 comments on commit 8a71a35

Please sign in to comment.