Skip to content

Commit

Permalink
bit more coverage, code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
psi29a committed Jun 3, 2015
1 parent 297aeb3 commit 70c24a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 7 additions & 3 deletions tests/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ def test_GridFileObjects(self):
with GridIn(db.fs, filename="test_with", contentType="text/plain", chunk_size=1024):
pass
grid_in_file = GridIn(db.fs, filename="test_1", contentType="text/plain",
content_type="text/plain", chunk_size=2**2**2**2)
content_type="text/plain", chunk_size=65536, length=1048576,
upload_date="20150101")
self.assertFalse(grid_in_file.closed)
if _version.version.major >= 15:
with self.assertRaises(TypeError):
Expand All @@ -165,12 +166,14 @@ def test_GridFileObjects(self):
grid_in_file.test = 1
yield grid_in_file.write("0xDEADBEEF")
yield grid_in_file.write("0xDEADBEEF"*1048576)
fake_doc = {"_id": "test_id", "length": 1048576}
fake_doc = {"_id": "test_id", "length": 1048576, "filename": "test",
"upload_date": "20150101"}
self.assertRaises(TypeError, GridOut, None, None)
grid_out_file = GridOut(db.fs, fake_doc)
if _version.version.major >= 15:
with self.assertRaises(AttributeError):
_ = grid_out_file.testing
self.assertEqual("test", grid_out_file.filename)
self.assertEqual(0, grid_out_file.tell())
grid_out_file.seek(1024)
self.assertEqual(1024, grid_out_file.tell())
Expand All @@ -181,11 +184,12 @@ def test_GridFileObjects(self):
self.assertRaises(IOError, grid_out_file.seek, 0, 4)
self.assertRaises(IOError, grid_out_file.seek, -1)
self.assertTrue("'_id': 'test_id'" in repr(grid_out_file))
self.assertTrue("20150101", grid_in_file.upload_date)
yield grid_in_file.writelines(["0xDEADBEEF", "0xDEADBEAF"])
yield grid_in_file.close()
if _version.version.major >= 15:
with self.assertRaises(AttributeError):
grid_in_file.test = 2
grid_in_file.length = 1
self.assertEqual(1, grid_in_file.test)
if _version.version.major >= 15:
with self.assertRaises(AttributeError):
Expand Down
3 changes: 0 additions & 3 deletions tests/test_replicaset.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,10 @@ def setUp(self):

yield master.disconnect()


@defer.inlineCallbacks
def tearDown(self):
yield defer.gatherResults([mongo.stop() for mongo in self.__mongod])


@defer.inlineCallbacks
def test_WriteToMaster(self):
conn = MongoConnection("localhost", self.ports[0])
Expand All @@ -119,7 +117,6 @@ def test_SlaveOk(self):
finally:
yield conn.disconnect()


@defer.inlineCallbacks
def test_SwitchToMasterOnConnect(self):
# Reverse hosts order
Expand Down

0 comments on commit 70c24a2

Please sign in to comment.