Skip to content

Commit

Permalink
Corrige endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardoPicolo authored Aug 15, 2022
1 parent b96e537 commit 8dcd8c3
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/routers/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_error_response(e: Exception):
}


@router.post("/categoria/", tags=["Categoria"], response_model=CategoryModel)
@router.post("/categoria", tags=["Categoria"], response_model=CategoryModel)
async def post_category(data: CategoryModel, db: Session = Depends(get_db)):
try:
new_object = Category(**data.dict())
Expand All @@ -63,7 +63,7 @@ async def post_category(data: CategoryModel, db: Session = Depends(get_db)):
)


@router.get("/categoria/", tags=["Categoria"])
@router.get("/categoria", tags=["Categoria"])
async def get_categories(
category_id: Union[int, None] = None, db: Session = Depends(get_db)
):
Expand Down
4 changes: 2 additions & 2 deletions src/routers/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_error_response(e: Exception):
}


@router.get("/problema/", tags=["Problema"])
@router.get("/problema", tags=["Problema"])
async def get_problems(
problem_id: Union[int, None] = None,
db: Session = Depends(get_db),
Expand Down Expand Up @@ -97,7 +97,7 @@ async def get_problems(
)


@router.post("/problema/", tags=["Problema"], response_model=ProblemModel)
@router.post("/problema", tags=["Problema"], response_model=ProblemModel)
async def post_problem(data: ProblemModel, db: Session = Depends(get_db)):
try:
problem = Problem(**data.dict())
Expand Down
2 changes: 1 addition & 1 deletion tests/test_delete_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def test_delete_category(client):
response.json()["message"]
== "Categoria de id = 10 deletada com sucesso"
)
verify = client.get("/categoria/?category_id=10")
verify = client.get("/categoria?category_id=10")
assert verify.status_code == 200
assert not verify.json()["data"]["active"]

Expand Down
6 changes: 3 additions & 3 deletions tests/test_get_category.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
def test_categoria(client):
response = client.get("/categoria/")
response = client.get("/categoria")
assert response.status_code == 200


def test_categoria_id(client):
response = client.get("/categoria/?category_id=2")
response = client.get("/categoria?category_id=2")
assert response.status_code == 200
assert response.json()["data"] == {
"id": 2,
Expand All @@ -16,6 +16,6 @@ def test_categoria_id(client):


def test_categoria_id_not_found(client):
response = client.get("/categoria/?category_id=12")
response = client.get("/categoria?category_id=12")
assert response.status_code == 200
assert response.json()["message"] == "Nenhuma categoria encontrada"
6 changes: 3 additions & 3 deletions tests/test_get_problem.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def test_get_problem(client):
url = "/problema/"
url = "/problema"
response = client.get(url)
assert response.status_code == 200
# assert response.json() == {
Expand Down Expand Up @@ -91,12 +91,12 @@ def test_get_problem(client):


def test_get_problemid(client):
url = "/problema/?id=1"
url = "/problema?id=1"
response = client.get(url)
assert response.status_code == 200


def test_get_problemcategoryid(client):
url = "/problema/?category_id=1"
url = "/problema?category_id=1"
response = client.get(url)
assert response.status_code == 200
4 changes: 2 additions & 2 deletions tests/test_post_category.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
def test_post_category(client):
response = client.post(
"/categoria/", json={"name": "test", "description": "test"}
"/categoria", json={"name": "test", "description": "test"}
)
assert response.status_code == 201


def test_post_category_invalid_name(client):
response = client.post(
"/categoria/", json={"name": None, "description": "test"}
"/categoria", json={"name": None, "description": "test"}
)
assert response.status_code == 422
2 changes: 1 addition & 1 deletion tests/test_post_problem.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def test_post_problem(client):
response = client.post(
"/problema/",
"/problema",
json={"name": "test", "description": "test", "category_id": 1},
)
assert response.status_code == 201

0 comments on commit 8dcd8c3

Please sign in to comment.