-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_evidence.py
170 lines (139 loc) · 6.37 KB
/
test_evidence.py
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
from nettlesome.terms import TermSequence
from authorityspoke.facts import Fact, build_fact, Evidence, Exhibit
from authorityspoke import Entity
class TestEvidence:
def test_make_evidence_object(self, watt_factor):
e = Evidence(
exhibit=Exhibit(offered_by=Entity(name="Al"), form="testimony"),
to_effect=watt_factor["f2"],
)
assert not e.absent
def test_default_len_based_on_unique_entity_slots(self, make_entity, make_factor):
"""same as e["no_shooting"]"""
e = Evidence(
exhibit=Exhibit(
form="testimony",
offered_by=Entity(name="Al"),
statement=make_factor["f_no_shooting"],
statement_attribution=make_entity["alice"],
),
to_effect=make_factor["f_no_crime"],
)
assert not e.generic
def test_no_extra_space_around_exhibit_in_string(self, make_opinion_with_holding):
"""
Don't expect the holdings imported from the JSON to
exactly match the holdings created for testing in conftest.
"""
lotus = make_opinion_with_holding["lotus_majority"]
holding = list(lotus.holdings)[4]
assert " , " not in str(holding.inputs[0])
def test_no_caps_in_short_string(self, make_opinion_with_holding):
"""
Class names should not be capitalized in this format.
"""
lotus = make_opinion_with_holding["lotus_majority"]
evidence = list(lotus.holdings)[4].inputs[0]
assert "Fact" not in evidence.short_string
assert "fact" in evidence.short_string
def test_get_entity_orders(self, make_evidence):
context = make_evidence["no_shooting"].exhibit.statement.terms
assert "Alice" in str(context[0])
assert "Bob" in str(context[1])
def test_get_entity_orders_no_statement(self, make_factor):
e = Evidence(
exhibit=Exhibit(form="testimony", offered_by=Entity(name="Al")),
to_effect=make_factor["f_no_crime"],
)
assert len(e.to_effect.terms) == 1
def test_evidence_str_with_context(self, make_evidence):
assert (
"in the form testimony"
in make_evidence["reciprocal"].wrapped_string.lower()
)
def test_type_of_terms(self, make_evidence):
assert isinstance(make_evidence["no_shooting"].term_sequence, TermSequence)
class TestEvidenceSameMeaning:
def test_equality_with_entity_order(self, make_evidence):
e = make_evidence
assert e["no_shooting"].means(e["no_shooting_entity_order"])
def test_equality_with_no_statement(self, make_evidence):
assert make_evidence["crime"].means(make_evidence["crime"])
def test_unequal_due_to_entity_order(self, make_evidence):
e = make_evidence
assert not e["no_shooting"].means(e["no_shooting_different_witness"])
def test_implies_due_to_more_complex_entity_order(self, make_exhibit):
"""Test the entire _registers_for_interchangeable_context function."""
hit = Fact(
predicate="$person1 hit $target1 and $target2",
terms=[Entity(name="Moe"), Entity(name="Curly"), Entity(name="Larry")],
)
hit2 = Fact(
predicate="$person1 hit $target1 and $target2",
terms=[
Entity(name="Joker"),
Entity(name="Batman"),
Entity(name="Superman"),
],
)
exhibit = Exhibit(
form="testimony",
offered_by=Entity(name="Curly"),
statement=hit,
statement_attribution=Entity(name="Larry"),
)
exhibit2 = Exhibit(
form="testimony",
offered_by=Entity(name="Joker"),
statement=hit2,
statement_attribution=Entity(name="Batman"),
)
assert exhibit.implies(exhibit2)
def test_unequal_different_attributes(self, make_evidence):
assert not (
make_evidence["no_shooting_no_effect_entity_order"].means(
make_evidence["no_shooting_different_witness"]
)
)
def test_not_equal_no_effect(self, make_evidence):
assert not make_evidence["shooting_no_effect"].means(make_evidence["shooting"])
assert not make_evidence["shooting"].means(make_evidence["shooting_no_effect"])
class TestEvidenceImplication:
def test_implication_missing_witness(self, make_evidence):
e = make_evidence
assert e["no_shooting"] >= e["no_shooting_witness_unknown"]
def test_implication_missing_effect(self, make_evidence):
e = make_evidence
assert e["no_shooting"] >= e["no_shooting_no_effect_entity_order"]
def test_no_implication_of_fact(
self, make_predicate, make_evidence, watt_mentioned
):
cool_fact = build_fact(
make_predicate["p_no_shooting"], case_factors=watt_mentioned
)
assert not make_evidence["no_shooting"] > cool_fact
assert not cool_fact > make_evidence["no_shooting"]
class TestEvidenceContradiction:
def test_no_contradiction_of_fact(self, make_evidence, make_factor):
assert not make_evidence["no_shooting"].contradicts(
make_factor["f_no_shooting"]
)
def test_no_contradiction_from_supporting_contradictory_facts(self, make_evidence):
assert not make_evidence["no_shooting"].contradicts(make_evidence["shooting"])
def test_contradiction_of_absent_version_of_self(self, make_evidence):
e = make_evidence
assert e["no_shooting"].contradicts(e["no_shooting_absent"])
def test_contradict_absent_version_of_implied_factor(self, make_evidence):
e = make_evidence
assert e["no_shooting_witness_unknown_absent"].contradicts(e["no_shooting"])
assert e["no_shooting"].contradicts(e["no_shooting_witness_unknown_absent"])
def test_no_contradiction_absent_same_witness(self, make_evidence):
e = make_evidence
assert not e["no_shooting_absent"].contradicts(e["no_shooting_witness_unknown"])
assert not e["no_shooting_witness_unknown"].contradicts(e["no_shooting_absent"])
assert not e["no_shooting_absent"].contradicts(
e["no_shooting_different_witness"]
)
def test_no_contradiction_of_implied_factor(self, make_evidence):
e = make_evidence
assert not e["no_shooting"].contradicts(e["no_shooting_witness_unknown"])