-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
72 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
3 changes: 2 additions & 1 deletion
3
api/src/tests/integration/features/health_check/test_health_check_feature.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import pytest | ||
from starlette.status import HTTP_200_OK | ||
from starlette.testclient import TestClient | ||
|
||
pytestmark = pytest.mark.integration | ||
|
||
|
||
class TestTodo: | ||
def test_get(self, test_app): | ||
def test_get(self, test_app: TestClient): | ||
response = test_app.get("/health-check") | ||
assert response.status_code == HTTP_200_OK | ||
assert response.content == b"OK" |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
import pytest | ||
from pydantic.error_wrappers import ValidationError | ||
|
||
from data_providers.repository_interfaces.TodoRepositoryInterface import ( | ||
TodoRepositoryInterface, | ||
) | ||
from features.todo.use_cases.add_todo import AddTodoRequest, add_todo_use_case | ||
|
||
|
||
def test_add_with_valid_title_should_return_todo(todo_repository): | ||
def test_add_with_valid_title_should_return_todo(todo_repository: TodoRepositoryInterface): | ||
data = AddTodoRequest(title="new todo") | ||
result = add_todo_use_case(data, todo_repository=todo_repository) | ||
assert result.title == data.title | ||
|
||
|
||
def test_add_with_empty_title_should_throw_validation_error(todo_repository): | ||
def test_add_with_empty_title_should_throw_validation_error(todo_repository: TodoRepositoryInterface): | ||
with pytest.raises(ValidationError): | ||
data = AddTodoRequest(title="") | ||
add_todo_use_case(data, todo_repository=todo_repository) |
9 changes: 6 additions & 3 deletions
9
api/src/tests/unit/features/todo/use_cases/test_delete_todo_by_id.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
import pytest as pytest | ||
|
||
from common.exceptions import NotFoundException | ||
from data_providers.repository_interfaces.TodoRepositoryInterface import ( | ||
TodoRepositoryInterface, | ||
) | ||
from features.todo.use_cases.delete_todo_by_id import ( | ||
DeleteTodoByIdResponse, | ||
delete_todo_use_case, | ||
) | ||
|
||
|
||
def test_delete_todo_should_return_success(todo_repository): | ||
def test_delete_todo_should_return_success(todo_repository: TodoRepositoryInterface): | ||
id = "dh2109" | ||
result: DeleteTodoByIdResponse = delete_todo_use_case(id=id, todo_repository=todo_repository) | ||
assert result.success | ||
|
||
|
||
def test_delete_todo_should_return_not_success(todo_repository): | ||
def test_delete_todo_should_return_not_success(todo_repository: TodoRepositoryInterface): | ||
id = "unkown" | ||
with pytest.raises(NotFoundException) as error: | ||
delete_todo_use_case(id=id, todo_repository=todo_repository) | ||
assert error.message == "The todo item you specified does not exist." | ||
assert error.value.message == "The todo item you specified does not exist." |
7 changes: 6 additions & 1 deletion
7
api/src/tests/unit/features/todo/use_cases/test_get_todo_all.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
from typing import Dict | ||
|
||
from data_providers.repository_interfaces.TodoRepositoryInterface import ( | ||
TodoRepositoryInterface, | ||
) | ||
from features.todo.use_cases.get_todo_all import get_todo_all_use_case | ||
|
||
|
||
def test_get_todos_should_return_todos(todo_repository, todo_test_data): | ||
def test_get_todos_should_return_todos(todo_repository: TodoRepositoryInterface, todo_test_data: Dict[str, dict]): | ||
todos = get_todo_all_use_case(todo_repository=todo_repository) | ||
assert len(todos) == len(todo_test_data.keys()) |
11 changes: 8 additions & 3 deletions
11
api/src/tests/unit/features/todo/use_cases/test_get_todo_by_id.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
from typing import Dict | ||
|
||
import pytest as pytest | ||
|
||
from common.exceptions import NotFoundException | ||
from data_providers.repository_interfaces.TodoRepositoryInterface import ( | ||
TodoRepositoryInterface, | ||
) | ||
from features.todo.use_cases.get_todo_by_id import ( | ||
GetTodoByIdResponse, | ||
get_todo_by_id_use_case, | ||
) | ||
|
||
|
||
def test_get_todo_by_id_should_return_todo(todo_repository, todo_test_data): | ||
def test_get_todo_by_id_should_return_todo(todo_repository: TodoRepositoryInterface, todo_test_data: Dict[str, dict]): | ||
id = "dh2109" | ||
todo: GetTodoByIdResponse = get_todo_by_id_use_case(id, todo_repository=todo_repository) | ||
assert todo.title == todo_test_data[id]["title"] | ||
|
||
|
||
def test_get_todo_by_id_should_throw_todo_not_found_error(todo_repository): | ||
def test_get_todo_by_id_should_throw_todo_not_found_error(todo_repository: TodoRepositoryInterface): | ||
id = "unknown" | ||
with pytest.raises(NotFoundException) as error: | ||
get_todo_by_id_use_case(id, todo_repository=todo_repository) | ||
assert error.message == "The todo item you specified does not exist." | ||
assert error.value.message == "The todo item you specified does not exist." |
5 changes: 4 additions & 1 deletion
5
api/src/tests/unit/features/todo/use_cases/test_update_todo.py
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Use case | ||
|
||
There will be one use case for each individual action/command of an actor. An actor is a person or another system that interacts with our application. Typically, it will be a regular user. | ||
|
||
## Examples | ||
|
||
For a meetup.com clone, it could be: | ||
|
||
* Confirming attendance as an attendee | ||
* Cancelling attendance as an attendee | ||
* Drafting new meeting as an organizer | ||
|
||
## Related concepts | ||
|
||
|
||
|