Skip to content

Commit fd01472

Browse files
committed
added orso_utils tests
1 parent c6c47bc commit fd01472

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

tests/test_orso_utils.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright (c) 2025 DMSC
3+
4+
import pytest
5+
from orsopy.fileio import orso
6+
7+
from easyreflectometry.orso_utils import (
8+
LoadOrso,
9+
load_data_from_orso_file,
10+
load_orso_data,
11+
load_orso_model,
12+
)
13+
14+
15+
@pytest.fixture
16+
def orso_data():
17+
"""Load the test ORSO data from Ni_example.ort."""
18+
return orso.load_orso("Ni_example.ort")
19+
20+
21+
def test_load_orso_model(orso_data):
22+
"""Test loading a model from ORSO data."""
23+
sample = load_orso_model(orso_data)
24+
assert sample is not None
25+
assert sample.name == "Ni on Si" # Based on the file
26+
27+
28+
def test_load_orso_data(orso_data):
29+
"""Test loading data from ORSO data."""
30+
data = load_orso_data(orso_data)
31+
assert data is not None
32+
# Check structure, e.g., has R_0 in data
33+
assert "R_0" in data["data"]
34+
35+
36+
def test_LoadOrso(orso_data):
37+
"""Test the LoadOrso function."""
38+
sample, data = LoadOrso(orso_data)
39+
assert sample is not None
40+
assert data is not None
41+
# Similar checks as above
42+
43+
44+
def test_load_data_from_orso_file():
45+
"""Test loading data from ORSO file."""
46+
data = load_data_from_orso_file("Ni_example.ort")
47+
assert data is not None
48+
# Check it's a sc.DataGroup
49+
import scipp as sc
50+
assert isinstance(data, sc.DataGroup)

0 commit comments

Comments
 (0)