コード例 #1
0
ファイル: test_motor_ipv6.py プロジェクト: AraHaan/motor
    async def test_ipv6(self):
        assert env.host in (
            "localhost",
            "127.0.0.1",
        ), "This unittest isn't written to test IPv6 with host %s" % repr(
            env.host)

        try:
            connected(
                MongoClient("[::1]",
                            username=db_user,
                            password=db_password,
                            serverSelectionTimeoutMS=100))
        except ConnectionFailure:
            # Either mongod was started without --ipv6
            # or the OS doesn't support it (or both).
            raise SkipTest("No IPV6")

        if test.env.auth:
            cx_string = "mongodb://%s:%s@[::1]:%d" % (db_user, db_password,
                                                      env.port)
        else:
            cx_string = "mongodb://[::1]:%d" % env.port

        cx = motor.MotorClient(cx_string, io_loop=self.io_loop)
        collection = cx.motor_test.test_collection
        await collection.insert_one({"dummy": "object"})
        self.assertTrue((await collection.find_one({"dummy": "object"})))
コード例 #2
0
    def test_ipv6(self):
        assert env.host in ('localhost', '127.0.0.1'), (
            "This unittest isn't written to test IPv6 "
            "with host %s" % repr(env.host))

        try:
            connected(MongoClient("[::1]",
                                  username=db_user,
                                  password=db_password,
                                  serverSelectionTimeoutMS=100))
        except ConnectionFailure:
            # Either mongod was started without --ipv6
            # or the OS doesn't support it (or both).
            raise SkipTest("No IPV6")

        if test.env.auth:
            cx_string = 'mongodb://%s:%s@[::1]:%d' % (
                db_user, db_password, env.port)
        else:
            cx_string = 'mongodb://[::1]:%d' % env.port

        cx = self.asyncio_client(uri=cx_string)
        collection = cx.motor_test.test_collection
        yield from collection.insert_one({"dummy": "object"})
        self.assertTrue((yield from collection.find_one({"dummy": "object"})))