Ejemplo n.º 1
0
    def tearDown(self):
        super(SignalTestCase, self).tearDown()

        class CollectionTest(Collection):
            __collection__ = "collection_test"

        CollectionTest.objects.truncate(callback=self.stop)
        self.wait()
        Database.disconnect()
Ejemplo n.º 2
0
    def tearDown(self):
        super(SignalTestCase, self).tearDown()

        class CollectionTest(Collection):
            __collection__ = "collection_test"

        CollectionTest.objects.truncate(callback=self.stop)
        self.wait()
        Database.disconnect()
Ejemplo n.º 3
0
    def tearDown(self):
        super(CursorTestCase, self).tearDown()

        # delete all documents
        message_delete = message.delete('mongotor_test.cursor_test',
            {}, True, {})
        Database().send_message(message_delete, callback=self.stop)
        self.wait()

        Database.disconnect()
Ejemplo n.º 4
0
    def tearDown(self):
        super(CursorTestCase, self).tearDown()

        # delete all documents
        message_delete = message.delete('mongotor_test.cursor_test', {}, True,
                                        {})
        Database().send_message(message_delete, callback=self.stop)
        self.wait()

        Database.disconnect()
Ejemplo n.º 5
0
    def test_raises_erro_when_use_collection_with_not_initialized_database(
            self):
        """[CollectionTestCase] - Raises DatabaseError when use collection with a not initialized database"""
        class CollectionTest(Collection):
            __collection__ = 'collection_test'

        Database.disconnect()
        CollectionTest().save.when.called_with(callback=None) \
            .throw(DatabaseError, 'you must be initialize database before perform this action')

        Database.init(["localhost:27027", "localhost:27028"], dbname='test')
Ejemplo n.º 6
0
    def test_raises_erro_when_use_collection_with_not_initialized_database(self):
        """[CollectionTestCase] - Raises DatabaseError when use collection with a not initialized database"""

        class CollectionTest(Collection):
            __collection__ = 'collection_test'

        Database.disconnect()
        CollectionTest().save.when.called_with(callback=None) \
            .throw(DatabaseError, 'you must be initialize database before perform this action')

        Database.init(["localhost:27027", "localhost:27028"], dbname='test')
Ejemplo n.º 7
0
    def tearDown(self):
        super(CursorTestCase, self).tearDown()

        # delete all documents
        message_delete = message.delete('mongotor_test.cursor_test',
            {}, True, {})

        node = Database().get_node(ReadPreference.PRIMARY)
        node.connection(self.stop)
        connection = self.wait()

        connection.send_message(message_delete, with_last_error=True, callback=self.stop)
        self.wait()

        Database.disconnect()
Ejemplo n.º 8
0
    def test_check_connections_when_use_cursors(self):
        """[ConnectionPoolTestCase] - check connections when use cursors"""
        db = Database.init('localhost:27027', dbname='test', maxconnections=10, maxusage=29)

        try:
            for i in range(2):
                db.cards.insert({'_id': ObjectId(), 'range': i}, callback=self.stop)
                self.wait()

            db._nodes[0].pool._connections.should.be.equal(0)

            db.cards.find({}, callback=self.stop)
            self.wait()

            db._nodes[0].pool._connections.should.be.equal(0)
        finally:
            Database.disconnect()
Ejemplo n.º 9
0
    def tearDown(self):
        super(CursorTestCase, self).tearDown()

        # delete all documents
        message_delete = message.delete('mongotor_test.cursor_test', {}, True,
                                        {})

        Database().get_node(ReadPreference.PRIMARY, callback=self.stop)
        node = self.wait()
        node.connection(self.stop)
        connection = self.wait()

        connection.send_message(message_delete,
                                with_last_error=True,
                                callback=self.stop)
        self.wait()

        Database.disconnect()
Ejemplo n.º 10
0
    def test_check_connections_when_use_cursors(self):
        """[ConnectionPoolTestCase] - check connections when use cursors"""
        db = Database.init('localhost:27027',
                           dbname='test',
                           maxconnections=10,
                           maxusage=29)

        try:
            for i in range(2):
                db.cards.insert({
                    '_id': ObjectId(),
                    'range': i
                },
                                callback=self.stop)
                self.wait()

            db._nodes[0].pool._connections.should.be.equal(0)

            db.cards.find({}, callback=self.stop)
            self.wait()

            db._nodes[0].pool._connections.should.be.equal(0)
        finally:
            Database.disconnect()
Ejemplo n.º 11
0
 def tearDown(self):
     super(ManagerTestCase, self).tearDown()
     CollectionTest.objects.truncate(callback=self.stop)
     self.wait()
     Database.disconnect()
Ejemplo n.º 12
0
    def test_disconnect_database(self):
        """[DatabaseTestCase] - Disconnect the database"""
        Database.init(["localhost:27027"], dbname='test')
        Database.disconnect()

        Database._instance.should.be.none
Ejemplo n.º 13
0
 def tearDown(self):
     super(CollectionTestCase, self).tearDown()
     Database.disconnect()
Ejemplo n.º 14
0
 def tearDown(self):
     super(ManagerTestCase, self).tearDown()
     CollectionTest.objects.truncate(callback=self.stop)
     self.wait()
     Database.disconnect()
Ejemplo n.º 15
0
 def tearDown(self):
     super(ReplicaSetTestCase, self).tearDown()
     Database.disconnect()
Ejemplo n.º 16
0
 def tearDown(self):
     super(ReplicaSetTestCase, self).tearDown()
     Database.disconnect()
Ejemplo n.º 17
0
 def tearDown(self):
     super(CollectionTestCase, self).tearDown()
     Database.disconnect()
Ejemplo n.º 18
0
    def test_disconnect_database(self):
        """[DatabaseTestCase] - Disconnect the database"""
        Database.connect(["localhost:27027"], dbname="test")
        Database.disconnect()

        Database._instance.should.be.none