ocs_ci.framework.tests package

Submodules

ocs_ci.framework.tests.conftest module

Pytest configuration for framework unit tests.

Sets up logging configuration required for testing the custom logger.

ocs_ci.framework.tests.conftest.setup_log_record_factory()

Set up the custom log record factory for all tests.

This ensures that the ‘clusterctx’ field is added to all log records, which is expected by the pytest log format in pytest.ini.

ocs_ci.framework.tests.test_config module

class ocs_ci.framework.tests.test_config.TestConfig

Bases: object

reset_config()
test_custom_conf()
test_custom_conf_multicluster()
test_defaults()
test_defaults_specific()
test_layered_conf()
test_multicluster_ctx_switch()
class ocs_ci.framework.tests.test_config.TestMergeDict

Bases: object

test_merge_dict()

ocs_ci.framework.tests.test_custom_logger module

Unit tests for custom logger implementation.

Tests the OCSCILogger class and custom log levels (TEST_STEP, ASSERTION, AI_DATA).

class ocs_ci.framework.tests.test_custom_logger.TestAIDataLogging

Bases: object

Test ai_data() method functionality

test_ai_data_basic_logging(custom_logger, log_capture)

Test basic AI_DATA logging

test_ai_data_below_debug(custom_logger, log_capture)

Test AI_DATA is below DEBUG level

test_ai_data_with_args(custom_logger, log_capture)

Test AI_DATA logging with format args

class ocs_ci.framework.tests.test_custom_logger.TestAssertionLogging

Bases: object

Test assertion() method functionality

test_assertion_basic_logging(custom_logger, log_capture)

Test basic assertion logging

test_assertion_respects_log_level(custom_logger, log_capture)

Test assertion logging respects logger level

test_assertion_with_args(custom_logger, log_capture)

Test assertion logging with format args

class ocs_ci.framework.tests.test_custom_logger.TestBackwardsCompatibility

Bases: object

Test backwards compatibility with existing code

test_existing_logger_calls_work()

Test that existing logging patterns still work

test_logger_configuration(custom_logger)

Test logger configuration methods still work

test_logger_hierarchy()

Test logger hierarchy is preserved

class ocs_ci.framework.tests.test_custom_logger.TestCustomLogLevels

Bases: object

Test custom log level registration

test_ai_data_level_registered()

Test AI_DATA level is registered with correct value

test_assertion_level_registered()

Test ASSERTION level is registered with correct value

test_idempotent_registration()

Test that re-registering levels doesn’t cause errors

test_level_ordering()

Test custom levels are ordered correctly relative to standard levels

test_test_step_level_registered()

Test TEST_STEP level is registered with correct value

class ocs_ci.framework.tests.test_custom_logger.TestDeprecationWarnings

Bases: object

Test deprecation warnings for old log_step()

test_deprecation_message_helpful(recwarn)

Test that deprecation message provides migration guidance

test_log_step_not_required_for_new_code()

Test that new code doesn’t need to import log_step

test_log_step_shows_deprecation_warning(recwarn)

Test that old log_step() shows deprecation warning

test_log_step_still_works(log_capture)

Test that old log_step() still works despite deprecation

test_migration_path_equivalence(log_capture)

Test that log_step and logger.test_step produce exactly the same output format

class ocs_ci.framework.tests.test_custom_logger.TestEdgeCases

Bases: object

Test edge cases and error handling

test_assertion_with_exception_info(custom_logger, log_capture)

Test assertion logging with exception info

test_step_with_empty_message(custom_logger, log_capture)

Test step with empty message

test_step_with_multiline_message(custom_logger, log_capture)

Test step with multiline message

test_step_with_special_characters(custom_logger, log_capture)

Test step with special characters

class ocs_ci.framework.tests.test_custom_logger.TestLoggerIntegration

Bases: object

Test logger integration with framework

test_logger_name_preserved(custom_logger, logger_name)

Test logger preserves its name

test_multiple_loggers_independent()

Test multiple logger instances maintain independent step counters

test_standard_logging_still_works(custom_logger, log_capture)

Test standard logging methods still work correctly

class ocs_ci.framework.tests.test_custom_logger.TestOCSCILoggerClass

Bases: object

Test OCSCILogger class functionality

test_logger_has_ai_data_method(custom_logger)

Test logger has ai_data() method

test_logger_has_assertion_method(custom_logger)

Test logger has assertion() method

test_logger_has_test_step_method(custom_logger)

Test logger has test_step() method

test_logger_inherits_standard_methods(custom_logger)

Test logger still has standard logging methods

test_logger_is_custom_class(custom_logger)

Test that getLogger returns OCSCILogger instance

class ocs_ci.framework.tests.test_custom_logger.TestPerformance

Bases: object

Test performance characteristics

test_logging_performance_overhead(custom_logger)

Test that custom logger doesn’t add significant overhead

class ocs_ci.framework.tests.test_custom_logger.TestPytestIntegration

Bases: object

Test integration with pytest

test_ai_data_captured_with_low_level(caplog)

Test that AI_DATA logs are captured when level is set appropriately

test_ai_data_not_captured_at_debug_level(caplog)

Test that AI_DATA logs are NOT captured at DEBUG level

test_custom_levels_in_caplog_records(caplog)

Test that custom level names appear in caplog records

test_exception_info_in_custom_levels(caplog)

Test that exception info works with custom log levels

test_extra_fields_with_custom_levels(caplog)

Test that extra fields work with custom log levels

test_logs_captured_by_pytest(caplog)

Test that custom log levels are captured by pytest

test_pytest_fixture_compatibility(custom_logger, log_capture)

Test that custom logger works with pytest fixtures

test_step_counter_independent_per_test()

Test that each test gets independent step numbering

test_step_counter_resets_between_tests()

Test that step counters reset between pytest tests

test_step_formatting_in_pytest_output(caplog)

Test that step messages are formatted correctly in pytest output

class ocs_ci.framework.tests.test_custom_logger.TestStepCounters

Bases: object

Test step counter management

test_get_current_step()

Test getting current step count

test_reset_step_counts_all_modules()

Test resetting all step counts

test_reset_step_counts_single_module()

Test resetting step count for single module

test_step_counter_increments(logger_name)

Test step counter increments correctly

test_step_counter_per_module()

Test step counters are tracked per module

class ocs_ci.framework.tests.test_custom_logger.TestStepLogging

Bases: object

Test test_step() method functionality

test_step_basic_logging(custom_logger, log_capture)

Test basic test_step logging

test_step_format(custom_logger, log_capture)

Test test_step message format includes function name and number

test_step_numbering(custom_logger, log_capture)

Test test_step numbering increments correctly

test_step_respects_log_level(custom_logger, log_capture)

Test test_step logging respects logger level

test_step_with_args(custom_logger, log_capture)

Test test_step logging with format args

class ocs_ci.framework.tests.test_custom_logger.TestThreadSafety

Bases: object

Test thread safety of logger operations

test_concurrent_logging(custom_logger, log_capture)

Test concurrent logging from multiple threads

test_step_counter_thread_safe()

Test step counter is thread-safe under concurrent access

ocs_ci.framework.tests.test_custom_logger.custom_logger(logger_name)

Create a test logger instance.

Note: Assumes custom_logger module is imported and logging.setLoggerClass() has been called during framework init.

ocs_ci.framework.tests.test_custom_logger.log_capture()

Capture log output for verification

ocs_ci.framework.tests.test_custom_logger.logger_name()

Provide unique logger name for each test

ocs_ci.framework.tests.test_custom_logger.reset_step_counts()

Reset step counters before each test

ocs_ci.framework.tests.test_main module

class ocs_ci.framework.tests.test_main.TestEntrypoint

Bases: object

reset_config()
test_config_passing(config_update, pytest_main, testdir)
test_help()
test_multi_config_passing(config_update, pytest_main, testdir)
test_multicluster_help()
test_no_args(config_update, pytest_main, testdir)

Module contents