3.0.ipv8.test.test_loader ========================= .. py:module:: 3.0.ipv8.test.test_loader Classes ------- .. autoapisummary:: 3.0.ipv8.test.test_loader.MockCommunity 3.0.ipv8.test.test_loader.MockWalk 3.0.ipv8.test.test_loader.MockWalk2 3.0.ipv8.test.test_loader.MockBootstrapper 3.0.ipv8.test.test_loader.MockBootstrapper2 3.0.ipv8.test.test_loader.MockSession 3.0.ipv8.test.test_loader.MockOverlayProvider 3.0.ipv8.test.test_loader.StagedCommunityLauncher 3.0.ipv8.test.test_loader.TestCommunityLauncher 3.0.ipv8.test.test_loader.TestCommunityLoader Module Contents --------------- .. py:class:: MockCommunity(settings: 3.0.ipv8.community.CommunitySettings) Bases: :py:obj:`3.0.ipv8.community.Community` Empty community implementation. .. py:attribute:: peer .. py:attribute:: endpoint .. py:attribute:: network .. py:attribute:: kwargs .. py:attribute:: bootstrappers :value: [] .. py:class:: MockWalk(community: MockCommunity, some_attribute: int) Bases: :py:obj:`3.0.ipv8.peerdiscovery.discovery.DiscoveryStrategy` Empty walker with an init parameter. .. py:attribute:: overlay .. py:attribute:: some_attribute .. py:method:: take_step() -> None Do nothing. .. py:class:: MockWalk2(overlay: _OT) Bases: :py:obj:`3.0.ipv8.peerdiscovery.discovery.DiscoveryStrategy` Empty walker. .. py:method:: take_step() -> None Do nothing. .. py:class:: MockBootstrapper(some_attribute: int) Bases: :py:obj:`3.0.ipv8.bootstrapping.bootstrapper_interface.Bootstrapper` Empty bootstrapper with an init parameter. .. py:attribute:: some_attribute .. py:method:: initialize(overlay: 3.0.ipv8.community.Community) -> None :async: Initialize nothing. .. py:method:: get_addresses(overlay: 3.0.ipv8.community.Community, timeout: float) -> collections.abc.Iterable[3.0.ipv8.types.Address] :async: Return no addresses. .. py:method:: keep_alive(overlay: 3.0.ipv8.community.Community) -> None Ping nothing. .. py:method:: blacklist() -> collections.abc.Iterable[3.0.ipv8.types.Address] Return no blacklist. .. py:method:: unload() -> None Unload nothing. .. py:class:: MockBootstrapper2 Bases: :py:obj:`3.0.ipv8.bootstrapping.bootstrapper_interface.Bootstrapper` Empty bootstrapper. .. py:method:: initialize(overlay: 3.0.ipv8.community.Community) -> None :async: Initialize nothing. .. py:method:: get_addresses(overlay: 3.0.ipv8.community.Community, timeout: float) -> collections.abc.Iterable[3.0.ipv8.types.Address] :async: Return no addresses. .. py:method:: keep_alive(overlay: 3.0.ipv8.community.Community) -> None Ping nothing. .. py:method:: blacklist() -> collections.abc.Iterable[3.0.ipv8.types.Address] Return no blacklist. .. py:method:: unload() -> None Unload nothing. .. py:class:: MockSession Fake session object. .. py:attribute:: launch_condition1 :value: True .. py:attribute:: launch_condition2 :value: False .. py:attribute:: some_attribute1 :value: 'I am a string :)' .. py:attribute:: some_attribute2 :value: 1337 .. py:attribute:: community :value: None .. py:class:: MockOverlayProvider Fake overlay provider. .. py:attribute:: endpoint :value: None .. py:attribute:: network :value: None .. py:attribute:: overlays :value: [] .. py:attribute:: strategies :value: [] .. py:class:: StagedCommunityLauncher Bases: :py:obj:`3.0.ipv8.loader.CommunityLauncher` Community launcher with some fake data. .. py:method:: not_before() -> list[str] Should wait for CommunityLauncher1 and CommunityLauncher2. .. py:method:: should_launch(session: MockSession) -> bool Pull the launch conditions from our session. .. py:method:: get_overlay_class() -> type[MockCommunity] We run on the MockCommunity. .. py:method:: get_kwargs(session: MockSession) -> dict[str, Any] The keyword args to launch our community with. .. py:method:: get_walk_strategies() -> list[tuple[type[3.0.ipv8.peerdiscovery.discovery.DiscoveryStrategy], dict, int]] Get our walkers. .. py:method:: get_bootstrappers(session: MockSession) -> list[tuple[type[3.0.ipv8.bootstrapping.bootstrapper_interface.Bootstrapper], dict]] Get the bootstrappers for our community. .. py:method:: finalize(ipv8: 3.0.ipv8.types.IPv8, session: MockSession, community: MockCommunity) -> None Finish off our launching procedure. .. py:class:: TestCommunityLauncher(methodName: str = 'runTest') Bases: :py:obj:`3.0.ipv8.test.base.TestBase` Tests related to the community launcher. .. py:method:: setUp() -> None Create a staged launcher to run tests with. .. py:method:: test_not_before_list() -> None Check that the not_before decorator with multiple arguments equals the not_before() definition. .. py:method:: test_not_before_multiple() -> None Check that multiple not_before decorators with an argument equals the not_before() definition. .. py:method:: test_should_launch_single() -> None Check that a validated single launch condition causes should_launch() to return True. .. py:method:: test_shouldnt_launch_single() -> None Check that an invalid single launch condition causes should_launch() to return False. .. py:method:: test_should_launch_multiple() -> None Check that a validated multiple launch conditions causes should_launch() to return True. .. py:method:: test_shouldnt_launch_multiple() -> None Check that an invalid condition for multiple launch conditions causes should_launch() to return False. .. py:method:: test_overlay_class_from_str() -> None Check if a Community string specification can be lazy-loaded through the overlay_class decorator. .. py:method:: test_overlay_class_from_class() -> None Check if a Community class can be lazy-loaded through the overlay_class decorator. .. py:method:: test_overlay_class_from_function() -> None Check if a Community class (functional representation) can be lazy-loaded through the overlay_class decorator. .. py:method:: test_walk_strategy_from_str() -> None Check if adding a walk strategy string specification is successful. .. py:method:: test_walk_strategy_from_class() -> None Check if adding a walk strategy from a DiscoveryStrategy class is successful. .. py:method:: test_walk_strategy_from_function() -> None Check if adding a walk strategy from a function is successful. .. py:method:: test_walk_strategy_multiple() -> None Check if adding multiple walk strategies is successful. .. py:method:: test_bootstrapper_from_str() -> None Check if adding a bootstrapper string specification is successful. .. py:method:: test_bootstrapper_from_class() -> None Check if adding a bootstrapper from a Bootstrapper class is successful. .. py:method:: test_bootstrapper_from_function() -> None Check if adding a bootstrapper from a function is successful. .. py:method:: test_bootstrapper_multiple() -> None Check if adding multiple bootstrappers is successful. .. py:method:: test_set_in_session() -> None Check if set_in_session correctly sets the attribute of the session. .. py:method:: test_kwargs() -> None Check if the kwargs decorator correctly passes keyword arguments. .. py:method:: test_name() -> None Check if the name of a launcher can be set, using the name decorator. .. py:method:: test_no_name() -> None Check if the name of a launcher is equal to the Community class name by default. .. py:class:: TestCommunityLoader(methodName: str = 'runTest') Bases: :py:obj:`3.0.ipv8.test.base.TestBase` Tests related to the community loader. .. py:method:: setUp() -> None Create a loader and a community provider to test with. .. py:method:: test_load_community() -> None Check if a CommunityLauncher is launched correctly. .. py:method:: test_protect_infinite_loop() -> None Check if the CommunityLoader raises an error when it encounters a circular dependency.