Best Python code snippet using localstack_python
test_secretsmanager.py
Source:test_secretsmanager.py
...35THIS_FOLDER = os.path.dirname(os.path.realpath(__file__))36TEST_LAMBDA_ROTATE_SECRET = os.path.join(THIS_FOLDER, "functions", "lambda_rotate_secret.py")37class TestSecretsManager:38 @pytest.fixture39 def sm_client(self, secretsmanager_client):40 return secretsmanager_client41 @pytest.mark.parametrize(42 "secret_name, is_valid_partial_arn",43 [44 (f"s-{short_uid()}", True),45 ("Valid/_+=.@-Name", True),46 ("Valid/_+=.@-Name-a1b2", True),47 ("Invalid/_+=.@-Name-a1b2c3", False),48 ("Invalid/_+=.@-Name-a1b2c3-", False),49 ],50 )51 def test_create_and_update_secret(52 self, sm_client, secret_name: str, is_valid_partial_arn: bool53 ):...
Yt tutorial.py
Source:Yt tutorial.py
1# -*- coding: utf-8 -*-2"""3Created on Sun Apr 11 18:30:07 202145@author: iiaaaronn6"""789# %%10#-------------------------------------------------------------------------11# Episode 312#-------------------------------------------------------------------------13import os14os.chdir('INSERT YOUR FILE PATH HERE\\smk_trading_bot-master')15#e.g.16# os.chdir('C:\\Users\\iiaaaronn\\Documents\\YT\\Betting\\Smarkets API tutorial\\Code\\smk_trading_bot-master') 17import client as sm_client18client = sm_client.SmarketsClient()19client.init_session()20212223# %%24#-------------------------------------------------------------------------25# Episode 426#-------------------------------------------------------------------------27import os28os.chdir('YOUR FILE PATH')29import client as sm_client30client = sm_client.SmarketsClient()31client.init_session()3233import datetime34start_date=datetime.datetime.now()+datetime.timedelta(days=1)35events =client.get_available_events(states=['upcoming'],types=['horse_racing_race'],start_datetime_max=start_date,limit=20)36373839# %%40#-------------------------------------------------------------------------41# Episode 542#-------------------------------------------------------------------------4344import os45os.chdir('YOUR FILE PATH')46import client as sm_client47client = sm_client.SmarketsClient()48client.init_session()4950import datetime51start_date=datetime.datetime.now()+datetime.timedelta(days=1)5253events=client.get_available_events(states=['upcoming'],54 types=['horse_racing_race'],55 start_datetime_max=start_date,56 limit=20,57 sort='id')5859events=client.get_available_events(states=['upcoming'],60 types=['horse_racing_race'],61 #start_datetime_max=start_date,62 limit=20,63 sort='id')6465events=client.get_available_events(states=['upcoming'],66 #types=['horse_racing_race'],67 start_datetime_max=start_date,68 limit=20,69 sort='id')70717273# %%74#-------------------------------------------------------------------------75# Episode 676#-------------------------------------------------------------------------77import os78os.chdir('YOUR FILE PATH')79import client as sm_client80client = sm_client.SmarketsClient()81client.init_session()8283import datetime84start_date=datetime.datetime.now()+datetime.timedelta(days=1)8586events=client.get_available_events(states=['upcoming'],87 #types=['horse_racing_race'],88 type_domains=['horse_racing'],89 start_datetime_max=start_date,90 limit=20,91 sort='id')9293# %%94#-------------------------------------------------------------------------95# Episode 796#-------------------------------------------------------------------------97import os98os.chdir('YOUR FILE PATH')99import client as sm_client100client = sm_client.SmarketsClient()101client.init_session()102from datetime import datetime103from datetime import timedelta104105# enter time of race today in format 12:00106# Dependant on timezone (if in the uk you may need to -1 hour due to clock change)107event_time='19:50'108# date today + time of event as a string109event_date_time=(datetime.today()).strftime("%Y-%m-%d")+" "+event_time110# convert that string to a date time object111event_date_time=datetime.strptime(event_date_time,"%Y-%m-%d %H:%M")112# set max start date for 5 min after event113start_date=event_date_time+timedelta(minutes=5)114# set min start date for 5 min before event115end_date=event_date_time-timedelta(minutes=5)116117events=client.get_available_events(states=['upcoming'],118 #types=['horse_racing_race'],119 type_domains=['horse_racing'],120 start_datetime_max=start_date,121 start_datetime_min=end_date,122 limit=20,123 sort='id')124 125markets=client.get_related_markets(events)126127128129# %%130#-------------------------------------------------------------------------131# Episode 8132#-------------------------------------------------------------------------133import os134os.chdir('YOUR FILE PATH')135import client as sm_client136client = sm_client.SmarketsClient()137client.init_session()138from datetime import datetime139from datetime import timedelta140141142# Dependant on timezone (if in the uk you may need to -1 hour due to clock change)143event_time='18:50'144event_date_time=(datetime.today()).strftime("%Y-%m-%d")+" "+event_time145event_date_time=datetime.strptime(event_date_time,"%Y-%m-%d %H:%M")146start_date=event_date_time+timedelta(minutes=5)147end_date=event_date_time-timedelta(minutes=5)148149events=client.get_available_events(states=['upcoming'],150 #types=['horse_racing_race'],151 type_domains=['horse_racing'],152 start_datetime_max=start_date,153 start_datetime_min=end_date,154 limit=20,155 sort='id')156 157markets=client.get_related_markets(events)158159160# Quick method - normally works161to_win_market = markets[0]162163# More robust method to ensure obtain 'To win market'164for market in markets:165 if market['name']=='To win':166 to_win_market = market167 168 169contracts = client.get_related_contracts( [to_win_market] ) 170171172173for contract in contracts:174 name=contract['name']175 contract_id=contract['id']176 market_id=contract['market_id']177 print(f'name: {name}, contract_id: {contract_id}, market_id: {market_id}')178 179 180 181 182 183contracts = client.get_related_contracts( markets ) 184for contract in contracts:185 name=contract['name']186 contract_id=contract['id']187 market_id=contract['market_id']188 print(f'name: {name}, contract_id: {contract_id}, market_id: {market_id}') 189 190 191 192 193 194# %%195#-------------------------------------------------------------------------196# Episode 9197#-------------------------------------------------------------------------198 199import os200os.chdir('YOUR FILE PATH')201import client as sm_client202client = sm_client.SmarketsClient()203client.init_session()204from datetime import datetime205from datetime import timedelta206207# Dependant on timezone (if in the uk you may need to -1 hour due to clock change)208event_time='18:50'209event_date_time=(datetime.today()).strftime("%Y-%m-%d")+" "+event_time210event_date_time=datetime.strptime(event_date_time,"%Y-%m-%d %H:%M")211start_date=event_date_time+timedelta(minutes=5)212end_date=event_date_time-timedelta(minutes=5)213214events=client.get_available_events(states=['upcoming'],215 #types=['horse_racing_race'],216 type_domains=['horse_racing'],217 start_datetime_max=start_date,218 start_datetime_min=end_date,219 limit=20,220 sort='id')221 222markets=client.get_related_markets(events)223224225for market in markets:226 if market['name']=='To win':227 to_win_market = market228 229quotes=client.get_quotes([to_win_market['id']])230 231232233234# %%235#-------------------------------------------------------------------------236# Episode 10237#-------------------------------------------------------------------------238import os239os.chdir('YOUR FILE PATH')240import client as sm_client241client = sm_client.SmarketsClient()242client.init_session()243244client.percent_to_decimal(4950)245246247248249250251252253254255
...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!