mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-14 10:27:57 +00:00
add test for timeout class
This commit is contained in:
36
test/python/api/test_timeout.py
Normal file
36
test/python/api/test_timeout.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
# This file is part of Nominatim. (https://nominatim.org)
|
||||
#
|
||||
# Copyright (C) 2025 by the Nominatim developer community.
|
||||
# For a full list of authors see the git log.
|
||||
"""
|
||||
Tests for timeout helper
|
||||
"""
|
||||
import asyncio
|
||||
|
||||
import pytest
|
||||
|
||||
from nominatim_api.timeout import Timeout
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_timeout_none():
|
||||
timeout = Timeout(None)
|
||||
|
||||
assert timeout.abs is None
|
||||
assert not timeout.is_elapsed()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_timeout_should_not_be_elapsed_after_creation():
|
||||
assert not Timeout(2).is_elapsed()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_timeout_elapse():
|
||||
timeout = Timeout(0.5)
|
||||
|
||||
assert timeout.abs is not None
|
||||
await asyncio.sleep(0.5)
|
||||
assert timeout.is_elapsed()
|
||||
Reference in New Issue
Block a user