diff --git a/tests/test_xfel_calibrate/test_cli.py b/tests/test_xfel_calibrate/test_cli.py index ced06f6a15cf0c12e07e9c3725be363248acd529..4ca5c9cf5693a58b48c03e8b76b94b60a4fc4d7c 100644 --- a/tests/test_xfel_calibrate/test_cli.py +++ b/tests/test_xfel_calibrate/test_cli.py @@ -1,3 +1,4 @@ +# pylint: disable=missing-class-docstring, missing-function-docstring, no-self-use """Tests for the CLI portion of `xfel_calibrate` These tests cover the CLI interface which is called by the `xfel-calibrate ...` @@ -20,6 +21,9 @@ from tests.test_xfel_calibrate.conftest import CalibrateCall, MockProposal class TestBasicCalls: + """Tests which only call the command line utility `xfel-calibrate` and check + that the expected output is present in stdout + """ @mock.patch.object(sys, "argv", ["xfel-calibrate", "--help"]) def test_help(self, capsys): with pytest.raises(SystemExit): @@ -87,6 +91,9 @@ class TestBasicCalls: class TestTutorialNotebook: + """ Checks calling `xfel-calibrate` on the `Tutorial TEST` notebook, looks + at the stdout as well as files generated by the call + """ @pytest.fixture(scope="class") def mock_proposal(self, tmpdir_factory): return MockProposal( @@ -123,15 +130,15 @@ class TestTutorialNotebook: # metadata_yml_path = list(self.tmp_path.glob("**/calibration_metadata.yml")) pass - def test_output_ipynb(self, calibrate_call: CalibrateCall): - nb_path = list(calibrate_call.tmp_path.glob("**/*/*.ipynb")) + def test_output_ipynb(self, calibrate_call: CalibrateCall, fake_process): + notebook_path = calibrate_call.paths.notebooks - assert len(nb_path) == 1 + assert len(notebook_path) == 1 - with nb_path[0].open() as f: - nb = nbformat.read(f, as_version=4) + with notebook_path[0].open() as file: + notebook = nbformat.read(file, as_version=4) - parameters = {p.name: p.value for p in extract_parameters(nb)} + parameters = {p.name: p.value for p in extract_parameters(notebook)} assert parameters["out_folder"] == str(calibrate_call.out_folder) assert parameters["sensor_size"] == [10, 30] @@ -141,14 +148,13 @@ class TestTutorialNotebook: def test_output_finalize( self, mock_proposal: MockProposal, calibrate_call: CalibrateCall ): - finalize_path = list(calibrate_call.tmp_path.glob("**/*/finalize.py"))[0] # TODO: Specify `feature_version` once we run on python 3.8+ - finalize_ast = ast.parse(finalize_path.read_text()) + finalize_ast = ast.parse(calibrate_call.paths.finalize.read_text()) finalize_kwargs = { k.arg: ast.literal_eval(k.value) for k in ast.walk(finalize_ast) - if type(k) is ast.keyword and k.arg != "finaljob" + if isinstance(k, ast.keyword) and k.arg != "finaljob" } today = date.today()