3.0.ipv8.test.test_requestcache =============================== .. py:module:: 3.0.ipv8.test.test_requestcache Attributes ---------- .. autoapisummary:: 3.0.ipv8.test.test_requestcache.CACHE_TIMEOUT Classes ------- .. autoapisummary:: 3.0.ipv8.test.test_requestcache.MockCache 3.0.ipv8.test.test_requestcache.MockRegisteredCache 3.0.ipv8.test.test_requestcache.MockInfiniteCache 3.0.ipv8.test.test_requestcache.MockNamedCache 3.0.ipv8.test.test_requestcache.MockNamedNumberCache 3.0.ipv8.test.test_requestcache.TestRequestCache Module Contents --------------- .. py:data:: CACHE_TIMEOUT :value: 0.01 .. py:class:: MockCache(request_cache: 3.0.ipv8.requestcache.RequestCache) Bases: :py:obj:`3.0.ipv8.requestcache.RandomNumberCache` A cache that stores a future. .. py:attribute:: timed_out .. py:property:: timeout_delay :type: float Adopt the global cache timeout value. .. py:method:: on_timeout() -> None When actually timed out, set the result of our future to ``None``. .. py:class:: MockRegisteredCache(request_cache: 3.0.ipv8.requestcache.RequestCache) Bases: :py:obj:`3.0.ipv8.requestcache.RandomNumberCache` A cache that stores a future and registers it. .. py:attribute:: timed_out .. py:property:: timeout_delay :type: float Adopt the global cache timeout value. .. py:method:: on_timeout() -> None Don't do anything on timeout. .. py:class:: MockInfiniteCache(request_cache: 3.0.ipv8.requestcache.RequestCache) Bases: :py:obj:`3.0.ipv8.requestcache.RandomNumberCache` Create a cache that has near-infinite timeout delay. .. py:attribute:: timed_out :value: False .. py:property:: timeout_delay :type: float Set the timeout delay to be huge. .. py:method:: on_timeout() -> None Flag the ``timed_out`` value as timed out. .. py:class:: MockNamedCache(request_cache: 3.0.ipv8.requestcache.RequestCache) Bases: :py:obj:`3.0.ipv8.requestcache.RandomNumberCacheWithName` A cache with a name. .. py:attribute:: name :value: 'my-cache-name' .. py:method:: on_timeout() -> None We do nothing. .. py:class:: MockNamedNumberCache(request_cache: RequestCache, prefix: str, number: int) Bases: :py:obj:`3.0.ipv8.requestcache.NumberCache` A "normal" NumberCache that has a name. .. py:attribute:: name :value: 'test' .. py:class:: TestRequestCache(methodName: str = 'runTest') Bases: :py:obj:`3.0.ipv8.test.base.TestBase` Tests related to the request cache. .. py:method:: setUp() -> None Create a new request cache, without registered caches. .. py:method:: tearDown() -> None :async: Destroy the request cache. .. py:method:: test_shutdown() -> None :async: Test if RequestCache does not allow new Caches after shutdown(). .. py:method:: test_timeout() -> None :async: Test if the cache.on_timeout() is called after the cache.timeout_delay. .. py:method:: test_add_duplicate() -> None :async: Test if adding a cache twice returns None as the newly added cache. .. py:method:: test_timeout_future_default_value() -> None :async: Test if a registered future gets set to None on timeout. .. py:method:: test_timeout_future_custom_value() -> None :async: Test if a registered future gets set to a value on timeout. .. py:method:: test_timeout_future_exception() -> None :async: Test if a registered future raises an exception on timeout. .. py:method:: test_cancel_future_after_shutdown() -> None :async: Test if a registered future is cancelled when the RequestCache has shutdown. .. py:method:: test_cancel_future() -> None :async: Test if a registered future gets canceled at shutdown. .. py:method:: test_passthrough_noargs() -> None :async: Test if passthrough without arguments immediately times a cache out. .. py:method:: test_passthrough_timeout() -> None :async: Test if passthrough respects the timeout value. .. py:method:: test_passthrough_filter_one_match() -> None :async: Test if passthrough filters correctly with one filter, that matches. .. py:method:: test_passthrough_filter_one_mismatch() -> None :async: Test if passthrough filters correctly with one filter, that doesn't match. .. py:method:: test_passthrough_filter_many_match() -> None :async: Test if passthrough filters correctly with many filters, that all match. .. py:method:: test_passthrough_filter_some_match() -> None :async: Test if passthrough filters correctly with many filters, for which some match. .. py:method:: test_passthrough_filter_no_match() -> None :async: Test if passthrough filters correctly with many filters, for which none match. .. py:method:: test_has_by_class() -> None :async: Check if we can call ``.has()`` by cache class. .. py:method:: test_wait_for_by_name() -> None :async: Check if we can call ``.wait_for()`` by cache name. .. py:method:: test_wait_for_by_class() -> None :async: Check if we can call ``.wait_for()`` by cache class. .. py:method:: test_wait_for_already_added() -> None :async: Check if we can ``.wait_for()`` returns when a cache is already available. .. py:method:: test_wait_for_timeout() -> None :async: Check if ``.wait_for()`` cancels its future when a timeout occurs. .. py:method:: test_get_by_class() -> None :async: Check if we can call ``.get()`` by cache class. .. py:method:: test_pop_by_class() -> None :async: Check if we can call ``.pop()`` by cache class.