config_parser_test.py
High-level description
This file contains unit tests for the config parsing functionality of the cassiopeia_preprocess pipeline. It tests the parsing of configuration files, the creation of pipeline stages, and the handling of various configuration scenarios.
Code Structure
The main class TestCollapseUMIs
inherits from unittest.TestCase
and contains several test methods. The setUp
method initializes test data, including different configuration scenarios. The test methods then use this data to verify the correct behavior of the config parsing and pipeline setup functions.
Symbols
TestCollapseUMIs
Description
A test class that inherits from unittest.TestCase
, containing methods to test the configuration parsing and pipeline setup for the cassiopeia_preprocess pipeline.
Internal Logic
- Sets up test data in the
setUp
method, including various configuration scenarios. - Tests the parsing of a valid configuration file.
- Tests the handling of an unspecified configuration parameter.
- Tests the correct setup of the full pipeline.
- Tests the correct setup of a subset pipeline.
TestCollapseUMIs.setUp
Description
Initializes test data for the test cases, including different configuration scenarios.
Internal Logic
- Creates a basic configuration dictionary and its string representation.
- Creates a subset configuration dictionary and its string representation.
- Creates a failure configuration dictionary and its string representation.
TestCollapseUMIs.test_read_good_config
Description
Tests the parsing of a valid configuration file.
Internal Logic
- Parses the basic configuration string.
- Checks that default parameters are set correctly.
- Verifies that specified parameters are updated correctly.
- Ensures that output directories are set for various pipeline stages.
TestCollapseUMIs.test_unspecified_config_raises_error
Description
Tests that an error is raised when an unspecified configuration parameter is encountered.
Internal Logic
- Attempts to parse the failure configuration string.
- Asserts that a
UnspecifiedConfigParameterError
is raised.
TestCollapseUMIs.test_pipeline_setup_correct
Description
Tests the correct setup of the full pipeline.
Internal Logic
- Parses the basic configuration string.
- Creates the pipeline using the entry and exit points from the configuration.
- Compares the created pipeline stages with the expected stages.
TestCollapseUMIs.test_subset_pipeline_setup_correct
Description
Tests the correct setup of a subset pipeline.
Internal Logic
- Parses the subset configuration string.
- Creates the pipeline using the entry and exit points from the configuration.
- Compares the created pipeline stages with the expected subset of stages.
Dependencies
Dependency | Purpose |
---|---|
unittest | Provides the testing framework |
pandas | Used for data manipulation (imported but not used in the test file) |
cassiopeia.preprocess.cassiopeia_preprocess | Contains the main pipeline logic |
cassiopeia.preprocess.constants | Contains constants used in the pipeline |
cassiopeia.preprocess.setup_utilities | Provides utility functions for setting up the pipeline |
Error Handling
The test cases check for proper error handling, specifically testing that a UnspecifiedConfigParameterError
is raised when an unspecified configuration parameter is encountered.
This test file ensures that the configuration parsing and pipeline setup functionality of the cassiopeia_preprocess pipeline works correctly under various scenarios, including full pipeline setup, subset pipeline setup, and handling of configuration errors.