File: test_phil.py

package info (click to toggle)
dials 3.12.1%2Bdfsg3-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 19,068 kB
  • sloc: python: 119,028; cpp: 33,923; makefile: 158; sh: 144
file content (41 lines) | stat: -rw-r--r-- 1,475 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from __future__ import annotations

from unittest import mock

import dials.util.phil
from dials.array_family import flex


@mock.patch("dials.util.phil.ExperimentListFactory")
def test(ExperimentListFactory, dials_data):
    # Only use these filenames for verification
    path = dials_data("centroid_test_data", pathlib=True)
    experiments_path = path / "experiments.json"
    reflections_path1 = path / "integrated.pickle"
    reflections_path2 = path / "integrated.refl"

    phil_scope = dials.util.phil.parse(
        f"""
    input {{
      reflections1 = {reflections_path1}
        .type = reflection_table
      reflections2 = {reflections_path2}
        .type = reflection_table
      experiments = {experiments_path}
        .type = experiment_list
    }}
  """
    )

    params = phil_scope.extract()

    # Check the right filenames were parsed
    assert params.input.reflections1.filename == str(reflections_path1)
    assert params.input.reflections2.filename == str(reflections_path2)
    assert params.input.experiments.filename == str(experiments_path)
    # Check that we got the expected objects back
    assert isinstance(params.input.experiments.data, mock.Mock)
    assert isinstance(params.input.reflections1.data, flex.reflection_table)
    assert isinstance(params.input.reflections2.data, flex.reflection_table)
    # Check we had the correct calls made
    assert ExperimentListFactory.from_json_file.call_args[0] == (str(experiments_path),)