Skip to content
This repository
Newer
Older
100644 37 lines (26 sloc) 1.2 kb
dc96b8f4 »
2010-10-07 passing back some errors; no more logging of raw bytes
1 import tornado.ioloop
2 import time
3 import logging
4
5 import test_shunt
6 import asyncmongo
7
8 TEST_TIMESTAMP = int(time.time())
9
d27388f8 »
2011-09-09 update test code to init/teardown a mongod instance appropriately
10 class DuplicateInsertTest(test_shunt.MongoTest):
11 def test_duplicate_insert(self):
12 test_shunt.setup()
13 db = asyncmongo.Client(pool_id='dup_insert', host='127.0.0.1', port=27017, dbname='test')
14
15 def insert_callback(response, error):
07e56f0d »
2011-12-14 Harden the unittests a little: close connections between tests, and s…
16 tornado.ioloop.IOLoop.instance().stop()
d27388f8 »
2011-09-09 update test code to init/teardown a mongod instance appropriately
17 logging.info(response)
18 assert len(response) == 1
19 test_shunt.register_called('inserted')
07e56f0d »
2011-12-14 Harden the unittests a little: close connections between tests, and s…
20
d27388f8 »
2011-09-09 update test code to init/teardown a mongod instance appropriately
21 db.test_users.insert({"_id" : "duplicate_insert.%d" % TEST_TIMESTAMP}, callback=insert_callback)
22
23 tornado.ioloop.IOLoop.instance().start()
24 test_shunt.assert_called('inserted')
25
26 def duplicate_callback(response, error):
07e56f0d »
2011-12-14 Harden the unittests a little: close connections between tests, and s…
27 tornado.ioloop.IOLoop.instance().stop()
d27388f8 »
2011-09-09 update test code to init/teardown a mongod instance appropriately
28 logging.info(response)
29 if error:
30 test_shunt.register_called('dupe')
07e56f0d »
2011-12-14 Harden the unittests a little: close connections between tests, and s…
31
d27388f8 »
2011-09-09 update test code to init/teardown a mongod instance appropriately
32 db.test_users.insert({"_id" : "duplicate_insert.%d" % TEST_TIMESTAMP}, callback=duplicate_callback)
33
34 tornado.ioloop.IOLoop.instance().start()
35 test_shunt.assert_called('dupe')
dc96b8f4 »
2010-10-07 passing back some errors; no more logging of raw bytes
36
Something went wrong with that request. Please try again.