How to use do_PUT method in lettuce-tools

Best Python code snippet using lettuce-tools_python

gift.py

Source:gift.py Github

copy

Full Screen

1# encoding: utf-82from common import uid, qz_path, pprint3import sys4sys.path.insert(0, qz_path)5import apps.settings_stg as settings_stg6from django.core.management import setup_environ7setup_environ(settings_stg)8from apps.models.user_gift import UserGift9from apps.models.user_login import UserLogin10from apps.models.user_base import UserBase11from apps.config.game_config import game_config12from apps.models.user_cards import UserCards13from apps.models.user_property import UserProperty14from apps.models.user_dungeon import UserDungeon15from apps.models.user_pack import UserPack16from apps.models.user_property import UserProperty17from apps.models.user_equips import UserEquips18from apps.models.collection import UserCollection19import json20import copy21import datetime22from apps.common.utils import create_gen_id23from apps.common import utils, tools24import time25from apps.models import data_log_mod26from apps.models import GameModel27ug = UserGift.get_instance(uid)28rk_user = UserBase.get(uid)29ul = rk_user.user_login30def show_gift():31 ug = UserGift.get_instance(uid)32 pprint(ug.gift_list)33def add_gift():34 ug = UserGift.get_instance(uid)35 ug.add_open_server_gift({'gold': 50, '1_card':1}, 8)36 ug.do_put()37#add_gift()38def get_gift():39 ug.get_gift('2')40 ug.do_put()41#get_gift()42#show_gift()43def clear_all_gifts():44 ug.gift_list = {}45 ug.do_put()46#clear_all_gifts()47def clear_open_server():48 49 #print(ug.open_server_record)50 #ug.clear_open_server_gift()51 #ug.do_put()52 print(ug.open_server_record)53#clear_open_server()54def _got_days(ug):55 '''已领取开服奖励的天数'''56 days = 057 for info in ug.open_server_record['gifts'].values():58 if info['has_got']:59 days += 160 return days61def show_open_server_gift(rk_user, params):62 '''63 返回开服奖励的礼包64 '''65 ug = rk_user.user_gift66 ul = rk_user.user_login67 add_time = utils.timestamp_toDatetime(rk_user.add_time)68 now = datetime.datetime.now()69 today = utils.get_today_str()70 # 初始化71 if not ug.open_server_record:72 # 'gifts'按领取天数记录奖励是否领取,比如登录过10天,但只领过一次,这时gifts记录的是['1']['has_got']=True ,其他为False73 # 因为每天只能领取一次,'date_info'用来按日期记录哪天是否已领过一次74 ug.open_server_record = {'gifts': {}, 'date_info': {}}75 for day in range(1, 32):76 ug.open_server_record['gifts'].setdefault(str(day), {})['has_got'] = False77 ug.do_put()78 # 账号注册已达45天(包括注册当天),或者全部领取了,则清空全部开服礼包79 if (now - add_time).days + 1 > 45 or ug.has_got_all_open_server_gifts():80 ug.clear_open_server_gift()81 return 11, {'msg': utils.get_msg('gift','clear_open_server')}82 awards = game_config.loginbonus_config['open_server_gift'].get('awards', {})83 data = {'gifts': {}}84 for days, award in awards.items():85 data['gifts'].setdefault(days, {})['awards'] = award86 #data['gifts'][days]['has_got'] = ug.open_server_record.setdefault(days, {}).setdefault('has_got', False)87 data['gifts'][days]['has_got'] = ug.open_server_record['gifts'][days]['has_got']88 # 给前端现实能否领取,不需存在model中89 #data['gifts'][days]['can_get'] = True if ul.total_login_num >= int(days) else False90 if int(days) == _got_days(ug)+1 and not ug.open_server_record['date_info'].get(today, False):91 data['gifts'][days]['can_get'] = True92 else:93 data['gifts'][days]['can_get'] = False 94 ug.do_put()95 return 0, data96#pprint(show_open_server_gift(rk_user, {}))97def get_open_server_gift(rk_user, params):98 '''99 领取开服礼包中的奖励100 参数101 params['day'] 第几次领102 '''103 #day = params['day']104 day = '5'105 ug = rk_user.user_gift106 ul = rk_user.user_login107 awards = game_config.loginbonus_config['open_server_gift'].get('awards', {})108 if day not in awards.keys():109 return 11, {'msg': utils.get_msg('gift', 'gift_not_exist')}110 the_gift = ug.open_server_record['gifts'][day]111 if the_gift['has_got']:112 return 11, {'msg': utils.get_msg('gift', 'gift_has_got')}113 today = utils.get_today_str()114 if ug.open_server_record['date_info'].get(today, False):115 return 11, {'msg': utils.get_msg('gift', 'today_has_signed_in')}116 # 按顺序领取117 if int(day) != _got_days(ug)+1:118 return 11, {'msg': utils.get_msg('gift', 'signin_in_turn')}119 data = tools.add_things(120 rk_user, 121 [{"_id": goods, "num": awards[goods]} for goods in awards if goods],122 where="open_server_gift"123 )124 the_gift['has_got'] = True125 # 因为每天只能领取一次,'date_info'用来按日期记录哪天是否已领过一次126 ug.open_server_record['date_info'][today] = True 127 ug.do_put()128 return 0, data129#print('get_open_server_gift(rk_user, {})')130#pprint(get_open_server_gift(rk_user, {}))131#print('show_open_server_gift(rk_user, {})')132#pprint(show_open_server_gift(rk_user, {}))133def test_clear_open_server_gift():134 ug.clear_open_server_gift()135 ug.do_put()136#test_clear_open_server_gift()137def test_init_open_server_gift():138 ul.init_open_server_gift()139 ug.do_put() 140#test_init_open_server_gift()141def test_has_got_today_gift():142 return ug.has_got_today_open_server_gift()143#print 'has got: ',test_has_got_today_gift()144def _get_total_sign_in_days(ug):145 days = 0146 for info in ug.sign_in_record.values():147 if info['has_got']:148 days += 1149 return days150def get_sign_in_gift(rk_user, params):151 '''152 领取签到奖励153 params['day'] 当月日期,作为id使用154 '''155 day = '5' 156 ug = rk_user.user_gift157 now = datetime.datetime.now()158 month = str(now.month)159 today = str(now.day)160 print ' _get_total_sign_in_days(ug)', _get_total_sign_in_days(ug)161 if day != str(_get_total_sign_in_days(ug) + 1):162 return 11, {'msg': utils.get_msg('gift', 'signin_in_turn')}163 if ug.sign_in_record[day]['has_got']:164 return 11, {'msg': utils.get_msg('gift', 'gift_has_got')}165 if ug.sign_in_record[today].get('today_has_signed_in', False):166 return 11, {'msg': utils.get_msg('gift', 'today_has_signed_in')} 167 # 添加奖励168 awards = game_config.loginbonus_config['sign_in_bonus'].get(month, {}).get(day, {})169 data = tools.add_things(170 rk_user, 171 [{"_id": goods, "num": awards[goods]} for goods in awards if goods],172 where="open_server_gift"173 )174 ug.sign_in_record[day]['has_got'] = True175 # 每天只能签到一次,此字段用来后端判断当天是否已签到过176 ug.sign_in_record[today]['today_has_signed_in'] = True177 ug.do_put() 178 rk_user.user_property.do_put()179 rk_user.user_pack.do_put()180 rk_user.user_cards.do_put()181 rk_user.user_equips.do_put() 182 return 0, data183#pprint(ug.sign_in_record)184pprint(get_sign_in_gift(rk_user, {}))185def show_sign_in_gift(rk_user, params):186 '''187 返回前端当月签到奖励信息188 '''189 now = datetime.datetime.now()190 month = str(now.month)191 #month = '1' 192 today = str(now.day)193 awards = game_config.loginbonus_config['sign_in_bonus'].get(month, {})194 if not awards:195 return 11, {'msg': utils.get_msg('gift', 'no_sign_in_gift')}196 data = {'gifts': {}}197 ug = rk_user.user_gift198 # 当月总签到天数199 sign_in_days = _get_total_sign_in_days(ug)200 # 当月总登陆天数201 month_login_days = rk_user.user_login.month_total_login202 # 新的月份,领取信息全部置False203 if today == '1':204 for n in range(31):205 ug.sign_in_record[str(n)]['has_got'] = False206 ug.sign_in_record[str(n)]['today_has_signed_in'] = False207 for day, award in awards.items():208 data['gifts'].setdefault(day, {})['awards'] = award209 data['gifts'][day]['has_got'] = ug.sign_in_record.setdefault(day, {}).setdefault('has_got', False)210 #if int(day) == sign_in_days+1:211 if int(day) == sign_in_days+1 and not ug.sign_in_record.setdefault(today, {}).setdefault('today_has_signed_in', False):212 data['gifts'][day]['can_get'] = True213 else:214 data['gifts'][day]['can_get'] = False215 ug.do_put()216 data['total_sign_in_days'] = _get_total_sign_in_days(ug)217 data['month_login_days'] = month_login_days218 return 0, data ...

Full Screen

Full Screen

property.py

Source:property.py Github

copy

Full Screen

1# encoding: utf-82from common import uid, qz_path, pprint3import sys4sys.path.insert(0, qz_path)5import apps.settings_stg as settings_stg6from django.core.management import setup_environ7setup_environ(settings_stg)8from apps.models.user_gift import UserGift9from apps.models.user_login import UserLogin10from apps.models.user_base import UserBase11from apps.config.game_config import game_config12from apps.models.user_cards import UserCards13from apps.models.user_property import UserProperty14from apps.models.user_dungeon import UserDungeon15from apps.models.user_pack import UserPack16from apps.models.user_property import UserProperty17from apps.models.user_equips import UserEquips18from apps.models.collection import UserCollection19from apps.models.user_souls import UserSouls20import json21import copy22import datetime23from apps.common.utils import create_gen_id24from apps.common import utils25import time26from apps.models import data_log_mod27from apps.models import GameModel28#uid = '9100214781'29game_config.subareas_conf()30game_config.set_subarea('1')31up = UserProperty.get_instance(uid)32pprint(up.property_info)33def show_property_fields():34 user_property_obj = UserProperty.get_instance(uid)35 print 'user_property_obj.property_info','-'*5036 pprint(user_property_obj.property_info)37 #user_property_obj.property_info['wipe_out_times'] = 038 #user_property_obj.do_put()39 '''40 print 'user_property_obj.charge_award_info','-'*5041 print user_property_obj.charge_award_info42 print 'user_property_obj.consume_award_info','-'*5043 print user_property_obj.consume_award_info44 print 'user_property_obj.month_item_info','-'*5045 print user_property_obj.month_item_info46 '''47show_property_fields()48def modify_today_str():49 up.property_info['recover_times']['today_str'] = '2014-11-15'50 up.do_put()51#modify_today_str()52def add_stamina():53 up.add_stamina(100)54 up.do_put()55#add_stamina()56def t_give_award():57 user_property_obj = UserProperty.get_instance(uid)58 user_property_obj.give_award({'gold':3})59 user_property_obj.do_put()60#t_give_award()61def property_real_pvp():62 user_property_obj = UserProperty.get_instance(uid)63 user_real_pvp = user_property_obj.user_base.user_real_pvp64 print user_real_pvp65#property_real_pvp()66def ttest_give_award():67 user_property = UserProperty.get_instance(uid)68 uc = UserCards.get_instance(uid) 69 ue = UserEquips.get_instance(uid) 70 up = UserPack.get_instance(uid)71 us = UserSouls.get_instance(uid) 72 #award = {'card':{'1_card':1}}73 #award = {'equip':{'13001_equip': 2}}74 #award = {'props':{'1_props':2}}75 #award = {'soul':{'card':{'1_card':1}}}76 award = {'soul':{'equip':{'13001_equip':1}}}77 print user_property.test_give_award(award)78 uc.do_put() 79 ue.do_put()80 up.do_put()81 us.do_put()82#ttest_give_award()83 84def add_vip_lv():85 user_property = UserProperty.get_instance(uid)86 user_property.add_charge_sumcoin(10) # vip lv 187 #user_property.property_info["charge_sumcoin"] = 0 # vip lv 0 88 user_property.do_put() 89#add_vip_lv()90def modify_vip_lv(lv):91 '''vip等级是通过玩家充值元宝的总数来判断的,没vip等级这个字段,所以是间接改'''92 vip_conf = game_config.user_vip_config[str(lv)] 93 coin = vip_conf['coin']94 up = UserProperty.get_instance(uid)95 #up.add_charge_sumcoin(coin)96 up.property_info["charge_sumcoin"] = coin97 up.do_put()98#modify_vip_lv(1)99def set_newbie():100 upp = up.property_info101 #upp['newbie'] = False 102 #upp['newbie_steps'] = 63 103 #upp['stamina'] = 100104 up.do_put()105 print upp['newbie_steps'], upp['newbie']106#set_newbie()107def get_info():108 print up.property_info109 print up.vip_cur_level110#get_info() 111 112def modify_attr():113 up = UserProperty.get_instance(uid)114 up.property_info['lv'] = 43115 up.do_put()...

Full Screen

Full Screen

new_account.py

Source:new_account.py Github

copy

Full Screen

1# encoding: utf-82from common import uid, qz_path3import sys4sys.path.insert(0, qz_path)5import apps.settings_stg as settings_stg6from django.core.management import setup_environ7setup_environ(settings_stg)8from apps.models.user_gift import UserGift9from apps.models.user_login import UserLogin10from apps.models.user_base import UserBase11from apps.config.game_config import game_config12from apps.models.user_cards import UserCards13from apps.models.user_property import UserProperty14from apps.models.user_dungeon import UserDungeon15from apps.models.user_pack import UserPack16from apps.models.user_property import UserProperty17from apps.models.user_equips import UserEquips18from apps.models.collection import UserCollection19from apps.models.user_souls import UserSouls20from apps.models.user_real_pvp import UserRealPvp21import json22import copy23import datetime24from apps.common.utils import create_gen_id25from apps.common import utils26import time27from apps.models import data_log_mod28from apps.models import GameModel29game_config.subareas_conf()30game_config.set_subarea('1')31up = UserProperty.get_instance(uid)32def add_honor():33 urp = UserRealPvp.get_instance(uid)34 urp.add_honor(99999)35 urp.do_put()36 print urp.honor37def add_vip_lv():38 user_property = UserProperty.get_instance(uid)39 user_property.add_charge_sumcoin(10) # vip lv 140 #user_property.property_info["charge_sumcoin"] = 0 # vip lv 0 41 user_property.do_put() 42#add_vip_lv()43def set_newbie():44 upp = up.property_info45 upp['newbie'] = False 46 upp['newbie_steps'] = 63 47 #upp['stamina'] = 10048 up.do_put()49 print upp['newbie_steps'], upp['newbie']50def set_user_lv():51 up.property_info['lv'] = 40 52 up.do_put()53'''新账号做一些操作,方便调试'''54def add_equip():55 ue = UserEquips.get_instance(uid)56 ue.add_equip('12001_equip') # 4个装备都是火云套57 ue.add_equip('22001_equip')58 ue.add_equip('32001_equip')59 ue.add_equip('42001_equip')60 ue.add_equip('53003_equip') # 诗经61 ue.add_equip('63003_equip') # 沙里飞62 ue.do_put()63def new_account():64 add_equip()65 set_newbie()66 add_honor()67 set_user_lv()68 pass69new_account()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lettuce-tools automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful