-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_readme.py
75 lines (57 loc) · 2.66 KB
/
test_readme.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
"""Tests for any commands in readme.md."""
from authorityspoke.decisions import DecisionReading
import os
from dotenv import load_dotenv
load_dotenv()
from authorityspoke import CAPClient, Decision, LegisClient
from authorityspoke.io.fake_enactments import FakeClient
from authorityspoke.io.loaders import (
load_decision,
read_holdings_from_file,
read_anchored_holdings_from_file,
)
from authorityspoke.io.loaders import read_holdings_from_file
class TestReadme:
def test_posit_anchored_holdings(self, make_response):
client = FakeClient(responses=make_response)
oracle_dict = load_decision("oracle_h.json")
lotus_dict = load_decision("lotus_h.json")
oracle = Decision(**oracle_dict)
lotus = Decision(**lotus_dict)
oracle_ah = read_anchored_holdings_from_file(
"holding_oracle.yaml", client=client
)
lotus_ah = read_anchored_holdings_from_file("holding_lotus.yaml", client=client)
oracle_reading = DecisionReading(decision=oracle)
lotus_reading = DecisionReading(decision=lotus)
oracle_reading.posit(
holdings=oracle_ah.holdings,
named_anchors=oracle_ah.named_anchors,
enactment_anchors=oracle_ah.enactment_anchors,
)
lotus_reading.posit(
holdings=lotus_ah.holdings,
named_anchors=lotus_ah.named_anchors,
enactment_anchors=lotus_ah.enactment_anchors,
)
assert lotus_reading.contradicts(oracle_reading)
def test_posit_holdings(self, make_response):
client = FakeClient(responses=make_response)
oracle_dict = load_decision("oracle_h.json")
lotus_dict = load_decision("lotus_h.json")
oracle = Decision(**oracle_dict)
lotus = Decision(**lotus_dict)
oracle_h = read_holdings_from_file("holding_oracle.yaml", client=client)
lotus_h = read_holdings_from_file("holding_lotus.yaml", client=client)
oracle_reading = DecisionReading(decision=oracle)
lotus_reading = DecisionReading(decision=lotus)
oracle_reading.posit(holdings=oracle_h)
lotus_reading.posit(holdings=lotus_h)
assert lotus_reading.contradicts(oracle_reading)
def test_explain_contradiction(self, make_decision_with_holding):
lotus = make_decision_with_holding["lotus"]
oracle = make_decision_with_holding["oracle"]
explanation = str(lotus.explain_contradiction(oracle))
lotus_like = "<the Lotus menu command hierarchy> is like <the Java API>"
java_like = "<the Java API> is like <the Lotus menu command hierarchy>"
assert lotus_like in explanation or java_like in explanation