Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaellaude committed Jun 30, 2024
1 parent 95c4b43 commit 84553ff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion backend/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def update_plan(
)
return AssignmentsUpdate(
acknowledged=result.acknowledged,
inserted_id=result.upserted_id,
upserted_id=result.upserted_id,
matched_count=result.matched_count,
modified_count=result.modified_count,
)
2 changes: 1 addition & 1 deletion backend/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class AssignmentsUpdate(BaseModel):
"""

acknowledged: bool = PydanticField(description="Acknowledged")
inserted_id: Optional[str] = PydanticField(description="Inserted ID")
upserted_id: Optional[str] = PydanticField(description="Inserted ID")
matched_count: int = PydanticField(description="Matched count")
modified_count: int = PydanticField(description="Modified count")

Expand Down
11 changes: 6 additions & 5 deletions backend/app/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def plan_id_fixture() -> InsertOneResult:


def test_get_plan(client: TestClient, plan: InsertOneResult):
print(plan.inserted_id)
response = client.get(f"/plan/{plan.inserted_id}")
assert response.status_code == 200

Expand All @@ -68,25 +67,27 @@ def test_create_plan(client: TestClient):
assert response.status_code == 201


def test_update_plan(client: TestClient, plan: InsertOneResult):
def test_update_add_to_plan(client: TestClient, plan: InsertOneResult):
response = client.put(
f"/plan/{plan.inserted_id}", json={"assignments": {"06067001102": 1}}
)
assert response.status_code == 200
data = response.json()
assert data["modified_count"] == 1
assert data["upserted_id"] is None


def test_update_plan_with_modification_to_existing_assignment(
client: TestClient, plan: InsertOneResult
):
def test_update_update_and_add(client: TestClient, plan: InsertOneResult):
response = client.put(
f"/plan/{plan.inserted_id}",
json={"assignments": {"06067001101": 2, "06067001102": 1}},
)
assert response.status_code == 200
data = response.json()
assert data["modified_count"] == 1
assert data["matched_count"] == 1
assert data["acknowledged"] is True
assert data["upserted_id"] is None


def test_get_missing_plan(client: TestClient):
Expand Down

0 comments on commit 84553ff

Please sign in to comment.