tests.test_usage

Tests of integration by usage.

    Caution: See details about Robust Imports documented in tests.context.

    Meta
    tests.test_usage.BasicIntegrationTestSuite

    Integration Tests - Fixtures:

            Test fixtures by importing test context.

            >>> import tests.test_usage as test_usage
            >>> import tests
            >>>

            >>> tests.test_usage.MulticastTestSuite #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS
            <class...tests.test_usage.MulticastTestSuite...>
            >>>

            >>> tests.test_usage.BasicIntegrationTestSuite #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS
            <class...tests.test_usage.BasicIntegrationTestSuite...>
            >>>

Module Contents

Classes

MulticastTestSuite

A test suite for special Multicast usage scenarios.

BasicIntegrationTestSuite

A test suite for basic functional integration tests of the multicast module.

Data

__module__

API

tests.test_usage.__module__[source]

‘tests’

class tests.test_usage.MulticastTestSuite(methodName='runTest')[source][source]

Bases: context.BasicUsageTestSuite

A test suite for special Multicast usage scenarios.

This test suite extends the BasicUsageTestSuite and focuses on testing various aspects of the multicast functionality, including error handling, command-line interface behavior, and basic send/receive operations.

Methods:

test_aborts_WHEN_calling_multicast_GIVEN_invalid_tools(): Tests the behavior of the CLI tools when given invalid tool names.

test_say_is_stable_WHEN_calling_multicast_GIVEN_say_tool(): Verifies the stability of the ‘SAY’ command with various message arguments.

test_recv_aborts_WHEN_calling_multicast_GIVEN_invalid_args(): Checks if the ‘RECV’ command properly aborts when given invalid arguments.

test_hear_aborts_WHEN_calling_multicast_GIVEN_invalid_args(): Ensures the ‘HEAR’ command aborts correctly when provided with invalid arguments.

test_hear_is_stable_WHEN_calling_multicast_GIVEN_invalid_tool(): Tests the stability of the ‘HEAR’ command when given an invalid tool (–hex).

test_noop_stable_WHEN_calling_multicast_GIVEN_noop_args(): Verifies the stability of the ‘NOOP’ command.

test_help_works_WHEN_calling_multicast_GIVEN_help_tool(): Checks if the ‘HELP’ command functions correctly.

test_hear_works_WHEN_say_works(): Tests the basic send and receive functionality using ‘SAY’ and ‘HEAR’ commands.

test_recv_Errors_WHEN_say_not_used(): Verifies that ‘RECV’ command produces an error when ‘SAY’ is not used.

Notes:

  • This test suite uses subprocess calls to test the multicast CLI interface.

  • Some tests involve multiprocessing to simulate concurrent operations.

  • Ensure proper network configuration for multicast tests to function correctly.

Warnings:

  • Some tests may require specific network conditions to pass successfully.

  • Failure in these tests may indicate issues with the multicast implementation or the testing environment rather than actual bugs in the code.

Initialization

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

__module__[source]

‘tests.test_usage’

__name__[source]

‘tests.test_usage.MulticastTestSuite’

test_aborts_WHEN_calling_multicast_GIVEN_invalid_tools()[source][source]

Tests the impossible state for CLI tools given bad tools

test_say_is_stable_WHEN_calling_multicast_GIVEN_say_tool()[source][source]

Tests the message argument for expected syntax given simple args.

First check that the –message argument requires a message value, or exits(2) as per CEP-8. Second check that providing the message value “test” is sufficient to succeed with exit(0).

Rational of these tests are simple enough, the mis-use of the SAY sub-command should result in an argument error value of 2, due to misuse of shell/CLI builtin as per CEP-8, while a value of 0 should indicate success.

test_recv_aborts_WHEN_calling_multicast_GIVEN_invalid_args()[source][source]

Tests the message argument for failure given invalid input

test_hear_aborts_WHEN_calling_multicast_GIVEN_invalid_args()[source][source]

Tests the message argument for failure given invalid input

test_hear_ignores_WHEN_calling_multicast_GIVEN_invalid_args()[source][source]

Tests the group argument for new auto-default behavior given None.

test_hear_is_stable_WHEN_calling_multicast_GIVEN_invalid_tool()[source][source]

Tests the hexdump argument for failure given future tools

test_noop_stable_WHEN_calling_multicast_GIVEN_noop_args()[source][source]

Tests the NOOP state for multicast given bad input

test_help_works_WHEN_calling_multicast_GIVEN_help_tool()[source][source]

Tests the HELP argument for help usage

test_hear_works_WHEN_say_works()[source][source]

Tests the basic send and recv test

test_hear_works_WHEN_fuzzed_and_say_works()[source][source]

Tests the basic send and recv test. Skips if fuzzing broke SAY fixture.

test_say_works_WHEN_using_stdin()[source][source]

Tests the basic send with streamed input test case.

test_recv_Errors_WHEN_say_not_used()[source][source]

Tests the basic noop recv test

class tests.test_usage.BasicIntegrationTestSuite(methodName='runTest')[source][source]

Bases: context.BasicUsageTestSuite

A test suite for basic functional integration tests of the multicast module.

This class inherits from context.BasicUsageTestSuite and provides a set of test cases to verify the functionality of the multicast module’s command-line interface and core features.

The suite includes tests for:

  • Printing usage information when called with the help argument

  • Verifying command-specific help output

  • Comparing responses between absolute and implicit module calls

  • Checking version information output

  • Validating error handling for invalid inputs

  • Profiling and stability checks for the NOOP command

Attributes: _thepython (str): Path to the Python interpreter used for testing.

Methods: setUp(): Prepares the test environment before each test method is run. test_prints_usage_WHEN_called_GIVEN_help_argument(): Verifies help output. test_prints_usage_WHEN_called_GIVEN_cmd_and_help_argument(): Checks command-specific help. test_equivilant_response_WHEN_absolute_vs_implicit(): Compares module call methods. test_prints_version_WHEN_called_GIVEN_version_argument(): Validates version output. test_Usage_Error_WHEN_the_help_command_is_called(): Ensures correct help output. test_profile_WHEN_the_noop_command_is_called(): Profiles the NOOP command. test_stable_WHEN_the_noop_command_is_called(): Checks NOOP command stability. test_invalid_Error_WHEN_cli_called_GIVEN_bad_input(): Verifies error handling.

Note: This test suite relies on the context module for utility functions and the subprocess module for executing Python commands. It uses various assertion methods to validate the expected behavior of the multicast module.

Example: To run this test suite, use the unittest module’s test runner:

    ```
    python -m unittest tests.test_usage.BasicIntegrationTestSuite
    ```

Initialization

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

__module__[source]

‘tests.test_usage’

__name__[source]

‘tests.test_usage.BasicIntegrationTestSuite’

setUp()[source][source]
test_prints_usage_WHEN_called_GIVEN_help_argument()[source][source]

Test case for multicast.main help.

test_prints_usage_WHEN_called_GIVEN_cmd_and_help_argument()[source][source]

Test case for multicast HEAR|RECV|SAY help.

test_equivilant_response_WHEN_absolute_vs_implicit()[source][source]

Test case for multicast vs multicast.main

test_prints_version_WHEN_called_GIVEN_version_argument()[source][source]

Test for result from –version argument: python -m multicast.* –version

test_Usage_Error_WHEN_the_help_command_is_called()[source][source]

Test case for multicast* –help.

test_Usage_Error_WHEN_the_help_sub_command_is_called()[source][source]

Test case for validating help output of multicast sub-commands.

This test ensures that the help output is correct for various sub-commands (HEAR, RECV, SAY) in both daemon and non-daemon modes. It validates that each command combination provides appropriate usage information.

Test fixtures use named tuples to organize:

  • mode: daemon/non-daemon mode

  • command: the sub-command being tested

test_profile_WHEN_the_noop_command_is_called()[source][source]

Test case template for profiling

test_stable_WHEN_the_noop_command_is_called()[source][source]

Test case template for profiling

test_invalid_Error_WHEN_cli_called_GIVEN_bad_input()[source][source]

Test case template for invalid input to multicast CLI.