Best Python code snippet using autotest_python
steps_when.py
Source:steps_when.py
...5import re6@when('I execute the API request to search for the repository "{repo}" owned by "{owner}"')7def step_impl(context, repo, owner):8 query = query_builder(repo="{}/{}".format(owner, repo))9 context.request_response = execute_request(query)10@when('I execute the API request to search for all repositories that contain the keyword "{key}" in its "{location}"')11def step_impl(context, key, location):12 locations = set(map(lambda x: str(x).lower(), re.split('[^a-zA-Z]', location)))13 query = query_builder(keyword=key, q_in=list(locations.intersection(VALID_LOCATIONS)))14 context.request_response = execute_request(query)15@when('I execute the API request to search for all repositories from the user "{user}"')16def step_impl(context, user):17 query = query_builder(user=user)18 context.request_response = execute_request(query)19@when('I execute the API request to search for all repositories from the organization "{organization}"')20def step_impl(context, organization):21 query = query_builder(org=organization)22 context.request_response = execute_request(query)23@when('I execute the API request to search for all repositories "{comparator}" "{size:d}" kilobytes')24def step_impl(context, comparator, size):25 query = query_builder(size=[get_comparator(comparator), size])26 context.request_response = execute_request(query)27@when('I execute the API request to search for all repositories between "{size1}" and "{size2}" kilobytes')28def step_impl(context, size1, size2):29 query = query_builder(size=[size1, '..', size2])30 context.request_response = execute_request(query)31@when('I execute the API request to search for all repositories with "{comparator}" "{cnt}" followers')32def step_impl(context, comparator, cnt):33 query = query_builder(followers=[get_comparator(comparator), cnt])34 context.request_response = execute_request(query)35@when('I execute the API request to search for all repositories with between "{cnt1}" and "{cnt2}" followers')36def step_impl(context, cnt1, cnt2):37 query = query_builder(followers=[cnt1, '..', cnt2])38 context.request_response = execute_request(query)39@when('I execute the API request to search for all repositories with "{comparator}" "{cnt}" forks')40def step_impl(context, comparator, cnt):41 query = query_builder(forks=[get_comparator(comparator), cnt])42 context.request_response = execute_request(query)43@when('I execute the API request to search for all repositories with between "{cnt1}" and "{cnt2}" forks')44def step_impl(context, cnt1, cnt2):45 query = query_builder(forks=[cnt1, '..', cnt2])46 context.request_response = execute_request(query)47@when('I execute the API request to search for all repositories with "{comparator}" "{cnt}" stars')48def step_impl(context, comparator, cnt):49 query = query_builder(stars=[get_comparator(comparator), cnt])50 context.request_response = execute_request(query)51@when('I execute the API request to search for all repositories with between "{cnt1}" and "{cnt2}" stars')52def step_impl(context, cnt1, cnt2):53 query = query_builder(stars=[cnt1, '..', cnt2])54 context.request_response = execute_request(query)55@when('I execute the API request to search for all repositories {selector} "{comparator}" "{date}"')56def step_impl(context, selector, comparator, date):57 if selector in ['created']:58 query = query_builder(created=[get_comparator(comparator), date])59 elif selector in ['pushed']:60 query = query_builder(pushed=[get_comparator(comparator), date])61 context.request_response = execute_request(query)62@when('I execute the API request to search for all repositories {selector} between "{date1}" and "{date2}"')63def step_impl(context, selector, date1, date2):64 if selector in ['created']:65 query = query_builder(created=[date1, '..', date2])66 elif selector in ['pushed']:67 query = query_builder(pushed=[date1, '..', date2])68 context.request_response = execute_request(query)69@when('I execute the API request to search for all repositories written in "{language}"')70def step_impl(context, language):71 query = query_builder(language=str(language).upper())72 context.request_response = execute_request(query)73@when('I execute the API request to search for all repositories with the topic in "{topic}"')74def step_impl(context, topic):75 query = query_builder(topic=topic)76 context.request_response = execute_request(query)77@when('I execute the API request to search for all repositories with the licence keyword "{licence_key}"')78def step_impl(context, licence_key):79 query = query_builder(licence=licence_key)80 context.request_response = execute_request(query)81@when('I execute the API request to search for all repositories that are "{public_status}"')82def step_impl(context, public_status):83 query = query_builder(q_is=str(public_status).lower())84 context.request_response = execute_request(query)85@when('I execute the API request to search for all repositories that {evaluator} a mirror')86def step_impl(context, evaluator):87 if evaluator == 'is':88 is_mirror = 'True'89 else:90 is_mirror = 'False'91 query = query_builder(mirror=is_mirror)92 context.request_response = execute_request(query)93@when('I execute the API request to search for all repositories that {evaluator} archived')94def step_impl(context, evaluator):95 if evaluator == 'is':96 is_archived = 'true'97 else:98 is_archived = 'false'99 query = query_builder(archived=is_archived)100 context.request_response = execute_request(query)101@when('I execute the API request to search for repositories using the query parameters')102def step_impl(context):103 query_args = table_to_query_args(context.table)104 query = query_builder(**query_args)105 context.request_response = execute_request(query)106@when('I execute the API request to search for repositories, sorted by "{sort}", using the query parameters')107def step_impl(context, sort):108 query_args = table_to_query_args(context.table)109 query = query_builder(**query_args)110 context.request_response = execute_request(query, sort=sort)111@when('I execute the API request to search for repositories, ordered in {order} manner, using the query parameters')112def step_impl(context, order):113 query_args = table_to_query_args(context.table)114 query = query_builder(**query_args)115 context.request_response = execute_request(query, order=get_order(order))116@when('I execute the API request to search for repositories, sorted by "{sort}" ordered in {order} manner, using the query parameters')117def step_impl(context, sort, order):118 query_args = table_to_query_args(context.table)119 query = query_builder(**query_args)120 context.request_response = execute_request(query, sort=sort, order=get_order(order))121@when('I execute the API request to search for repositories, sorted by "{sort}" ordered in {order} manner with "{per_page:d}" items per page, using the query parameters')122def step_impl(context, sort, order, per_page):123 query_args = table_to_query_args(context.table)124 query = query_builder(**query_args)125 context.request_response = execute_request(query, sort=sort, order=get_order(order), per_page=per_page)126@when('I execute the API request to search for repositories, with "{per_page}" items per page, using the query parameters')127def step_impl(context, per_page):128 query_args = table_to_query_args(context.table)129 query = query_builder(**query_args)...
kyber.py
Source:kyber.py
...16 users = '/users'17 def get_buy_rate(self, *args):18 url = self.base_endpoint + self.buy_rate19 url = append_params(url, *args)20 return execute_request(url)21 def get_change24h(self, only_official_reserve=True):22 url = self.base_endpoint + self.change24h23 if not only_official_reserve:24 url += '?only_official_reserve=' + str(only_official_reserve)25 print(url)26 return execute_request(url)27 28 def get_currencies(self, *args):29 url = self.base_endpoint + self.currencies30 url = append_params(url, *args)31 return execute_request(url)32 33 def get_gas_limit(self, *args):34 url = self.base_endpoint + self.gas_limit35 url = append_params(url, *args)36 return execute_request(url)37 38 def get_gas_limit_config(self):39 url = self.base_endpoint + self.gas_limit_config40 return execute_request(url)41 42 def get_market(self):43 url = self.base_endpoint + self.market44 return execute_request(url)45 46 def get_quote_amount(self, *args):47 url = self.base_endpoint + self.quote_amount48 url = append_params(url, *args)49 return execute_request(url)50 51 def get_sell_rate(self, *args):52 url = self.base_endpoint + self.sell_rate53 url = append_params(url, *args)54 return execute_request(url)55 56 def get_trade_data(self, *args):57 url = self.base_endpoint + self.sell_rate58 url = append_params(url, *args)59 return execute_request(url)60 61 def get_transfer_data(self, *args):62 url = self.base_endpoint + self.transfer_data63 url = append_params(url, *args)64 return execute_request(url)65 66 def get_users_currencies(self, user_address):67 url = self.base_endpoint + self.users + '/' + user_address + self.currencies68 return execute_request(url)69 70 def get_users_currencies_enable_data(self, *args, user_address, currency_id):71 url = self.base_endpoint + self.users + '/' + user_address + self.currencies + '/' + currency_id + self.enable_data72 url = append_params(url, *args)73 return execute_request(url)74 ...
dydx.py
Source:dydx.py
...16 standard_actions = 'v1/standard-actions'17 # Trading API18 def get_orderbook(self, market):19 url = self.base_endpoint + self.orderbook + market20 return execute_request(url)21 def get_orders(self, *args):22 url = self.base_endpoint + self.orders23 url = append_params(url, *args)24 return execute_request(url)25 def get_trades(self, *args):26 url = self.base_endpoint + self.orders27 url = append_params(url, *args)28 return execute_request(url)29 def get_fills(self, *args):30 url = self.base_endpoint + self.fills31 url = append_params(url, *args)32 return execute_request(url)33 def get_stats_markets(self):34 url = self.base_endpoint + self.stats_markets35 return execute_request(url)36 def get_candles(self, *args):37 url = self.base_endpoint + self.candles38 url = append_params(url, *args)39 return execute_request(url)40 # Solo API41 def get_markets(self, market=None):42 url = self.base_endpoint + self.markets43 if market:44 url += market45 return execute_request(url)46 def get_accounts(self, address, number=None):47 url = self.base_endpoint + self.accounts + address48 if number:49 url += '?number=' + number50 return execute_request(url)51 # Perpetual API52 def get_perpetual_markets(self):53 url = self.base_endpoint + self.perpetual_markets54 return execute_request(url)55 def get_perpetual_balance_updates(self, *args):56 url = self.base_endpoint + self.perpetual_balance_updates57 url = append_params(url, *args)58 return execute_request(url)59 def get_standard_actions(self, *args):60 url = self.base_endpoint + self.stats_markets61 url = append_params(url, *args)62 return execute_request(url)63 def get_perpetual_accounts(self, wallet_address):64 url = self.base_endpoint + self.perpetual_accounts + wallet_address...
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!!