def test_array(self): location1 = Object('me.hourui.echo.bean.Location') location1['province'] = '江苏省' location1['city'] = '南京市' location1['street'] = '软件大道' location2 = Object('me.hourui.echo.bean.Location') location2['province'] = '浙江省' location2['city'] = '杭州市' location2['street'] = '余杭区' user1 = Object('me.hourui.echo.bean.User1') user1['name'] = '张三' user2 = Object('me.hourui.echo.bean.User1') user2['name'] = '李四' array = Object('me.hourui.echo.bean.Object4Array') array['locations'] = [location1, location2] array['users'] = [user1, user2] array['strings'] = [ '这是', '一个', '不可', '重复', '重复', '重复', '重复', '的', '列表' ] dubbo_cli = DubboClient('me.hourui.echo.provider.Echo', host='127.0.0.1:20880') dubbo_cli.call('test4', [['你好', '我好'], [2, 3, 3, 3], array])
def test_pc_es_center(self): zk = ZkRegister('172.19.71.7:2181') dubbo_cli = DubboClient('com.qianmi.pc.es.api.EsGoodsQueryProvider', zk_register=zk) goods_query_request = Object( 'com.qianmi.pc.es.api.request.EsGoodsQueryRequest', values={ 'chainMasterId': 'A859315', 'fromSys': 2, 'pageNum': 50 }) result = dubbo_cli.call('query', goods_query_request) pretty_print(result) goods_list_by_id_request = Object( 'com.qianmi.pc.es.api.request.EsGoodsListByIdStringRequest', values={ 'chainMasterId': 'A859315', 'idString': 'g51426:g51422' }) result = dubbo_cli.call('listByIdString', goods_list_by_id_request) pretty_print(result) product_request = Object( 'com.qianmi.pc.es.api.request.EsGoodsListByIdStringRequest', values={ 'chainMasterId': 'A000000', 'idString': 'NotUsed:g10529' }) result = dubbo_cli.call('listByIdString', product_request) pretty_print(result)
def test_pc(self): zk = ZkRegister('172.21.4.71:2181') spu_query_provider = DubboClient( 'com.qianmi.pc.item.api.spu.SpuQueryProvider', zk_register=zk) channel = Object('com.qianmi.pc.base.api.constants.ChannelEnum', values={'name': 'D2C'}) spu_query_request = Object( 'com.qianmi.pc.item.api.spu.request.SpuQueryRequest') spu_query_request['chainMasterId'] = 'A000000' spu_query_request['channel'] = channel spu_query_request['pageSize'] = 20 result = spu_query_provider.call('query', spu_query_request) # pretty_print(result) total = result['totalCount'] print total print len(result['dataList']) data_list = result['dataList'] for data in data_list: spu_id = data['spuId'] spu_desc_request = Object( 'com.qianmi.pc.item.api.spu.request.SpuDescriptionGetRequest') spu_desc_request['spuId'] = spu_id print spu_id spu_desc_request['chainMasterId'] = 'A000000' pretty_print( spu_query_provider.call('getDescription', spu_desc_request)) for data in data_list: spu_request = Object( 'com.qianmi.pc.item.api.spu.request.SpuGetRequest') spu_request['chainMasterId'] = 'A000000' spu_request['spuId'] = data['spuId'] spu_request['channelEnum'] = channel pretty_print(spu_query_provider.call('getById', spu_request)) spu_ids = map(lambda spu: spu['spuId'], data_list) spu_ids_request = Object( 'com.qianmi.pc.item.api.spu.request.SpuListByIdsRequest') spu_ids_request['chainMasterId'] = 'A000000' spu_ids_request['channelEnum'] = channel spu_ids_request['spuIds'] = spu_ids batch_spu_request = spu_query_provider.call('listByIds', spu_ids_request) pretty_print(batch_spu_request)
def test_auto_rule(self): dubbo_cli = DubboClient( 'com.qianmi.common.autorule.api.WarehouseProvider', host='172.21.36.82:20880') delivery_man_query = Object( 'com.qianmi.common.autorule.api.request.warehouse.DeliveryManQueryRequest' ) delivery_man_query['userId'] = 'A1035712' delivery_man_query['warehouseId'] = '15373' delivery_man_query['deliveryManId'] = 'E132862' result = dubbo_cli.call('getWarehouseByDeliveryMan', delivery_man_query) pretty_print(result) delivery_area_query = Object( 'com.qianmi.common.autorule.api.request.warehouse.DeliveryAreaQueryRequest' ) delivery_area_query['userId'] = 'A1035527' delivery_area_query['warehouseId'] = '15346' delivery_area = Object( 'com.qianmi.common.autorule.api.bean.DeliveryArea') delivery_area['provinceName'] = '上海' delivery_area_query['deliveryArea'] = delivery_area result = dubbo_cli.call('getWarehouseByDeliveryArea', delivery_area_query) pretty_print(result) warehouse_type_request = Object( 'com.qianmi.common.autorule.api.request.warehouse.GetWarehouseRuleTypeRequest' ) warehouse_type_request['userId'] = 'A1035527' warehouse_type_request['warehouseId'] = '15346' result = dubbo_cli.call('getWarehouseRuleType', warehouse_type_request) pretty_print(result) zk_cli = ZkRegister('172.21.4.71:2181') dubbo_cli = DubboClient( 'com.qianmi.common.autorule.api.OrderRuleProvider', zk_register=zk_cli) order_query = Object( 'com.qianmi.common.autorule.api.request.order.OrderListByCustomerServiceIdRequest' ) order_query['userId'] = 'A1035527' order_query['customerServiceId'] = 'E132802' result = dubbo_cli.call('listOrdersByCustomerServiceId', order_query) pretty_print(result)
def test_run_default(self): zk = ZkRegister('172.19.71.7:2181') dubbo_cli = DubboClient('com.qianmi.pc.es.api.EsGoodsQueryProvider', zk_register=zk) goods_query_request = Object('com.qianmi.pc.es.api.request.EsGoodsQueryRequest', values={ 'chainMasterId': 'A859315', 'fromSys': 2, 'pageNum': 1 }) result = dubbo_cli.call('query', goods_query_request) pretty_print(result)
def test(self): import json from dubbo.client import DubboClient, ZkRegister zk = ZkRegister('172.30.41.18:2181') product_service = DubboClient( 'hry.exchange.api.remote.account.RemoteExProductService', group='exchange', zk_register=zk) customer = Object('hry.model.exchange.ExProduct', { 'id': 1, 'withdrawAlertMin': '12.01' }, {'withdrawAlertMin': 'java.math.BigDecimal'}) result = product_service.call('update', customer) print(json.dumps(result))
def test_object(self): new_user = Object('me.hourui.echo.bean.NewUser') user1 = Object('me.hourui.echo.bean.User1') user2 = Object('me.hourui.echo.bean.User2') user3 = Object('me.hourui.echo.bean.User3') user4 = Object('me.hourui.echo.bean.User4') user5 = Object('me.hourui.echo.bean.User5') user6 = Object('me.hourui.echo.bean.User6') user7 = Object('me.hourui.echo.bean.User7') user8 = Object('me.hourui.echo.bean.User8') user9 = Object('me.hourui.echo.bean.User9') user10 = Object('me.hourui.echo.bean.User10') user11 = Object('me.hourui.echo.bean.User11') user12 = Object('me.hourui.echo.bean.User12') user13 = Object('me.hourui.echo.bean.User13') location = Object('me.hourui.echo.bean.Location') location['province'] = '江苏省' location['city'] = '南京市' location['street'] = '软件大道' name = Object('me.hourui.echo.bean.Name') name['firstName'] = '隔壁的' name['lastName'] = '王叔叔' employee = Object('me.hourui.echo.bean.retail.Employee') employee['id'] = 'A137639' employee['name'] = '我勒个去居然不能用emoji啊' lock = Object('me.hourui.echo.bean.retail.Lock') lock['lockReason'] = '加锁的原因是什么呢?🤔' lock['employee'] = employee lock['locked'] = True new_user['user1'] = user1 new_user['user2'] = user2 new_user['user3'] = user3 new_user['user4'] = user4 new_user['user5'] = user5 new_user['user6'] = user6 new_user['user7'] = user7 new_user['user8'] = user8 new_user['user9'] = user9 new_user['user10'] = user10 new_user['user11'] = user11 new_user['user12'] = user12 new_user['user13'] = user13 new_user['location'] = location new_user['name'] = name new_user['lock'] = lock result = self.dubbo.call( 'test1', [new_user, name, '一个傻傻的用于测试的字符串', location, lock]) # result = dubbo.call('echo23') pretty_print(result)