2013-12-07 02:13:50 +04:00
|
|
|
from django.test import TestCase
|
2015-06-25 23:55:51 +03:00
|
|
|
|
2013-12-07 02:13:50 +04:00
|
|
|
from rest_framework.status import (
|
2024-10-19 22:10:57 +03:00
|
|
|
is_client_error, is_informational, is_redirect, is_server_error, is_success
|
2013-12-07 02:13:50 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class TestStatus(TestCase):
|
|
|
|
def test_status_categories(self):
|
2022-11-21 14:32:07 +03:00
|
|
|
assert not is_informational(99)
|
|
|
|
assert is_informational(100)
|
|
|
|
assert is_informational(199)
|
|
|
|
assert not is_informational(200)
|
2013-12-07 02:13:50 +04:00
|
|
|
|
2022-11-21 14:32:07 +03:00
|
|
|
assert not is_success(199)
|
|
|
|
assert is_success(200)
|
|
|
|
assert is_success(299)
|
|
|
|
assert not is_success(300)
|
2013-12-07 02:13:50 +04:00
|
|
|
|
2022-11-21 14:32:07 +03:00
|
|
|
assert not is_redirect(299)
|
|
|
|
assert is_redirect(300)
|
|
|
|
assert is_redirect(399)
|
|
|
|
assert not is_redirect(400)
|
2013-12-07 02:13:50 +04:00
|
|
|
|
2022-11-21 14:32:07 +03:00
|
|
|
assert not is_client_error(399)
|
|
|
|
assert is_client_error(400)
|
|
|
|
assert is_client_error(499)
|
|
|
|
assert not is_client_error(500)
|
2013-12-07 02:13:50 +04:00
|
|
|
|
2022-11-21 14:32:07 +03:00
|
|
|
assert not is_server_error(499)
|
|
|
|
assert is_server_error(500)
|
|
|
|
assert is_server_error(599)
|
|
|
|
assert not is_server_error(600)
|