Repository navigation
Expand file tree
/
Copy pathtest_utils.py
More file actions
67 lines (40 loc) · 1.77 KB
/
Copy pathtest_utils.py
File metadata and controls
67 lines (40 loc) · 1.77 KB
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
61
62
63
64
65
66
67
from unittest.mock import MagicMock, patch
from bluesky.protocols import Readable
from ophyd import EpicsMotor
from dodal.utils import collect_factories, get_hostname, make_all_devices
def test_finds_device_factories() -> None:
import tests.fake_beamline as fake_beamline
factories = collect_factories(fake_beamline)
from tests.fake_beamline import device_a, device_b, device_c
assert {
"device_a": device_a,
"device_b": device_b,
"device_c": device_c,
} == factories
def test_makes_devices() -> None:
import tests.fake_beamline as fake_beamline
devices = make_all_devices(fake_beamline)
assert {"readable", "motor", "cryo"} == devices.keys()
def test_makes_devices_with_dependencies() -> None:
import tests.fake_beamline_dependencies as fake_beamline
devices = make_all_devices(fake_beamline)
assert {"readable", "motor", "cryo"} == devices.keys()
def test_makes_devices_with_disordered_dependencies() -> None:
import tests.fake_beamline_disordered_dependencies as fake_beamline
devices = make_all_devices(fake_beamline)
assert {"readable", "motor", "cryo"} == devices.keys()
def test_makes_devices_with_module_name() -> None:
devices = make_all_devices("tests.fake_beamline")
assert {"readable", "motor", "cryo"} == devices.keys()
def test_get_hostname() -> None:
with patch("dodal.utils.socket.gethostname") as mock:
mock.return_value = "a.b.c"
assert get_hostname() == "a"
def test_no_signature_builtins_not_devices() -> None:
import tests.fake_beamline_misbehaving_builtins as fake_beamline
devices = make_all_devices(fake_beamline)
assert not devices
def device_a() -> Readable:
return MagicMock()
def device_b() -> EpicsMotor:
return MagicMock()