This repository has been archived by the owner on Apr 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
7fb0722
commit 35ac92b
Showing
8 changed files
with
103 additions
and
0 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
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,12 @@ | ||
from typing import Any, List, Optional | ||
|
||
from def_result.ResultDetails.SuccessDetail import SuccessDetail | ||
|
||
|
||
class CreatedDetail(SuccessDetail): | ||
""" A new resource has been created """ | ||
def __init__(self, title: Optional[str] = "A new resource has been created", | ||
message: Optional[str] = None, | ||
code: Optional[int] = 201, | ||
more_data: Optional[List[Any]] = None): | ||
super().__init__(title=title, message=message, code=code, more_data=more_data) |
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,12 @@ | ||
from typing import Any, List, Optional | ||
|
||
from def_result.ResultDetails.SuccessDetail import SuccessDetail | ||
|
||
|
||
class NotModifiedDetail(SuccessDetail): | ||
""" The resource has not been modified since the last request """ | ||
def __init__(self, title: Optional[str] = "The resource has not been modified since the last request", | ||
message: Optional[str] = None, | ||
code: Optional[int] = 304, | ||
more_data: Optional[List[Any]] = None): | ||
super().__init__(title=title, message=message, code=code, more_data=more_data) |
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,13 @@ | ||
from typing import Any, List, Optional | ||
|
||
from def_result.ResultDetails.SuccessDetail import SuccessDetail | ||
|
||
|
||
class PartialContentDetail(SuccessDetail): | ||
""" Partial content """ | ||
|
||
def __init__(self, title: Optional[str] = "Partial content", | ||
message: Optional[str] = None, | ||
code: Optional[int] = 206, | ||
more_data: Optional[List[Any]] = None): | ||
super().__init__(title=title, message=message, code=code, more_data=more_data) |
Empty file.
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,21 @@ | ||
import unittest | ||
|
||
from def_result.ResultDetails.Success.CreatedDetail import CreatedDetail | ||
from tests.helpers import assert_result_detail | ||
|
||
|
||
class TestCreatedDetail(unittest.TestCase): | ||
def test_init_without_args(self): | ||
create_detail = CreatedDetail() | ||
|
||
assert_result_detail(test_class=self, result_detail=create_detail, title="A new resource has been created", code=201) | ||
|
||
def test_init_with_args(self): | ||
create_detail = CreatedDetail(title="title", message="message", code=100, more_data=["message"]) | ||
|
||
assert_result_detail(test_class=self, result_detail=create_detail, title="title", message="message", code=100, | ||
more_data=["message"]) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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,22 @@ | ||
import unittest | ||
|
||
from def_result.ResultDetails.Success.NotModifiedDetail import \ | ||
NotModifiedDetail | ||
from tests.helpers import assert_result_detail | ||
|
||
|
||
class TestNotModifiedDetail(unittest.TestCase): | ||
def test_init_without_args(self): | ||
detail = NotModifiedDetail() | ||
|
||
assert_result_detail(test_class=self, result_detail=detail, title="The resource has not been modified since the last request", code=304) | ||
|
||
def test_init_with_args(self): | ||
detail = NotModifiedDetail(title="title", message="message", code=100, more_data=["message"]) | ||
|
||
assert_result_detail(test_class=self, result_detail=detail, title="title", message="message", code=100, | ||
more_data=["message"]) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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,22 @@ | ||
import unittest | ||
|
||
from def_result.ResultDetails.Success.PartialContentDetail import \ | ||
PartialContentDetail | ||
from tests.helpers import assert_result_detail | ||
|
||
|
||
class TestPartialContentDetail(unittest.TestCase): | ||
def test_init_without_args(self): | ||
detail = PartialContentDetail() | ||
|
||
assert_result_detail(test_class=self, result_detail=detail, title="Partial content", code=206) | ||
|
||
def test_init_with_args(self): | ||
detail = PartialContentDetail(title="title", message="message", code=100, more_data=["message"]) | ||
|
||
assert_result_detail(test_class=self, result_detail=detail, title="title", message="message", code=100, | ||
more_data=["message"]) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |