How to use update_stage method in localstack

Best Python code snippet using localstack_python

ArkPlanner.py

Source:ArkPlanner.py Github

copy

Full Screen

...192 assert len(self.stages_ap_cost) == len(self.stages_lst) == len(193 self.stages_id_to_idx)194195 def update_stages(self):196 self.update_stage({'4001': 3480}, 'sub_04-2-3', 'S4-6', 21)197 self.update_stage({'4001': 1700}, 'wk_melee_1', 'CE-1', 10)198 self.update_stage({'4001': 2800}, 'wk_melee_2', 'CE-2', 15)199 self.update_stage({'4001': 4100}, 'wk_melee_3', 'CE-3', 20)200 self.update_stage({'4001': 5700}, 'wk_melee_4', 'CE-4', 25)201 self.update_stage({'4001': 7500}, 'wk_melee_5', 'CE-5', 30)202 # self.update_stage({'4006': 21}, 'wk_toxic_1', 'AP-1', 10)203 # self.update_stage({'4006': 21}, 'wk_toxic_2', 'AP-2', 15)204 # self.update_stage({'4006': 21}, 'wk_toxic_3', 'AP-3', 20)205 # self.update_stage({'4006': 21}, 'wk_toxic_4', 'AP-4', 25)206 self.update_stage({'4006': 21, '4001': 360}, 'wk_toxic_5', 'AP-5', 30)207 self.update_stage({'3113': 0.5, '3114': 3, '4001': 360},208 'wk_armor_5', 'SK-5', 30)209 self.update_stage({'2002': 1, '2003': 1, '2004': 3,210 '4001': 360}, 'wk_kc_5', 'LS-5', 30)211212 self.update_stage(213 {'3231': 0.5, '3261': 0.5, '4001': 216}, 'pro_a_1', 'PR-A-1', 18)214 self.update_stage(215 {'3241': 0.5, '3251': 0.5, '4001': 216}, 'pro_b_1', 'PR-B-1', 18)216 self.update_stage(217 {'3211': 0.5, '3271': 0.5, '4001': 216}, 'pro_c_1', 'PR-C-1', 18)218 self.update_stage(219 {'3221': 0.5, '3281': 0.5, '4001': 216}, 'pro_d_1', 'PR-D-1', 18)220 self.update_stage(221 {'3232': 0.5, '3262': 0.5, '4001': 432}, 'pro_a_2', 'PR-A-2', 36)222 self.update_stage(223 {'3242': 0.5, '3252': 0.5, '4001': 432}, 'pro_b_2', 'PR-B-2', 36)224 self.update_stage(225 {'3212': 0.5, '3272': 0.5, '4001': 432}, 'pro_c_2', 'PR-C-2', 36)226 self.update_stage(227 {'3222': 0.5, '3282': 0.5, '4001': 432}, 'pro_d_2', 'PR-D-2', 36)228229 def update_stage(self, drop_dct, stage_id=None, stage_name=None, ap_cost=None):230 if stage_id == None:231 stage_id = self.stages_name_to_id[stage_name]232 if stage_name == None:233 stage_name = self.stages_id_to_name[stage_id]234 if ap_cost == None:235 ap_cost = self.stages_ap_cost[stage_id]236237 if stage_id not in self.stages_lst:238 stage_idx = len(self.stages_lst)239 self.stages_lst.append(stage_id)240 self.stages_id_to_idx[stage_id] = stage_idx241 self.stages_name_to_id[stage_name] = stage_id242 self.stages_id_to_name[stage_id] = stage_name243 self.stages_ap_cost[stage_id] = ap_cost ...

Full Screen

Full Screen

class_tests.py

Source:class_tests.py Github

copy

Full Screen

...14 progress_log.save()15 self.assertEqual(progress_log.total_stages, 1, "one stage")16 self.assertEqual(progress_log.end_time, None, "end_time not set")17 self.assertEqual(progress_log.completed, False, "completed is False")18 def test_update_stage(self):19 # Create the object20 progress_log = UpdateProgressLog(process_name="test_process", total_stages=1)21 progress_log.save()22 # Complete the process23 progress_log.update_stage("test_stage", 0.5)24 self.assertEqual(progress_log.stage_percent, 0.5, "stage_percent set properly")25 self.assertEqual(progress_log.process_percent, 0.5, "process_percent set properly")26 self.assertEqual(progress_log.completed, False, "completed is False")27 def test_cancel_current_stage(self):28 # Create the object29 progress_log = UpdateProgressLog(process_name="test_process", total_stages=1)30 progress_log.save()31 progress_log.update_stage("test_stage", 0.5)32 # Complete the process33 progress_log.cancel_current_stage()34 self.assertEqual(progress_log.stage_percent, 0., "stage_percent is 0")35 self.assertEqual(progress_log.process_percent, 0., "process_percent is 0")36 self.assertEqual(progress_log.total_stages, 1, "Should still have one stage after cancel.")37 self.assertEqual(progress_log.stage_name, None, "stage name is None")38 self.assertEqual(progress_log.completed, False, "completed is False")39 self.assertEqual(progress_log.end_time, None, "end_time is not set")40 def test_update_total_stages(self):41 # Create the object42 progress_log = UpdateProgressLog(process_name="test_process", total_stages=1)43 progress_log.save()44 progress_log.update_stage("test_stage", 0.5)45 # Complete the process46 progress_log.update_total_stages(10)47 self.assertEqual(progress_log.total_stages, 10, "no stages")48 self.assertEqual(progress_log.stage_percent, 0.5, "stage_percent is 0.05")49 self.assertEqual(progress_log.process_percent, 0.05, "process_percent is 0.05")50 self.assertEqual(progress_log.stage_name, "test_stage", "stage name still set")51 self.assertEqual(progress_log.completed, False, "completed is False")52 self.assertEqual(progress_log.end_time, None, "end_time is not set")53 def test_cancel_progress(self):54 # Create the object55 progress_log = UpdateProgressLog(process_name="test_process", total_stages=1)56 progress_log.save()57 # Complete the process58 progress_log.cancel_progress()59 self.assertTrue(abs(datediff(progress_log.end_time, datetime.datetime.now())) < 10, "end time is within 10 seconds")60 self.assertEqual(progress_log.completed, False, "completed is False")61 def test_completion(self):62 # Create the object63 progress_log = UpdateProgressLog(process_name="test_process", total_stages=1)64 progress_log.save()65 # Complete the process66 progress_log.mark_as_completed()67 self.assertTrue(abs(datediff(progress_log.end_time, datetime.datetime.now())) < 10, "end time is within 10 seconds")68 self.assertEqual(progress_log.stage_percent, 1., "stage_percent==1")69 self.assertEqual(progress_log.process_percent, 1., "proces_percent==1")70 self.assertEqual(progress_log.completed, True, "completed is False")71class TestMultiStageUpdate(unittest.TestCase):72 """73 """74 def test_create(self):75 # Create the object76 progress_log = UpdateProgressLog(process_name="test_process", total_stages=10)77 progress_log.save()78 self.assertEqual(progress_log.total_stages, 10, "10 stages stage")79 self.assertEqual(progress_log.end_time, None, "end_time not set")80 self.assertEqual(progress_log.completed, False, "completed is False")81 def test_update_stage(self):82 # Create the object83 progress_log = UpdateProgressLog(process_name="test_process", total_stages=10)84 progress_log.save()85 # Complete the process86 progress_log.update_stage("test_stage", 0.5)87 self.assertEqual(progress_log.stage_percent, 0.5, "stage_percent set properly")88 self.assertEqual(progress_log.process_percent, 0.05, "process_percent set properly")89 self.assertEqual(progress_log.completed, False, "completed is False")90 def test_dual_update_stage(self):91 # Create the object92 progress_log = UpdateProgressLog(process_name="test_process", total_stages=10)93 progress_log.save()94 # Complete the process95 progress_log.update_stage("test_stage", 0.25)96 progress_log.update_stage("test_stage2", 0.5) # completes stage 197 self.assertEqual(progress_log.stage_percent, 0.5, "stage_percent set properly")98 self.assertTrue(abs(progress_log.process_percent - 0.15) < 1E10, "process_percent is 0.15")99 self.assertEqual(progress_log.completed, False, "completed is False")100 def test_cancel_current_stage(self):101 # Create the object102 progress_log = UpdateProgressLog(process_name="test_process", total_stages=10)103 progress_log.save()104 progress_log.update_stage("test_stage", 0.25)105 progress_log.update_stage("test_stage2", 0.5) # completes stage 1106 # Complete the process107 progress_log.cancel_current_stage()108 self.assertEqual(progress_log.stage_percent, 0., "stage_percent is 0")109 self.assertTrue(abs(progress_log.process_percent - 0.1) < 1E10, "process_percent is 0.1")110 self.assertEqual(progress_log.total_stages, 10, "Should still have 10 stages after cancel.")111 self.assertEqual(progress_log.stage_name, None, "stage name is None")112 self.assertEqual(progress_log.completed, False, "completed is False")113 self.assertEqual(progress_log.end_time, None, "end_time is not set")114 def test_update_total_stages(self):115 # Create the object116 progress_log = UpdateProgressLog(process_name="test_process", total_stages=10)117 progress_log.save()118 progress_log.update_stage("test_stage", 0.5)119 # Complete the process120 progress_log.update_total_stages(20)121 self.assertEqual(progress_log.total_stages, 20, "Should have 20 stages after updating total stages.")122 self.assertEqual(progress_log.stage_percent, 0.5, "stage_percent is 0.025")123 self.assertTrue(abs(progress_log.process_percent - 0.025) < 1E10, "process_percent is 0.25")124 self.assertEqual(progress_log.stage_name, "test_stage", "stage name still set")125 self.assertEqual(progress_log.completed, False, "completed is False")126 self.assertEqual(progress_log.end_time, None, "end_time is not set")127 def test_update_total_stages_in_progress(self):128 # Create the object129 progress_log = UpdateProgressLog(process_name="test_process", total_stages=10)130 progress_log.save()131 progress_log.update_stage("test_stage", 0.25)132 progress_log.update_stage("test_stage2", 0.5)133 # Complete the process134 progress_log.update_total_stages(20)135 self.assertEqual(progress_log.total_stages, 20, "Should have 20 stages after updating total stages.")136 self.assertEqual(progress_log.stage_percent, 0.5, "stage_percent is 0.05")137 self.assertTrue(abs(progress_log.process_percent - 0.075) < 1E10, "process_percent is 0.075")138 self.assertEqual(progress_log.stage_name, "test_stage2", "stage name still set")139 self.assertEqual(progress_log.completed, False, "completed is False")140 self.assertEqual(progress_log.end_time, None, "end_time is not set")141 def test_cancel_progress(self):142 # Create the object143 progress_log = UpdateProgressLog(process_name="test_process", total_stages=10)144 progress_log.save()145 # Complete the process146 progress_log.cancel_progress()...

Full Screen

Full Screen

update_handlers.py

Source:update_handlers.py Github

copy

Full Screen

1import asyncio2from loader import bot3from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton4from aiogram.types import ReplyKeyboardMarkup, KeyboardButton, ReplyKeyboardRemove5from config import update_stage, answers6from states import Update7from .registr_handlers import Reg_state8from aiogram import Dispatcher9from aiogram import types10from aiogram.dispatcher import FSMContext11from database.db import sql_get_users_id, sql_update12from re import fullmatch13async def callback_update_handler(callback: types.CallbackQuery, state: FSMContext):14 async with state.proxy() as data:15 global lang16 lang = data['language']17 first_name = InlineKeyboardButton(text=update_stage[lang]["first_name"],18 callback_data="name")19 email = InlineKeyboardButton(text=update_stage[lang]["email"],20 callback_data="email")21 phone_number = InlineKeyboardButton(text=update_stage[lang]["phone_num"],22 callback_data="phone_number")23 geo = InlineKeyboardButton(text=update_stage[lang]["geo"],24 callback_data="location")25 global keyboard26 keyboard = InlineKeyboardMarkup().add(first_name) \27 .add(email).add(phone_number).add(geo)28 if data['user_id'] in sql_get_users_id():29 await bot.edit_message_text(message_id=callback.message.message_id,30 chat_id=callback.message.chat.id,31 text=update_stage[lang]["upd_accept"],32 reply_markup=keyboard)33 else:34 await callback.answer(update_stage[lang]["upd_decline"], show_alert=True)35 await state.finish()36async def callback_update_name(callback: types.CallbackQuery):37 await Update.name.set()38 await callback.answer(update_stage[lang]['redirect_name'])39 await bot.delete_message(chat_id=callback.message.chat.id,40 message_id=callback.message.message_id)41 await bot.send_message(chat_id=callback.message.chat.id,42 text=answers[lang]["entering_name"])43async def update_name(message: types.Message,44 state: FSMContext):45 if not message.text.isalpha() or len(message.text) < 3:46 await message.answer(answers[lang]['entering_name'])47 return await update_name(message.text, Update.name)48 else:49 async with state.proxy() as data:50 data['first_name'] = message.text.title()51 data['user_id'] = message.from_user.id52 await sql_update(state, "first_name", data['first_name'], data['user_id'])53 await message.answer(update_stage[lang]["successful_name_update"])54 await state.finish()55async def callback_update_phone(callback: types.CallbackQuery):56 await Update.phone.set()57 await callback.answer(update_stage[lang]['redirect_phone'])58 await asyncio.sleep(1)59 await bot.delete_message(chat_id=callback.message.chat.id,60 message_id=callback.message.message_id)61 await bot.send_message(chat_id=callback.message.chat.id,62 text=answers[lang]["entering_phone"])63async def update_phone(message: types.Message, state: FSMContext):64 async with state.proxy() as data:65 if bool(fullmatch(r"\+\d{9,20}", message.text)):66 data["phone"] = message.text67 data["user_id"] = message.from_user.id68 await sql_update(state, "phone_number", data["phone"], data["user_id"])69 await message.answer(update_stage[lang]["successful_phone_update"])70 else:71 await message.answer(answers[lang]['validate_phone'])72 return await update_phone(message.text, state)73 await state.finish()74async def callback_update_email(callback: types.CallbackQuery):75 await Update.email.set()76 await callback.answer(update_stage[lang]['redirect_email'])77 await asyncio.sleep(1)78 await bot.delete_message(chat_id=callback.message.chat.id,79 message_id=callback.message.message_id)80 await bot.send_message(chat_id=callback.message.chat.id,81 text=answers[lang]["entering_mail"])82async def update_email(message: types.Message, state: FSMContext):83 async with state.proxy() as data:84 if bool(fullmatch(r"^\w[^.\s]{0,10}.??[^.\s]{1,10}.??[^.\s]{0,10}.??[^.\s]"85 r"{0,10}[^.\s]{0,25}@[a-zA-Z]{1,32}-??\d{0,32}\d{0,32}.\w{1,10}$",86 message.text)):87 data["email"] = message.text88 data["user_id"] = message.from_user.id89 await sql_update(state, "email", data["email"], data["user_id"])90 await message.answer(update_stage[lang]["successful_email_update"])91 else:92 await message.answer(answers[lang]['try_mail'])93 return await update_email(message.text, state)94 await state.finish()95async def callback_update_location(callback: types.CallbackQuery):96 await Update.location.set()97 location_sending_button = KeyboardButton(update_stage[lang]['location'],98 request_location=True)99 location = ReplyKeyboardMarkup(resize_keyboard=True).add(location_sending_button)100 await callback.answer(update_stage[lang]['redirect_location'])101 await asyncio.sleep(1)102 await bot.delete_message(chat_id=callback.message.chat.id,103 message_id=callback.message.message_id)104 await bot.send_message(chat_id=callback.message.chat.id,105 text=update_stage[lang]["send_location"],106 reply_markup=location)107async def update_location(message: types.Message):108 await message.answer(update_stage[lang]["successful_location_update"],109 reply_markup=ReplyKeyboardRemove())110def reg_update_handlers(dp: Dispatcher):111 dp.register_callback_query_handler(callback_update_handler,112 lambda callback: callback.data == "upd",113 state=Reg_state.callback)114 dp.register_callback_query_handler(callback_update_name,115 lambda callback: callback.data == "name")116 dp.register_callback_query_handler(callback_update_phone,117 lambda callback: callback.data == "phone_number")118 dp.register_callback_query_handler(callback_update_email,119 lambda callback: callback.data == "email")120 dp.register_callback_query_handler(callback_update_location,121 lambda callback: callback.data == "location")122 dp.register_message_handler(update_name, state=Update.name)123 dp.register_message_handler(update_phone, state=Update.phone)124 dp.register_message_handler(update_email, state=Update.email)125 dp.register_message_handler(update_location, state=Update.location,...

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 localstack 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