File: test_report.py

package info (click to toggle)
dials 3.25.0%2Bdfsg3-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 20,112 kB
  • sloc: python: 134,740; cpp: 34,526; makefile: 160; sh: 142
file content (60 lines) | stat: -rw-r--r-- 1,797 bytes parent folder | download
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""Tests for dials.report"""

from __future__ import annotations

import json
import shutil
import subprocess


def test_report_integrated_data(dials_data, tmp_path):
    """Simple test to check that dials.report completes when given integrated data."""
    data_dir = dials_data("l_cysteine_dials_output", pathlib=True)
    result = subprocess.run(
        [
            shutil.which("dials.report"),
            data_dir / "20_integrated_experiments.json",
            data_dir / "20_integrated.pickle",
        ],
        cwd=tmp_path,
        capture_output=True,
    )
    assert not result.returncode and not result.stderr
    assert (tmp_path / "dials.report.html").is_file()


def test_report_scaled_data(dials_data, tmp_path):
    """Test that dials.report works on scaled data."""
    data_dir = dials_data("l_cysteine_4_sweeps_scaled", pathlib=True)
    result = subprocess.run(
        [
            shutil.which("dials.report"),
            data_dir / "scaled_30.refl",
            data_dir / "scaled_30.expt",
            f"json={tmp_path}/report.json",
        ],
        cwd=tmp_path,
        capture_output=True,
    )
    assert not result.returncode and not result.stderr
    assert (tmp_path / "dials.report.html").is_file()
    report_json = tmp_path / "report.json"
    assert report_json.is_file()
    expected_keys = {
        "strong",
        "centroid",
        "intensity",
        "reference",
        "scan_varying",
        "scaling_model",
        "resolution_graphs",
        "batch_graphs",
        "misc_graphs",
        "scaled_intensity_graphs",
        "scaling_tables",
        "xtriage_output",
        "image_range_tables",
    }
    with report_json.open(encoding="utf-8") as fh:
        d = json.load(fh)
        assert not expected_keys - set(d.keys())