Python · 952 bytes Raw Blame History
1 """Tests for :mod:`dlm_sway.core.sections`."""
2
3 from __future__ import annotations
4
5 from dlm_sway.core.sections import (
6 Section,
7 SectionPreference,
8 SectionProbe,
9 filter_kinds,
10 )
11
12
13 def test_default_field_types() -> None:
14 s = Section(id="abc", kind="prose", content="hello world")
15 assert s.probes == ()
16 assert s.preferences == ()
17 assert s.tag is None
18
19
20 def test_filter_kinds() -> None:
21 sections = (
22 Section(id="a", kind="prose", content="x"),
23 Section(id="b", kind="instruction", content="y"),
24 Section(id="c", kind="preference", content="z"),
25 )
26 only_prose = filter_kinds(sections, ("prose",))
27 assert len(only_prose) == 1
28 assert only_prose[0].id == "a"
29
30
31 def test_section_probe_and_preference() -> None:
32 p = SectionProbe(prompt="Q", gold="A")
33 assert p.prompt == "Q"
34 pref = SectionPreference(prompt="P", chosen="good", rejected="bad")
35 assert pref.chosen == "good"