示例#1
0
 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)
     to_read = load_holdings("holding_brad.yaml")
     holdings = readers.read_holdings(to_read, client=mock_client)
     breading = OpinionReading()
     breading.clear_holdings()
     breading.posit(holdings)
     expectation_not_reasonable = breading.holdings[6]
     changes = ContextRegister()
     changes.insert_pair(
         key=expectation_not_reasonable.generic_terms()[0],
         value=make_entity["watt"],
     )
     context_holding = expectation_not_reasonable.new_context(changes)
     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])
示例#2
0
 def test_opinion_posits_holding(self, make_response):
     mock_client = FakeClient(responses=make_response)
     to_read = load_holdings("holding_brad.yaml")
     holdings = readers.read_holdings(to_read, client=mock_client)
     reading = OpinionReading()
     reading.posit(holdings[0])
     assert "warrantless search and seizure" in reading.holdings[
         0].short_string
示例#3
0
    def test_posit_holding_with_selector(self, make_analysis, make_opinion):

        anchored_holdings = readers.read_holdings_with_anchors(
            make_analysis["minimal"])

        brad = make_opinion["brad_majority"]
        reading = OpinionReading(opinion_type="majority",
                                 opinion_author=brad.author)
        reading.posit(anchored_holdings.holdings)
        assert reading.holding_anchors[0].quotes[
            0].exact == "open fields or grounds"
示例#4
0
 def test_read_holding_with_no_anchor(self, make_analysis):
     raw_analysis = make_analysis["no anchors"]
     reading = OpinionReading()
     anchored_holdings = readers.read_holdings_with_anchors(raw_analysis)
     reading.posit(
         holdings=anchored_holdings.holdings,
         named_anchors=anchored_holdings.named_anchors,
         enactment_anchors=anchored_holdings.enactment_anchors,
     )
     assert not reading.holding_anchors[0].positions
     assert not reading.holding_anchors[0].quotes
示例#5
0
 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_holdings_with_anchors = loaders.read_anchored_holdings_from_file(
         "holding_oracle.yaml", client=mock_client)
     reading = OpinionReading()
     reading.posit(oracle_holdings_with_anchors)
     assert len(reading.holdings) == 20
示例#6
0
    def test_opinion_contradicts_opinion(self, make_opinion_with_holding):
        """Return the only contradictory pair of Holdings between these two Opinions."""
        oracle = make_opinion_with_holding["oracle_majority"]
        lotus = make_opinion_with_holding["lotus_majority"]

        left = OpinionReading(opinion_type="majority",
                              opinion_author=oracle.opinion_author)
        left.posit(lotus.holdings[6])
        right = OpinionReading(opinion_type="majority",
                               opinion_author=lotus.opinion_author)
        right.posit(oracle.holdings[10])
        explanation = left.explain_contradiction(right)
        assert len(explanation.reasons) == 1
        assert isinstance(explanation.reasons[0].left, Holding)
        assert isinstance(explanation.reasons[0].right, Holding)
示例#7
0
 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)
     reading = OpinionReading()
     to_read = load_holdings("holding_brad.yaml")
     holdings = readers.read_holdings(to_read, client=mock_client)
     reading.posit(holdings)
     expectation_not_reasonable = reading.holdings[6]
     generic_patch = expectation_not_reasonable.generic_terms()[1]
     changes = ContextRegister()
     changes.insert_pair(generic_patch, make_entity["trees_specific"])
     context_change = expectation_not_reasonable.new_context(changes)
     string = context_change.short_string
     assert "plants in the stockpile of trees was at least 3" in string
示例#8
0
 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.
     """
     mock_client = FakeClient(responses=make_response)
     to_read = load_holdings("holding_brad.yaml")
     brad_holdings = readers.read_holdings(to_read, client=mock_client)
     context_holding = brad_holdings[6].new_context(
         [make_entity["watt"], make_entity["trees"], make_entity["motel"]])
     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)
示例#9
0
 def test_opinion_entity_list(self, make_opinion, real_holding, make_entity,
                              make_evidence):
     watt = make_opinion["watt_majority"]
     h = real_holding
     e = make_entity
     reading = OpinionReading(opinion_type=watt.type,
                              opinion_author=watt.author)
     reading.posit(h["h1"], context=(e["motel"], e["watt"]))
     reading.posit(h["h2"], context=(e["trees"], e["motel"]))
     reading.posit(
         h["h3"],
         context=(
             make_evidence["generic"],
             e["motel"],
             e["watt"],
             e["trees"],
             e["tree_search"],
         ),
     )
     reading.posit(h["h4"],
                   context=(e["trees"], e["tree_search"], e["motel"],
                            e["watt"]))
     assert make_entity["watt"] in reading.generic_terms()
示例#10
0
 def test_opinion_implied_by_decision(self, make_holding,
                                      make_decision_with_holding):
     watt = make_decision_with_holding["watt"]
     reading = OpinionReading()
     reading.posit(watt.holdings[0])
     assert reading.implied_by(watt)