Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recalcule area #6

Merged
merged 6 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions 5_unit_test/test_rectangle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from unittest import TestCase
from rectangle import Rectangle


class TestRectangle(TestCase):
def test_area(self):
rectangle1 = Rectangle(2, 4)
area = rectangle1.area()
self.assertEqual(8, area)

def test_perimetre(self):
rectangle2 = Rectangle(2, 4)
perimetre = rectangle2.perimeter()
self.assertEqual(12, perimetre)
5 changes: 3 additions & 2 deletions 6_architecture/api/quiz_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def _create_connection(self):
return conn

def create_answer(self, question_id, user_name, answer_id):
sql = ''' INSERT INTO QUIZ (question_id, user_name, answer_id)
sql = ''' INSERT INTO QUIZ (question_id, user_name, answer_id)
VALUES(?,?,?) '''
with self._create_connection() as conn:
cur = conn.cursor()
Expand All @@ -44,7 +44,8 @@ def count_answers_by_id(self, question_id: int):
return len(rows)

def update_answer(self, question_id: int, user_name, answer_id):
sql = ''' UPDATE QUIZ SET answer_id=? WHERE question_id=? AND user_name=?'''
sql = ''' UPDATE QUIZ SET answer_id=? WHERE
question_id=? AND user_name=?'''
with self._create_connection() as conn:
cur = conn.cursor()
cur.execute(sql, (answer_id, question_id, user_name))
Expand Down
12 changes: 8 additions & 4 deletions 6_architecture/async_call/async_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ def get_a_random_data() -> list:

dog_response = call_api('https://dog.ceo/api/breeds/image/random')
cat_response = call_api('https://catfact.ninja/fact')
pokemon_response = call_api(f'https://pokeapi.co/api/v2/pokemon/{random.randint(0, 100)}')
pokemon_response = call_api(f'https://pokeapi.co/api/v2/pokemon/'
f'{random.randint(0, 100)}')
user_response = call_api('https://randomuser.me/api/')
joke_response = call_api('https://official-joke-api.appspot.com/random_joke')
products_response = call_api('https://hub.dummyapis.com/products?noofRecords=10&idStarts=1001&currency=usd')
joke_response = call_api('https://official-joke-api.appspot.com'
'/random_joke')
products_response = call_api('https://hub.dummyapis.com/products?'
'noofRecords=10&idStarts=1001&currency=usd')

responses = [dog_response, cat_response, pokemon_response, joke_response, user_response, products_response]
responses = [dog_response, cat_response, pokemon_response,
joke_response, user_response, products_response]

end = datetime.now()
print(f"duration = {end - start}")
Expand Down
Loading