当前位置: 首页>>代码示例>>Python>>正文


Python test_base_class.TestBaseClass类代码示例

本文整理汇总了Python中test_base_class.TestBaseClass的典型用法代码示例。如果您正苦于以下问题:Python TestBaseClass类的具体用法?Python TestBaseClass怎么用?Python TestBaseClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TestBaseClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_put_with_mixeddata_client_serializer_deserializer_with_spec_in_put

    def test_put_with_mixeddata_client_serializer_deserializer_with_spec_in_put(self):

        #    Invoke put() for mixed data with class and instance serialziers
        #    with a specification in put. Client one is called

        hostlist, user, password = TestBaseClass.get_hosts()
        method_config = {'hosts': hostlist,
                'serialization': (client_serialize_function,
                    client_deserialize_function)}
        if user == None and password == None:
            client = aerospike.client(method_config).connect()
        else:
            client = aerospike.client(method_config).connect(user, password)
        response = aerospike.set_serializer(serialize_function)
        response = aerospike.set_deserializer(deserialize_function)
        key = ('test', 'demo', 1)

        rec = {
            'map': {"key": "asd';q;'1';",
                    "pi": 3},
            'normal': 1234,
            'special': '[email protected]#@#$QSDAsd;as',
            'list': ["nanslkdl", 1, bytearray("asd;as[d'as;d", "utf-8")],
            'bytes': bytearray("asd;as[d'as;d", "utf-8"),
            'nestedlist': ["nanslkdl", 1, bytearray("asd;as[d'as;d", "utf-8"),
                           [1, bytearray("asd;as[d'as;d", "utf-8")]],
            'nestedmap': {
                "key": "asd';q;'1';",
                "pi": 314,
                "nest": {"pi1": 312,
                         "t": 1}
            },
        }

        res = client.put(key, rec, {}, {}, aerospike.SERIALIZER_USER)

        assert res == 0

        _, _, bins = client.get(key)


        assert bins == {
            'map': {"key": "asd';q;'1';",
                    "pi": 3},
            'normal': 1234,
            'special': '[email protected]#@#$QSDAsd;as',
            'list': ["nanslkdl", 1, bytearray("asd;as[d'as;d", "utf-8")],
            'bytes': bytearray("asd;as[d'as;d", "utf-8"),
            'nestedlist': ["nanslkdl", 1, bytearray("asd;as[d'as;d", "utf-8"),
                           [1, bytearray("asd;as[d'as;d", "utf-8")]],
            'nestedmap': {
                "key": "asd';q;'1';",
                "pi": 314,
                "nest": {"pi1": 312,
                         "t": 1}
            },
        }
        client.close()

        self.delete_keys.append(key)
开发者ID:Fabma,项目名称:aerospike-client-python,代码行数:60,代码来源:test_user_serializer.py

示例2: setup_class

    def setup_class(cls):
        hostlist, user, password = TestBaseClass.get_hosts()
        config = {'hosts': hostlist}
        if user == None and password == None:
            TestApply.client = aerospike.client(config).connect()
        else:
            TestApply.client = aerospike.client(config).connect(user, password)
        TestApply.skip_old_server = True
        versioninfo = TestApply.client.info('version')
        for keys in versioninfo:
            for value in versioninfo[keys]:
                if value != None:
                    versionlist = value[value.find("build") + 6:value.find("\n")].split(".")
                    if int(versionlist[0]) >= 3 and int(versionlist[1]) >= 6:
                        TestApply.skip_old_server = False

        policy = {}
        TestApply.client.index_integer_create('test', 'demo', 'age',
                                              'age_index', policy)
        policy = {}
        TestApply.client.index_integer_create('test', 'demo', 'age1',
                                              'age_index1', policy)

        policy = {}
        filename = "sample.lua"
        udf_type = 0

        status = TestApply.client.udf_put(filename, udf_type, policy)
        filename = "test_record_udf.lua"
        status = TestApply.client.udf_put(filename, udf_type, policy)
开发者ID:Kavec,项目名称:aerospike-client-python,代码行数:30,代码来源:test_apply.py

示例3: setup_class

    def setup_class(cls):

        print "setup class invoked..."
        hostlist, user, password = TestBaseClass.get_hosts()
        config = {
                'hosts': hostlist
                }
        if user == None and password == None:
            TestLList.client = aerospike.client(config).connect()
        else:
            TestLList.client = aerospike.client(config).connect(user, password)

        TestLList.key1 = ('test', 'demo', 'integer_llist_ky')

        TestLList.llist_integer = TestLList.client.llist(TestLList.key1,
                'integer_bin')

        TestLList.key2 = ('test', 'demo', 'string_llist_ky')

        TestLList.llist_string = TestLList.client.llist(TestLList.key2,
                'string_bin')

        TestLList.key3 = ('test', 'demo', 'float_llist_ky')

        TestLList.llist_float = TestLList.client.llist(TestLList.key3,
                'float_bin')
开发者ID:dreamflychen,项目名称:aerospike-client-python,代码行数:26,代码来源:test_llist.py

示例4: test_with_class_serializer_and_instance_serializer_with_unset_serializer

    def test_with_class_serializer_and_instance_serializer_with_unset_serializer(self):
        """
            Invoke put() for mixed data record with python serializer.
        """
        aerospike.set_serializer((lambda v: json.dumps(v)))
        aerospike.set_deserializer((lambda v: json.loads(v)))
        hostlist, user, password = TestBaseClass.get_hosts()
        method_config = {
            'hosts': hostlist
        }
        if user == None and password == None:
            client = aerospike.client(method_config).connect()
        else:
            client = aerospike.client(method_config).connect(user, password)
        key = ('test', 'demo', 16)
        try:
            TestPythonSerializer.client.remove(key)
        except:
            pass

        rec = {'normal': 1234, 'tuple': (1,2,3)}

        aerospike.unset_serializers()
        try:
            res = client.put(key, rec, serializer=aerospike.SERIALIZER_USER)
        except ClientError as exception:
            assert exception.code == -1
            assert exception.msg == "No serializer callback registered"
开发者ID:Fabma,项目名称:aerospike-client-python,代码行数:28,代码来源:test_zserializers.py

示例5: test_with_class_serializer_and_instance_serializer

    def test_with_class_serializer_and_instance_serializer(self):
        """
            Invoke put() for mixed data record with class and instance serializer.
        """
        aerospike.set_serializer((lambda v: json.dumps(v)))
        aerospike.set_deserializer((lambda v: json.loads(v)))
        hostlist, user, password = TestBaseClass.get_hosts()
        method_config = {
            'hosts': hostlist,
            'serialization': ((lambda v: marshal.dumps(v)), (lambda v: marshal.loads(v)))}
        if user == None and password == None:
            client = aerospike.client(method_config).connect()
        else:
            client = aerospike.client(method_config).connect(user, password)
        key = ('test', 'demo', 16)
        try:
            TestPythonSerializer.client.remove(key)
        except:
            pass

        rec = {'normal': 1234, 'tuple': (1,2,3)}
        res = client.put(key, rec, serializer=aerospike.SERIALIZER_USER)

        assert res == 0

        _, _, bins = client.get(key)

        # tuples JSON-encode to a list, and we use this fact to check which
        # serializer ran:
        assert bins == {'normal': 1234, 'tuple': (1,2,3)}
        client.remove(key)
开发者ID:Fabma,项目名称:aerospike-client-python,代码行数:31,代码来源:test_zserializers.py

示例6: test_with_unset_serializer_python_serializer

    def test_with_unset_serializer_python_serializer(self):
        """
            Invoke put() for mixed data record with python serializer and
            calling unset_serializers
        """
        aerospike.set_serializer((lambda v: json.dumps(v)))
        aerospike.set_deserializer((lambda v: json.loads(v)))
        hostlist, user, password = TestBaseClass.get_hosts()
        method_config = {
            'hosts': hostlist
        }
        if user == None and password == None:
            client = aerospike.client(method_config).connect()
        else:
            client = aerospike.client(method_config).connect(user, password)
        key = ('test', 'demo', 16)
        try:
            client.remove(key)
        except:
            pass

        rec = {'normal': 1234, 'tuple': (1,2,3)}

        aerospike.unset_serializers()
        res = client.put(key, rec, serializer=aerospike.SERIALIZER_PYTHON)
        
        assert res == 0

        _, _, bins = client.get(key)

        # tuples JSON-encode to a list, and we use this fact to check which
        # serializer ran:
        assert bins == {'normal': 1234, 'tuple': (1,2,3)}
        client.remove(key)
开发者ID:Fabma,项目名称:aerospike-client-python,代码行数:34,代码来源:test_zserializers.py

示例7: setup_method

    def setup_method(self, method):
        """
        Setup method.
        """
        hostlist, user, password = TestBaseClass.get_hosts()
        config = {'hosts': hostlist}
        if user == None and password == None:
            self.client = aerospike.client(config).connect()
        else:
            self.client = aerospike.client(config).connect(user, password)

        for i in xrange(19):
            key = ('test', u'demo', i)
            rec = {'name': 'name%s' % (str(i)), 'age': i}
            self.client.put(key, rec)

        key = ('test', u'demo', 122)
        list = [{"op": aerospike.OPERATOR_APPEND,
                "bin": bytearray("asd;adk\0kj", "utf-8"),
                "val": u"john"}];
        self.client.operate(key, list)

        key = ('test', u'demo', 'ldt_key')
        self.llist_bin = self.client.llist(key, 'llist_key')
        self.llist_bin.add(10)
开发者ID:Fabma,项目名称:aerospike-client-python,代码行数:25,代码来源:test_scan.py

示例8: test_builtin_with_instance_serializer_and_no_class_serializer

    def test_builtin_with_instance_serializer_and_no_class_serializer(self):

        #    Invoke put() for data record with builtin serializer and an
        #    instance serializer set
        hostlist, user, password = TestBaseClass.get_hosts()
        method_config = {
            'hosts': hostlist,
            'serialization': ((lambda v: json.dumps(v)), (lambda v: json.loads(v)))}
        if user == None and password == None:
            client = aerospike.client(method_config).connect()
        else:
            client = aerospike.client(method_config).connect(user, password)
        key = ('test', 'demo', 12)
        try:
            client.remove(key)
        except:
            pass

        rec = {'normal': 1234, 'tuple': (1,2,3)}

        res = client.put(key, rec, serializer=aerospike.SERIALIZER_PYTHON)

        assert res == 0

        _, _, bins = client.get(key)

        assert bins == {'normal': 1234, 'tuple': (1,2,3)}
        client.remove(key)
        client.close()
开发者ID:Fabma,项目名称:aerospike-client-python,代码行数:29,代码来源:test_zserializers.py

示例9: test_instance_serializer_and_no_class_serializer

    def test_instance_serializer_and_no_class_serializer(self):

        #    Invoke put() for record with no class serializer. There is an
        #    instance serializer
        hostlist, user, password = TestBaseClass.get_hosts()
        method_config = {
            'hosts': hostlist,
            'serialization': ((lambda v: json.dumps(v)), (lambda v: json.loads(v)))}
        if user == None and password == None:
            client = aerospike.client(method_config).connect()
        else:
            client = aerospike.client(method_config).connect(user, password)
        key = ('test', 'demo', 11)
        try:
            client.remove(key)
        except:
            pass

        rec = {'normal': 1234, 'tuple': (1,2,3)}

        res = client.put(key, rec, serializer=aerospike.SERIALIZER_USER)

        assert res == 0

        _, _, bins = client.get(key)

        # tuples JSON-encode to a list, and we use this fact to check which
        # serializer ran:
        assert bins == {'normal': 1234, 'tuple': [1,2,3]}
        client.remove(key)
        client.close()
开发者ID:Fabma,项目名称:aerospike-client-python,代码行数:31,代码来源:test_zserializers.py

示例10: setup_class

    def setup_class(cls):
        hostlist, user, password = TestBaseClass.get_hosts()
        config = {
            'hosts': hostlist,
            'lua':{'user_path': '/tmp/',
            'system_path':'../aerospike-client-c/lua/'}}
        if user == None and password == None:
            client = aerospike.client(config).connect()
        else:
            client = aerospike.client(config).connect(user, password)

        TestAggregate.skip_old_server = True
        versioninfo = client.info('version')
        for keys in versioninfo:
            for value in versioninfo[keys]:
                if value != None:
                    versionlist = value[value.find("build") + 6:value.find("\n")].split(".")
                    if int(versionlist[0]) >= 3 and int(versionlist[1]) >= 6:
                        TestAggregate.skip_old_server = False
        client.index_integer_create('test', 'demo', 'test_age',
                'test_demo_test_age_idx')
        client.index_integer_create('test', 'demo', 'age1', 'test_demo_age1_idx')
        time.sleep(2)

        filename = "stream_example.lua"
        udf_type = aerospike.UDF_TYPE_LUA
        status = client.udf_put(filename, udf_type)
        shutil.copyfile(filename, config['lua']['user_path'] +
            'stream_example.lua')
        client.close()
开发者ID:Fabma,项目名称:aerospike-client-python,代码行数:30,代码来源:test_aggregate.py

示例11: setup_class

    def setup_class(cls):
        hostlist, user, password = TestBaseClass.get_hosts()
        config = {'hosts': hostlist}
        if user == None and password == None:
            client = aerospike.client(config).connect()
        else:
            client = aerospike.client(config).connect(user, password)

        client.index_integer_create('test', 'demo', 'test_age',
                                              'age_index')
        client.index_string_create('test', 'demo', 'addr',
                                             'addr_index')
        client.index_integer_create('test', 'demo', 'age1',
                                              'age_index1')
        client.index_list_create('test', 'demo', 'numeric_list',
                                           aerospike.INDEX_NUMERIC,
                                           'numeric_list_index')
        client.index_list_create('test', 'demo', 'string_list',
                                           aerospike.INDEX_STRING,
                                           'string_list_index')
        client.index_map_keys_create('test', 'demo', 'numeric_map',
                                               aerospike.INDEX_NUMERIC,
                                               'numeric_map_index')
        client.index_map_keys_create('test', 'demo', 'string_map',
                                               aerospike.INDEX_STRING,
                                               'string_map_index')
        client.index_map_values_create('test', 'demo', 'numeric_map',
                                                 aerospike.INDEX_NUMERIC,
                                                 'numeric_map_values_index')
        client.index_map_values_create('test', 'demo', 'string_map',
                                                 aerospike.INDEX_STRING,
                                                 'string_map_values_index')
        client.index_integer_create('test', None, 'test_age_none', 
                                                'age_index_none')
开发者ID:Kavec,项目名称:aerospike-client-python,代码行数:34,代码来源:test_query.py

示例12: setup_method

    def setup_method(self, method):
        """
        Setup method.
        """

        hostlist, user, password = TestBaseClass.get_hosts()
        config = {
            'hosts': hostlist,
            'lua':{'user_path': '/tmp/',
            'system_path':'../aerospike-client-c/lua/'}}
        if TestBaseClass.user == None and TestBaseClass.password == None:
            self.client = aerospike.client(config).connect()
        else:
            self.client = aerospike.client(config).connect(
                TestBaseClass.user, TestBaseClass.password)

        for i in xrange(5):
            key = ('test', 'demo', i)
            rec = {
                'name': 'name%s' % (str(i)),
                'addr': 'name%s' % (str(i)),
                'test_age': i,
                'no': i
            }
            self.client.put(key, rec)
开发者ID:Fabma,项目名称:aerospike-client-python,代码行数:25,代码来源:test_aggregate.py

示例13: setup_class

    def setup_class(cls):
        """
        Setup method.
        """
        hostlist, user, password = TestBaseClass.get_hosts()
        config = {'hosts': hostlist}
        if user == None and password == None:
            TestOperate.client = aerospike.client(config).connect()
        else:
            TestOperate.client = aerospike.client(config).connect(user,
                                                                  password)
        config_no_typechecks = {'hosts': hostlist, 'strict_types': False}
        if user == None and password == None:
            TestOperate.client_no_typechecks = aerospike.client(config_no_typechecks).connect()
        else:
            TestOperate.client_no_typechecks = aerospike.client(config_no_typechecks).connect(user, password)

        TestOperate.skip_old_server = True
        versioninfo = TestOperate.client.info('version')
        for keys in versioninfo:
            for value in versioninfo[keys]:
                if value != None:
                    versionlist = value[value.find("build") + 6:value.find("\n")].split(".")
                    if int(versionlist[0]) >= 3 and int(versionlist[1]) >= 6:
                        TestOperate.skip_old_server = False
开发者ID:Fabma,项目名称:aerospike-client-python,代码行数:25,代码来源:test_operate.py

示例14: setup_class

 def setup_class(cls):
     """
     Setup method.
     """
     hostlist, user, password = TestBaseClass.get_hosts()
     config = {'hosts': hostlist}
     if user == None and password == None:
         TestExists.client = aerospike.client(config).connect()
     else:
         TestExists.client = aerospike.client(config).connect(user, password)
开发者ID:Kavec,项目名称:aerospike-client-python,代码行数:10,代码来源:test_exists.py

示例15: setup_class

 def setup_class(cls):
     """
     Setup method.
     """
     TestGetMany.hostlist, TestGetMany.user, TestGetMany.password = TestBaseClass.get_hosts()
     config = {"hosts": TestGetMany.hostlist}
     if TestGetMany.user == None and TestGetMany.password == None:
         TestGetMany.client = aerospike.client(config).connect()
     else:
         TestGetMany.client = aerospike.client(config).connect(TestGetMany.user, TestGetMany.password)
开发者ID:Fabma,项目名称:aerospike-client-python,代码行数:10,代码来源:test_get_many.py


注:本文中的test_base_class.TestBaseClass类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。