This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| def retrieve_data(max): | |
| counter = 0 | |
| while counter < max: | |
| data = {'data': list(range(1, 300))} | |
| print('Requesting the api') | |
| response = requests.post('https://httpbin.org/anything', json=data) | |
| if response.ok: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Install faker: pip install Faker | |
| from datetime import datetime, timezone, timedelta | |
| import random | |
| import time | |
| import json | |
| import os | |
| import sys | |
| from faker import Faker |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from scenario3.price_client import get_price | |
| def retrieve_prices(products_id: list[str]) -> dict[str, float]: | |
| prices = [] | |
| for product_id in products_id: | |
| price = get_price(product_id) | |
| prices.append({'product_id': product_id, 'price': price}) | |
| return prices |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Union | |
| from io import BytesIO | |
| from scenario2.nf_client import get_nf_data | |
| from scenario2.pdf_service import generate_pdf | |
| def issue_nota_fiscal(nf_id: str) -> BytesIO: | |
| nf_data = get_nf_data(nf_id) | |
| template = 'nf_pdf.template' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def save_pokemon_name(pokemon_name: str): | |
| # Should save pokemon name in database | |
| pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class X: | |
| def __eq__(self, other): | |
| return True | |
| x = X() | |
| if x == 1 and x == 2 and x == 3: | |
| print('Absurdo') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| VARIABLE_CACHE = {} | |
| def request_data(url): | |
| if 'my_data' not in VARIABLE_CACHE: | |
| data = request_data_from_web(url) | |
| VARIABLE_CACHE['my_data'] = data | |
| return data | |
| else: | |
| return VARIABLE_CACHE['my-data'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyFormClass(forms.ModelForm): | |
| def __init__(self, *args, **kwargs): | |
| super() | |
| pk = kwargs.pop("pk", None) | |
| if pk: | |
| self.field_with_querystring.query = Something.objects.filter(pk=pk) | |
| form = MyFormClass(pk=client_id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from locust import stats, HttpLocust, TaskSet, task, events | |
| from locust.runners import locust_runner | |
| import sys | |
| class QueryElyssonMRTaskSet(TaskSet): | |
| @task(5) | |
| def query_for_facebook(self): | |
| url = "" | |
| self.client.get(url) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from locust import stats, HttpLocust, TaskSet, task, events | |
| from locust.runners import locust_runner | |
| import sys | |
| class QueryElyssonMRTaskSet(TaskSet): | |
| @task(5) | |
| def query_for_facebook(self): | |
| url = "" | |
| self.client.get(url) |
NewerOlder