Skip to content

Fix tests failing when installation process tests are run via cdds account - #1042

Open
Ed (mo-gill) wants to merge 4 commits into
mainfrom
1038_fix_user_tests
Open

Fix tests failing when installation process tests are run via cdds account#1042
Ed (mo-gill) wants to merge 4 commits into
mainfrom
1038_fix_user_tests

Conversation

@mo-gill

Copy link
Copy Markdown
Collaborator

Fixes #1038

@mo-gill Ed (mo-gill) self-assigned this Aug 6, 2026
@mo-gill Ed (mo-gill) changed the title Fix tests failing when installation process tests are run Fix tests failing when installation process tests are run via cdds account Aug 6, 2026
@mo-gill

Ed (mo-gill) commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

Commit f0aafc8 resolves:
tests/test_misc/test_system_information.py::test_system_information_valid - assert 1 == 0

It was caused by the discrepancy in CDDS_ENV_COMMAND in setup_env_for_devel:

# Pass a command which would set up a cdds conda environment on SPICE
export CDDS_ENV_COMMAND="source $CDDS_DIR/setup_env_for_devel"

vs the way its set in the installation process:
conda env config vars set CDDS_ENV_COMMAND="conda activate $HOME/conda_environments/cdds-X.Y.Z"

@mo-gill

Copy link
Copy Markdown
Collaborator Author

Commit 235ba3d fixes all the errors involving configparser e.g.:
configparser.InterpolationSyntaxError: '$' must be followed by '$' or '{', found: '$CDDS_DIR/cdds/cdds/tests/test_validate/data/variables_file.txt'

Turned out it was because at the point of running the tests in the installation, $CDDS_DIR isn't set. I think usually it's set in setup_env_for_devel which isn't run as part of the installation process. The addition of the setting of that variable via a pytest fixture will hopefully avoid that in future and it does fix those errors.

@mo-gill

Ed (mo-gill) commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

Commit b0ea0a0 fixed these errors caused by hardcoded paths.

FAILED checkout_for_fixing_tests/CDDS/cdds/cdds/tests/test_extract/test_validate.py::TestValidate::test_calculate_file_frequency - RuntimeError: Request config file "cdds/cdds/tests/test_extract/data/test_request_minimal.cfg" not found. Please check the command line arguments and try again.
FAILED checkout_for_fixing_tests/CDDS/cdds/cdds/tests/test_extract/test_validate.py::TestValidate::test_configure_mapping_for_each_variable - RuntimeError: Request config file "cdds/cdds/tests/test_extract/data/test_request_minimal.cfg" not found. Please check the command line arguments and try again.
FAILED checkout_for_fixing_tests/CDDS/cdds/cdds/tests/test_extract/test_validate.py::TestValidate::test_process_pp_streamtype - RuntimeError: Request config file "cdds/cdds/tests/test_extract/data/test_request_minimal.cfg" not found. Please check the command line arguments and try again.

and

FAILED checkout_for_fixing_tests/CDDS/cdds/cdds/tests/test_extract/test_validate.py::TestValidate::test_calculate_file_frequency - AttributeError: The "variable_list_file" does not exist.
FAILED checkout_for_fixing_tests/CDDS/cdds/cdds/tests/test_extract/test_validate.py::TestValidate::test_configure_mapping_for_each_variable - AttributeError: The "variable_list_file" does not exist.
FAILED checkout_for_fixing_tests/CDDS/cdds/cdds/tests/test_extract/test_validate.py::TestValidate::test_process_pp_streamtype - AttributeError: The "variable_list_file" does not exist.

@mo-gill

Copy link
Copy Markdown
Collaborator Author

Commit 39d843a fixed the hardcoded paths so that were causing these failures:

FAILED checkout_for_fixing_tests/CDDS/cdds/cdds/tests/test_misc/test_stream_mappings.py::TestStreamMappings::test_read_variables_file - FileNotFoundError: [Errno 2] No such file or directory: 'cdds/cdds/tests/test_misc/data/inputs/minimal_variables.txt'
FAILED checkout_for_fixing_tests/CDDS/cdds/cdds/tests/test_misc/test_stream_mappings.py::TestStreamMappings::test_save_mappings - FileNotFoundError: [Errno 2] No such file or directory: 'cdds/cdds/tests/test_misc/data/outputs/minimal_variables_final_output.txt'

and

checkout_for_fixing_tests/CDDS/cdds/cdds/tests/test_sim_review/test_process_critical_errors.py::TestCheckIssuesInCmor::test_check_issues_for_variable - FileNotFoundError: [Errno 2] No such file or directory: 'cdds/cdds/tests/test_deprecated/test_transfer/data/test_cmor.log.gz'
FAILED checkout_for_fixing_tests/CDDS/cdds/cdds/tests/test_sim_review/test_process_critical_errors.py::TestCheckIssuesInCmor::test_check_issues_in_cmor_axis - FileNotFoundError: [Errno 2] No such file or directory: 'cdds/cdds/tests/test_deprecated/test_transfer/data/test_cmor.log.gz'
FAILED checkout_for_fixing_tests/CDDS/cdds/cdds/tests/test_sim_review/test_process_critical_errors.py::TestCheckIssuesInCmor::test_check_issues_in_cmor_variable - FileNotFoundError: [Errno 2] No such file or directory: 'cdds/cdds/tests/test_deprecated/test_transfer/data/test_cmor.log.gz'
FAILED checkout_for_fixing_tests/CDDS/cdds/cdds/tests/test_sim_review/test_process_critical_errors.py::TestCheckIssuesInCmor::test_check_issues_in_cmor_write - FileNotFoundError: [Errno 2] No such file or directory: 'cdds/cdds/tests/test_deprecated/test_transfer/data/test_cmor.log.gz'
FAILED checkout_for_fixing_tests/CDDS/cdds/cdds/tests/test_sim_review/test_process_critical_errors.py::TestCheckIssuesInCmor::test_check_issues_in_cmor_zfactor - FileNotFoundError: [Errno 2] No such file or directory: 'cdds/cdds/tests/test_deprecated/test_transfer/data/test_cmor.log.gz'

from cdds.common.request.request import Request


@pytest.fixture(autouse=True)

@mo-gill Ed (mo-gill) Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More on autouse here, as i can't see it used elsewhere in CDDS. Seems like a handy way to ensure it's always used by tests rather than having to explicitly request it.

@mo-gill

Ed (mo-gill) commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

These tests that are supposed to be run during installation now pass:

echo "# Executing tests for cdds:"
pytest -s $SRCDIR/cdds --doctest-modules -m 'not slow and not integration and not rabbitMQ and not data_request'
pytest -s $SRCDIR/cdds -m slow
pytest -s $SRCDIR/cdds -m integration
pytest -s $SRCDIR/cdds -m data_request
echo "# Executing tests for mip_convert:"
pytest -s $SRCDIR/mip_convert --doctest-modules -m 'not slow and not mappings and not superslow'
pytest -s $SRCDIR/mip_convert -m mappings
pytest -s $SRCDIR/mip_convert -m slow

If anyone wants to test it i've left two dirs in the cdds home:

checkout_for_fixing_tests has the same changes that i applied in this branch when i was iterating. The environment that uses it is called fix_the_tests_editable

checkout_for_comparison is just a checkout of current state of main in case i needed to do a meld.

I'll clean all that out once this has been merged.

I've also run the unit tests on my own space and everything is passing there as well.

Copilot was used during development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix currently failing unit tests when using new 4.0 environment as user rather than dev

1 participant