Skip to content
Snippets Groups Projects

Test/add xfel calibrate cli tests

Merged Robert Rosca requested to merge test/add-xfel-calibrate-cli-tests into master

Description

This MR adds in some basic tests for the CLI in xfel_calibrate. Done since I want to edit the CLI a bit for SQS Moonshot but the CLI is kinda spaghetti so I'm worried about breaking things and not realising it.

How Has This Been Tested?

Locally, tested by breaking code and checking that the tests fail.

Relevant Documents (optional)

Part of SQS Moonshot, see:

Types of changes

  • Test (additional or refactored tests)

Checklist:

  • My code follows the code style of this project.

Reviewers

@calibration

Edited by Robert Rosca

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Robert Rosca added 8 commits

    added 8 commits

    Compare with previous version

  • Robert Rosca added 6 commits

    added 6 commits

    • bd00649b - Add todo note for using `feature_version` kwarg
    • 96acc382 - Add todo
    • 04246249 - Add test docstring
    • eaff032c - Expand tests to cover multiple additional help
    • 6bdd86c2 - Attempt to add in tests for other notebooks
    • b7492f4a - Refactor tests

    Compare with previous version

  • Robert Rosca mentioned in commit bd00649b

    mentioned in commit bd00649b

  • Robert Rosca added 1 commit

    added 1 commit

    • c00510ff - Add sequences to agipd nb test

    Compare with previous version

  • @kluyvert I've massacred this and turned it from a relatively simple use of pytest to something a fair bit more complex, tests/test_xfel_calibrate/conftest.py now contains some fixtures to make it (I think) easier and way more flexible to set up tests calling xfel-calibrate in different ways.

    The actual implementation of the tests themselves hasn't changed, it's just nicer to set them up, e.g.:

    class TestTutorialNotebook:
        @pytest.fixture(scope="function")
        def mock_proposal(self, tmp_path):
            return MockProposal(tmp_path, runs=4)
    
        @pytest.fixture(scope="function")
        def calibrate_call(self, mock_proposal: MockProposal, capsys, tmp_path):
            return CalibrateCall(
                tmp_path,
                capsys,
                out_folder=mock_proposal.path_proc,
                detector="Tutorial",
                cal_type="TEST",
                extra_args=["--runs", "1000"],
            )

    And

    class TestIntelliList:
        @pytest.fixture(scope="function")
        def mock_proposal(self, tmp_path):
            return MockProposal(tmp_path, runs=4)
    
        @pytest.fixture(scope="function")
        def calibrate_call(self, mock_proposal: MockProposal, capsys, tmp_path):
            return CalibrateCall(
                tmp_path,
                capsys,
                out_folder=mock_proposal.path_proc,
                detector="Tutorial",
                cal_type="TEST",
                extra_args=["--random-seed", "1,2,3-10"],
            )

    And

    class TestAgipdNotebook:
        @pytest.fixture(scope="function")
        def mock_proposal(self, tmp_path):
            return MockProposal(tmp_path, runs=4)
    
        @pytest.fixture(scope="function")
        def calibrate_call(self, mock_proposal: MockProposal, capsys, tmp_path):
            return CalibrateCall(
                tmp_path,
                capsys,
                in_folder=mock_proposal.path_raw,
                out_folder=mock_proposal.path_proc,
                detector="AGIPD",
                cal_type="CORRECT",
                extra_args=["--run", "0", "--sequences", "1-3"],
            )

    With the way I did it before this kinda thing was a bit of a pain but now it's a tad smoother... I think/hope :wink:

    You free to have another look some time?

  • Robert Rosca added 2 commits

    added 2 commits

    • bf32aa65 - Improve docstrings
    • e2cdb287 - Potential fix for unicode encode error

    Compare with previous version

  • Robert Rosca added 2 commits

    added 2 commits

    Compare with previous version

  • Robert Rosca added 2 commits

    added 2 commits

    Compare with previous version

  • Robert Rosca mentioned in commit 73e9b0cb

    mentioned in commit 73e9b0cb

  • Robert Rosca mentioned in commit 83a2792c

    mentioned in commit 83a2792c

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading