Skip to content

Commit

Permalink
remove Opinions from some tests that don't need them.
Browse files Browse the repository at this point in the history
  • Loading branch information
mscarey committed Aug 2, 2021
1 parent cd1736d commit 2e810e1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 43 deletions.
4 changes: 2 additions & 2 deletions tests/io/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ def test_download_case_by_cite(self):
@pytest.mark.default_cassette("TestDownload.test_download_case_by_cite.yaml")
@pytest.mark.vcr
def test_decision_without_opinion_posits_holding(self, make_holding):
"""Test that a blank opinion is created when the decision doesn't have an opinion."""
"""Test that a blank OpinionReading is created for a decision's Holding."""
decision = self.client.read_cite("49 F.3d 807")
reading = DecisionReading(decision=decision)
reading.posit(make_holding["h2"])
assert len(reading.holdings) == 1
assert reading.casebody.status != "ok"
assert len(reading.opinion_readings[0].holdings) == 1

@pytest.mark.default_cassette("TestDownload.test_full_case_download.yaml")
@pytest.mark.vcr
Expand Down
54 changes: 18 additions & 36 deletions tests/io/test_holding.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,16 @@ def test_read_holdings_and_then_get_anchors(self, make_response):
assert isinstance(holdings[0], Holding)
assert isinstance(named_anchors.popitem()[1].pop(), TextQuoteSelector)

def test_load_and_posit_holdings_with_anchors(self, make_opinion, make_response):
def test_load_and_posit_holdings_with_anchors(self, make_response):
"""
Test that Opinion.posit can take a HoldingsIndexed as the only argument.
Trying to combine several tasks that normally happen together, into a single command.
"""
mock_client = FakeClient(responses=make_response)
oracle = make_opinion["oracle_majority"]
oracle_holdings_with_anchors = loaders.read_anchored_holdings_from_file(
"holding_oracle.json", client=mock_client
)
reading = OpinionReading(opinion=oracle)
reading = OpinionReading()
reading.posit(oracle_holdings_with_anchors)
assert len(reading.holdings) == 20

Expand All @@ -248,10 +247,9 @@ def test_pass_holdings_to_decision_reading_constructor(
class TestTextAnchors:
client = Client(api_token=TOKEN)

def test_read_holding_with_no_anchor(self, make_opinion, make_analysis):
oracle = make_opinion["oracle_majority"]
def test_read_holding_with_no_anchor(self, make_analysis):
raw_analysis = make_analysis["no anchors"]
reading = OpinionReading(opinion=oracle)
reading = OpinionReading()
(
oracle_holdings,
holding_anchors,
Expand All @@ -272,13 +270,10 @@ def test_holding_without_enactments_or_regime(self, raw_holding):
new_factor = built.outputs[0].to_effect.terms[0]
assert new_factor.name == "Bradley"

def test_posit_one_holding_with_anchor(
self, make_opinion, raw_holding, make_response
):
def test_posit_one_holding_with_anchor(self, raw_holding, make_response):
mock_client = FakeClient(responses=make_response)
holding = readers.read_holding(raw_holding["bradley_house"], client=mock_client)
cardenas = make_opinion["cardenas_majority"]
reading = OpinionReading(opinion=cardenas)
reading = OpinionReading()
reading.posit_holding(
holding,
holding_anchors=TextQuoteSelector(
Expand Down Expand Up @@ -503,28 +498,24 @@ def test_fact_with_quantity(self, make_response):
new_fact = holdings[1].inputs[3]
assert "was no more than 35 foot" in str(new_fact)

def test_use_int_not_pint_without_dimension(self, make_opinion, make_response):
def test_use_int_not_pint_without_dimension(self, make_response):
mock_client = FakeClient(responses=make_response)
brad = make_opinion["brad_majority"]
to_read = load_holdings("holding_brad.json")
holdings = readers.read_holdings(to_read, client=mock_client)
reading = OpinionReading(opinion=brad, holdings=holdings)
reading = OpinionReading(holdings=holdings)
expectation_not_reasonable = list(reading.holdings)[6]
assert "dimensionless" not in str(expectation_not_reasonable)
assert isinstance(expectation_not_reasonable.inputs[0].predicate.quantity, int)

def test_opinion_posits_holding(self, make_opinion, make_response):
def test_opinion_posits_holding(self, make_response):
mock_client = FakeClient(responses=make_response)
brad = make_opinion["brad_majority"]
to_read = load_holdings("holding_brad.json")
holdings = readers.read_holdings(to_read, client=mock_client)
reading = OpinionReading(opinion=brad)
reading = OpinionReading()
reading.posit(holdings[0])
assert "warrantless search and seizure" in reading.holdings[0].short_string

def test_opinion_posits_holding_tuple_context(
self, make_opinion, make_entity, make_response
):
def test_opinion_posits_holding_tuple_context(self, make_entity, make_response):
"""
Having the Watt case posit a holding from the Brad
case, but with generic factors from Watt.
Expand All @@ -535,29 +526,24 @@ def test_opinion_posits_holding_tuple_context(
context_holding = brad_holdings[6].new_context(
[make_entity["watt"], make_entity["trees"], make_entity["motel"]]
)
watt = make_opinion["watt_majority"]
reading = OpinionReading(opinion=watt)
reading = OpinionReading()
reading.posit(context_holding)
holding_string = reading.holdings[-1].short_string
assert (
"the number of marijuana plants in <the stockpile of trees> was at least 3"
in holding_string
)

def test_opinion_posits_holding_dict_context(
self, make_opinion, make_entity, make_response
):
def test_opinion_posits_holding_dict_context(self, make_entity, make_response):
"""
Having the Watt case posit a holding from the Brad
case, but replacing one generic factor with a factor
from Watt.
"""
mock_client = FakeClient(responses=make_response)
watt = make_opinion["watt_majority"]
brad = make_opinion["brad_majority"]
to_read = load_holdings("holding_brad.json")
holdings = readers.read_holdings(to_read, client=mock_client)
breading = OpinionReading(opinion=brad)
breading = OpinionReading()
breading.clear_holdings()
breading.posit(holdings)
expectation_not_reasonable = breading.holdings[6]
Expand All @@ -567,22 +553,19 @@ def test_opinion_posits_holding_dict_context(
value=make_entity["watt"],
)
context_holding = expectation_not_reasonable.new_context(changes)
wreading = OpinionReading(opinion=watt)
wreading = OpinionReading()
wreading.clear_holdings()
wreading.posit(context_holding)
string = str(context_holding)
assert "<Wattenburg> lived at <Bradley's house>" in string
assert "<Wattenburg> lived at <Bradley's house>" in str(wreading.holdings[-1])

def test_holding_with_non_generic_value(
self, make_opinion, make_entity, make_response
):
def test_holding_with_non_generic_value(self, make_entity, make_response):
"""
This test originally required a ValueError, but why should it?
"""
mock_client = FakeClient(responses=make_response)
brad = make_opinion["brad_majority"]
reading = OpinionReading(opinion=brad)
reading = OpinionReading()
to_read = load_holdings("holding_brad.json")
holdings = readers.read_holdings(to_read, client=mock_client)
reading.posit(holdings)
Expand Down Expand Up @@ -635,8 +618,7 @@ def test_posit_holding_with_selector(self, make_analysis, make_opinion):
) = readers.read_holdings_with_anchors(make_analysis["minimal"])

brad = make_opinion["brad_majority"]
reading = OpinionReading(opinion=brad)
reading.clear_holdings()
reading = OpinionReading(opinion_type="majority", opinion_author=brad.author)
reading.posit(holdings, holding_anchors=holding_anchors)
assert reading.holdings[0].anchors[0].exact == "open fields or grounds"

Expand Down
6 changes: 2 additions & 4 deletions tests/io/test_opinion.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ def test_load_opinion(self):
assert opinion.type == "concurring-in-part-and-dissenting-in-part"

def test_empty_holding_list_when_loading_opinion(self):
opinion = Opinion(type="majority")
reading = OpinionReading(opinion=opinion, holdings=[])
reading = OpinionReading(opinion_type="majority", holdings=[])
assert isinstance(reading.holdings, HoldingGroup)

def test_loading_opinion_with_one_holding_in_list(self, make_holding):
opinion = Opinion(type="majority")
reading = OpinionReading(opinion=opinion, holdings=[make_holding["h1"]])
reading = OpinionReading(holdings=[make_holding["h1"]])
assert isinstance(reading.holdings, HoldingGroup)
assert len(reading.holdings) == 1

Expand Down
2 changes: 1 addition & 1 deletion tests/test_holdings.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def test_holding_implies_opinion_with_no_holdings(
self, make_opinion_with_holding, make_opinion
):
lotus = make_opinion["lotus_majority"]
reading = OpinionReading(opinion=lotus)
reading = OpinionReading()
holding = make_opinion_with_holding["oracle_majority"].holdings[0]
context = ContextRegister()
context.insert_pair(
Expand Down

0 comments on commit 2e810e1

Please sign in to comment.