How to use skip_key method in localstack

Best Python code snippet using localstack_python

Player.py

Source:Player.py Github

copy

Full Screen

1from Constants import *2import pygame3class Hero:4 def __init__(self, screen, cords):5 self.screen = screen6 self.health_bar = None7 self.health_point = HP8 self.mana_bar = None9 self.mana_point = MANA10 self.sword_sound = pygame.mixer.Sound('Resources/sound/sword.mp3')11 self.sword_sound.set_volume(10.0)12 self.moves = []13 self.attack_moves = []14 self.death_animation = None15 self.active_move = {"Forward": False, "Back": False, "Right": False,16 "Left": False, "Attack": False}17 self.previous_active_move = "Forward"18 self.animation_counter = 019 self.damage_counter = 1020 self.x, self.y = cords21 self.wall_box = []22 def filling_moves(self):23 images = ["Resources/test_forward.png", "Resources/test_back.png",24 "Resources/test_right.png", "Resources/test_left.png"]25 for link in images:26 image = pygame.image.load(link).convert_alpha()27 pose1 = pygame.transform.scale(image.subsurface(0, 0, 28, 34), PLAYER_SIZE)28 pose2 = pygame.transform.scale(image.subsurface(28, 0, 28, 34), PLAYER_SIZE)29 pose3 = pygame.transform.scale(image.subsurface(56, 0, 28, 34), PLAYER_SIZE)30 self.moves.append([pose1, pose2, pose3, pose2])31 images = ["Resources/forward_attak.png", "Resources/back_attak.png",32 "Resources/right_attak.png", "Resources/left_attak.png"]33 for link in images:34 image = pygame.image.load(link).convert_alpha()35 pose1 = pygame.transform.scale(image.subsurface(28, 0, 28, 34), PLAYER_SIZE)36 pose2 = pygame.transform.scale(image.subsurface(56, 0, 28, 34), PLAYER_SIZE)37 pose3 = pygame.transform.scale(image.subsurface(84, 0, 28, 34), PLAYER_SIZE)38 self.attack_moves.append([pose1, pose2, pose3])39 imgs = pygame.image.load("Resources/health_and_mana_bar.png").convert_alpha()40 self.health_bar, self.mana_bar = imgs.subsurface(0, 0, 249, 29), imgs.subsurface(0, 25, 249, 28)41 self.death_animation = pygame.transform.scale(pygame.image.load("Resources/PLITA.png"), (28 * 2, 34 * 2))42 def render(self):43 if self.active_move["Attack"]:44 if self.animation_counter + 1 >= len(self.attack_moves[0]) * MAX_FRAMES_FOR_IMAGE:45 if self.active_move["Attack"]:46 self.sword_sound.play()47 self.active_move["Attack"] = False48 self.change_mana("Attack")49 self.active_move[self.previous_active_move] = True50 self.animation_counter = 051 self.screen.blit(self.attack_moves[list(self.active_move.keys()).index(self.previous_active_move)][52 self.animation_counter // MAX_FRAMES_FOR_IMAGE], (self.x, self.y))53 else:54 if self.animation_counter + 1 >= len(self.moves[0]) * MAX_FRAMES_FOR_IMAGE:55 self.animation_counter = 056 if self.active_move["Forward"]:57 self.screen.blit(self.moves[0][self.animation_counter // MAX_FRAMES_FOR_IMAGE], (self.x, self.y))58 self.previous_active_move = "Forward"59 elif self.active_move["Back"]:60 self.screen.blit(self.moves[1][self.animation_counter // MAX_FRAMES_FOR_IMAGE], (self.x, self.y))61 self.previous_active_move = "Back"62 elif self.active_move["Right"]:63 self.screen.blit(self.moves[2][self.animation_counter // MAX_FRAMES_FOR_IMAGE], (self.x, self.y))64 self.previous_active_move = "Right"65 elif self.active_move["Left"]:66 self.screen.blit(self.moves[3][self.animation_counter // MAX_FRAMES_FOR_IMAGE], (self.x, self.y))67 self.previous_active_move = "Left"68 else:69 self.screen.blit(self.moves[list(self.active_move.keys()).index(self.previous_active_move)][1],70 (self.x, self.y))71 self.animation_counter = 072 self.animation_counter += 173 def chek_active_move(self, skip_key):74 for key in self.active_move.keys():75 if key != skip_key:76 self.active_move[key] = False77 def get_player_cords(self):78 return [self.x, self.y]79 def get_damage(self, damage):80 self.health_point -= damage81 def give_damage(self, button_name, side):82 cords = []83 if side == "Forward":84 cords = [self.x, self.y + PLAYER_HITBOX_HEIGHT, 50, 20]85 elif side == "Back":86 cords = [self.x, self.y - 5, 50, 20]87 elif side == "Left":88 cords = [self.x - 20, self.y - 5, 20, 70]89 elif side == "Right":90 cords = [self.x + PLAYER_HITBOX_WEIGHT, self.y - 5, 20, 70]91 """Проверка длинны радиуса атаки"""92 pygame.draw.rect(self.screen, pygame.Color("Yellow"), cords, 2)93 if button_name == "z":94 return [5, cords]95 def change_mana(self, pressed_button):96 if pressed_button == "Attack":97 self.mana_point -= 2298 def hp_regen(self):99 self.health_point += HP_REGEN100 def mn_regen(self):101 self.mana_point += MN_REGEN102 def chek_collisions(self, c1, r1, c2, r2):103 return self.wall_box[r1][c1] == -1 and self.wall_box[r1][c2] == -1 \104 and self.wall_box[r2][c1] == -1 and self.wall_box[r2][c2]105 def get_collision_box(self, com):106 if com[pygame.K_LEFT]:107 cords = [self.x + 12, self.y + 48, self.x + 12 + 26, self.y + 48 + 12]108 elif com[pygame.K_RIGHT]:109 cords = [self.x + 22, self.y + 48, self.x + 22 + 26, self.y + 48 + 12]110 elif com[pygame.K_UP]:111 cords = [self.x + 16, self.y + 42, self.x + 16 + 20, self.y + 42 + 10]112 else:113 cords = [self.x + 16, self.y + 52, self.x + 16 + 20, self.y + 52 + 10]114 return cords115 def moving(self, pressed_button):116 skip_key = "None"117 cords = self.get_collision_box(pressed_button)118 col1, col2 = (cords[0]) // 32, (cords[2]) // 32119 row1, row2 = (cords[1]) // 32, (cords[3]) // 32120 if pressed_button[pygame.K_LEFT] and self.chek_collisions(col1, row1, col2, row2):121 self.x -= SPEED122 self.active_move["Left"] = True123 skip_key = "Left"124 elif pressed_button[pygame.K_RIGHT] and self.chek_collisions(col1, row1, col2, row2):125 self.x += SPEED126 self.active_move["Right"] = True127 skip_key = "Right"128 elif pressed_button[pygame.K_UP] and self.chek_collisions(col1, row1, col2, row2):129 self.y -= SPEED130 self.active_move["Back"] = True131 skip_key = "Back"132 elif pressed_button[pygame.K_DOWN] and self.chek_collisions(col1, row1, col2, row2):133 self.y += SPEED134 self.active_move["Forward"] = True135 skip_key = "Forward"136 elif pressed_button[pygame.K_z]:137 if self.mana_point > 0:138 self.active_move["Attack"] = True139 skip_key = "Attack"...

Full Screen

Full Screen

test_company_trade_areas_missing_labor_data_check.py

Source:test_company_trade_areas_missing_labor_data_check.py Github

copy

Full Screen

1import unittest2from bson.objectid import ObjectId3from pymongo import mongo_client4from core.data_checks.implementation.company_checks.economics.company_trade_areas_missing_labor_data_check import CompanyTradeAreasMissingLaborDataCheck5from common.utilities.date_utilities import LAST_ANALYTICS_DATE, LAST_ECONOMICS_DATE, get_start_date_of_next_month6__author__ = 'vgold'7class TestCompanyTradeAreasMissingLaborDataCheck(unittest.TestCase):8 conn = None9 mds = None10 @classmethod11 def setUpClass(cls):12 cls.conn = mongo_client.MongoClient("localhost", 27017)13 cls.mds = cls.conn["itest_mds"]14 @classmethod15 def tearDownClass(cls):16 cls.conn.close()17 def setUp(self):18 self.co1 = ObjectId()19 self.ta1 = ObjectId()20 self.ta2 = ObjectId()21 self.ta3 = ObjectId()22 self.ta4 = ObjectId()23 self.ta5 = ObjectId()24 self.ta6 = ObjectId()25 self.ta7 = ObjectId()26 self.ta8 = ObjectId()27 self.companies = [28 {29 "_id": self.co1,30 "data": {31 "type": "retail_banner",32 "workflow": {33 "current": {34 "status": "published"35 }36 },37 "analytics": {38 "stores": {39 "monthly": {40 "store_counts": [41 {"date": LAST_ECONOMICS_DATE.isoformat().split(".", 1)[0], "value": 1}42 ]43 }44 }45 }46 }47 }48 ]49 self.company_dict = {50 str(co["_id"])51 for co in self.companies52 }53 self.mds.company.insert(self.companies)54 good_date = LAST_ECONOMICS_DATE55 bad_date = get_start_date_of_next_month(LAST_ECONOMICS_DATE)56 self.mds.trade_area.insert([57 {58 "_id": self.ta1,59 "interval": None,60 "data": {61 "street_number": 123,62 "street": "Main St",63 "suite": "Suite 1A",64 "city": "Anytown",65 "state": "BA",66 "zip": "45666",67 "company_id": str(self.co1),68 "analytics": self.__add_labor_analytics(good_date, skip_key="area_type")69 }70 },71 {72 "_id": self.ta2,73 "interval": [None, None],74 "data": {75 "street_number": 456,76 "street": "Two St",77 "suite": None,78 "city": "Anytown",79 "state": "AR",80 "company_id": str(self.co1),81 "analytics": self.__add_labor_analytics(good_date, skip_key="area_text")82 }83 },84 {85 "_id": self.ta3,86 "interval": [None, None],87 "data": {88 "company_id": str(self.co1),89 "analytics": self.__add_labor_analytics(good_date, skip_key="unemployment")90 }91 },92 {93 "_id": self.ta4,94 "interval": [None, None],95 "data": {96 "company_id": str(self.co1),97 "analytics": self.__add_labor_analytics(good_date, skip_key="employment")98 }99 },100 {101 "_id": self.ta5,102 "interval": [None, None],103 "data": {104 "company_id": str(self.co1),105 "analytics": self.__add_labor_analytics(good_date, skip_key="unemployment rate")106 }107 },108 {109 "_id": self.ta6,110 "interval": [None, None],111 "data": {112 "company_id": str(self.co1),113 "analytics": self.__add_labor_analytics(good_date, skip_key="labor force")114 }115 },116 {117 "_id": self.ta7,118 "interval": [None, None],119 "data": {120 "company_id": str(self.co1),121 "analytics": self.__add_labor_analytics(bad_date)122 }123 },124 {125 "_id": self.ta8,126 "interval": [None, None],127 "data": {128 "company_id": str(self.co1),129 "analytics": self.__add_labor_analytics(good_date)130 }131 }132 ])133 def tearDown(self):134 self.mds.trade_area.drop()135 self.mds.company.drop()136 def test_company_trade_areas_missing_labor_data(self):137 checker = CompanyTradeAreasMissingLaborDataCheck(self.mds, self.companies[0], self.company_dict)138 result = checker.check()139 def tostring(ta):140 if ta == self.ta1:141 return "TA %s: \"123 Main St Suite 1A, Anytown, BA, 45666\"" % ta142 elif ta == self.ta2:143 return 'TA %s: "456 Two St , Anytown, AR, None"' % ta144 return "TA %s: \"None None , None, None, None\"" % ta145 self.assertFalse(result)146 self.assertEqual(147 sorted(checker.failures),148 sorted(map(tostring, [self.ta1, self.ta2, self.ta3, self.ta4, self.ta5, self.ta6, self.ta7]))149 )150 def __add_labor_analytics(self, date, skip_key=None):151 date_string = date.isoformat().split(".", 1)[0]152 data = {153 "economics": {154 "area_type": "C",155 "area_text": "Anytown, UT",156 "monthly": {157 "unemployment": [{"date": date_string, "value": 1234}],158 "unemployment rate": [{"date": date_string, "value": 1234}],159 "employment": [{"date": date_string, "value": 1234}],160 "labor force": [{"date": date_string, "value": 1234}],161 }162 }163 }164 if skip_key is not None:165 if skip_key in data["economics"].keys():166 del data["economics"][skip_key]167 elif skip_key in data["economics"]["monthly"].keys():168 del data["economics"]["monthly"][skip_key]169 return data170if __name__ == '__main__':...

Full Screen

Full Screen

pagination.py

Source:pagination.py Github

copy

Full Screen

1class Pagination(object):2 def __init__(self):3 self.next_page_key = None4 self.skip_key = None5 self.limit_key = None6 self.total_key = None7 self.next_page_url = None8 self.remaining_records = None9 self.records_to_skip = None10 self.pagination_style = ""11 self.counting_key = None12 self.counter = None13 self.is_data_single_dict = None14 self.is_last_page = None15 self.error_flag = None16 def configure_paging(self, config=None, skip_key=None, limit_key=None, total_key=None, next_page_key=None):17 config = {} if config is None else config18 self.next_page_key = config.get("next_page_key", next_page_key)19 self.skip_key = config.get("skip_key", skip_key)20 self.limit_key = config.get("limit_key", limit_key)21 self.total_key = config.get("total_key", total_key)22 def reset_paging(self, counting_key=None, url=None):23 self.remaining_records = 024 self.records_to_skip = 025 self.counting_key = counting_key26 self.counter = 027 self.next_page_url = url28 self.is_data_single_dict = False29 self.is_last_page = False30 self.error_flag = False31 def set_counting_key(self, counting_key):32 self.counting_key = counting_key33 def update_next_page(self, data):34 if isinstance(data, list):35 batch_size = len(data)36 self.records_to_skip = self.records_to_skip + batch_size37 return38 self.is_last_page = data.get('isLastPage', False)39 if self.counting_key:40 if isinstance(self.counting_key, list):41 counting_key = self.extract_counting_key(data)42 else:43 counting_key = self.counting_key44 if counting_key is not None:45 batch_size = len(data.get(counting_key))46 else:47 self.is_last_page = True48 batch_size = 149 else:50 self.is_data_single_dict = True51 return52 self.update_page_parameters(data, batch_size)53 def update_page_parameters(self, data, batch_size):54 if self.next_page_key:55 self.next_page_url = self.get_from_path(data, self.next_page_key)56 if self.skip_key:57 self.skip = data.get(self.skip_key)58 if self.limit_key:59 self.limit = data.get(self.limit_key)60 if self.total_key:61 self.total = data.get(self.total_key)62 self.records_to_skip = self.records_to_skip + batch_size63 if self.total:64 self.remaining_records = self.total - self.records_to_skip65 def extract_counting_key(self, data):66 counting_key = None67 for key in self.counting_key:68 if key in data:69 counting_key = key70 return counting_key71 def get_from_path(self, dictionary, path):72 if isinstance(path, list):73 endpoint = dictionary74 for key in path:75 endpoint = endpoint.get(key)76 if endpoint is None:77 return None78 return endpoint79 else:80 return dictionary.get(path)81 def is_next_page(self):82 if self.is_last_page:83 return False84 if self.is_data_single_dict or self.error_flag:85 return False86 if self.next_page_key:87 ret = (self.next_page_url is not None) and (self.next_page_url != "")88 else:89 ret = self.counter < self.remaining_records90 return ret91 def get_params(self):92 ret = {}93 if self.skip_key and (self.records_to_skip > 0):94 ret.update({self.skip_key: self.records_to_skip})95 return ret96 def get_next_page_url(self):97 return self.next_page_url98 def set_error_flag(self, flag=True):...

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