Skip to content

Commit

Permalink
Add a test for test_is_session_init_request()
Browse files Browse the repository at this point in the history
  • Loading branch information
Gallaecio committed Jul 18, 2024
1 parent 08fca0b commit b923923
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
SESSION_AGGRESSIVE_RETRY_POLICY,
SESSION_DEFAULT_RETRY_POLICY,
SessionConfig,
is_session_init_request,
session_config,
)
from scrapy_zyte_api._session import SESSION_INIT_META_KEY, session_config_registry
Expand Down Expand Up @@ -2649,3 +2650,16 @@ def parse(self, response):
}
if reason is not None:
assert reason in caplog.text


@pytest.mark.parametrize(
("meta", "expected"),
(
({}, False),
({SESSION_INIT_META_KEY: False}, False),
({SESSION_INIT_META_KEY: True}, True),
),
)
def test_is_session_init_request(meta, expected):
actual = is_session_init_request(Request("https://example.com", meta=meta))
assert expected == actual

0 comments on commit b923923

Please sign in to comment.