Skip to content

Commit 0f6409d

Browse files
committed
test: added unit test for HTTPStatusPattern.is_official
1 parent e74ca6d commit 0f6409d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_parser/test_responses.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from http import HTTPStatus
12
from unittest.mock import MagicMock
23

34
import pytest
@@ -289,3 +290,21 @@ def test_http_status_pattern_lt(pattern1: str, pattern2: str, result: bool) -> N
289290
assert isinstance(first, HTTPStatusPattern)
290291
assert isinstance(second, HTTPStatusPattern)
291292
assert (first < second) == result
293+
294+
295+
@pytest.mark.parametrize(
296+
"pattern,result",
297+
[
298+
(str(HTTPStatus.OK), True),
299+
(str(HTTPStatus.NOT_FOUND), True),
300+
(str(HTTPStatus.CONFLICT), True),
301+
(str(HTTPStatus.INTERNAL_SERVER_ERROR), True),
302+
("2XX", False),
303+
("1", False),
304+
("99999", False),
305+
],
306+
)
307+
def test_http_status_pattern_is_official(pattern: str, result: bool) -> None:
308+
parsed = HTTPStatusPattern.parse(pattern)
309+
assert isinstance(parsed, HTTPStatusPattern)
310+
assert parsed.is_official == result

0 commit comments

Comments
 (0)