Skip to content

Commit c06f337

Browse files
Lucas BeloLucas Belo
authored andcommitted
Code quality
1 parent b055f31 commit c06f337

File tree

4 files changed

+37
-9
lines changed

4 files changed

+37
-9
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import os
2+
3+
import boto3
4+
5+
client = boto3.client("dynamodb", endpoint_url=os.getenv("DYNAMODB_URL"))
6+
table_name = os.getenv("TABLE_NAME")
7+
client.create_table(
8+
AttributeDefinitions=[
9+
{"AttributeName": "PK", "AttributeType": "S"},
10+
{"AttributeName": "SK", "AttributeType": "S"},
11+
{"AttributeName": "GS1PK", "AttributeType": "S"},
12+
{"AttributeName": "GS1SK", "AttributeType": "S"},
13+
],
14+
TableName=table_name,
15+
KeySchema=[
16+
{"AttributeName": "PK", "KeyType": "HASH"},
17+
{"AttributeName": "SK", "KeyType": "RANGE"},
18+
],
19+
BillingMode="PAY_PER_REQUEST",
20+
GlobalSecondaryIndexes=[
21+
{
22+
"IndexName": "GS1",
23+
"KeySchema": [
24+
{"AttributeName": "GS1PK", "KeyType": "HASH"},
25+
{"AttributeName": "GS1SK", "KeyType": "RANGE"},
26+
],
27+
"Projection": {
28+
"ProjectionType": "ALL",
29+
},
30+
},
31+
],
32+
)

services/tasks_api/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from config import Config
1111
from models import Task
12-
from schemas import APITask, APITaskList, CreateTask, CloseTask
12+
from schemas import APITask, APITaskList, CloseTask, CreateTask
1313
from store import TaskStore
1414

1515
app = FastAPI()
@@ -58,7 +58,7 @@ def open_tasks(
5858
user_email: str = Depends(get_user_email),
5959
task_store: TaskStore = Depends(get_task_store),
6060
):
61-
results=task_store.list_open(owner=user_email)
61+
results = task_store.list_open(owner=user_email)
6262
print("Results: ", results)
6363
return APITaskList(results=results)
6464

@@ -84,4 +84,4 @@ def closed_tasks(
8484
user_email: str = Depends(get_user_email),
8585
task_store: TaskStore = Depends(get_task_store),
8686
):
87-
return APITaskList(results=task_store.list_closed(owner=user_email))
87+
return APITaskList(results=task_store.list_closed(owner=user_email))

services/tasks_api/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class Task:
1818
@classmethod
1919
def create(cls, id_, title, owner):
2020
return cls(id_, title, TaskStatus.OPEN, owner)
21-
2221

2322
def close(self):
2423
self.status = TaskStatus.CLOSED

services/tasks_api/tests.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,11 @@ def test_list_closed_tasks(client, user_email, id_token):
174174
headers={"Authorization": id_token},
175175
)
176176

177-
response = client.get(
178-
"/api/closed-tasks",
179-
headers={"Authorization": id_token}
180-
)
177+
response = client.get("/api/closed-tasks", headers={"Authorization": id_token})
181178
body = response.json()
182179

183180
assert response.status_code == status.HTTP_200_OK
184181
assert body["results"][0]["id"]
185182
assert body["results"][0]["title"] == title
186183
assert body["results"][0]["owner"] == user_email
187-
assert body["results"][0]["status"] == TaskStatus.CLOSED
184+
assert body["results"][0]["status"] == TaskStatus.CLOSED

0 commit comments

Comments
 (0)