Ejemplo n.º 1
0
 def test_add_opinion_to_decision(self, make_decision, make_opinion,
                                  make_opinion_with_holding):
     reading = DecisionReading(decision=Decision(
         decision_date=date(2000, 2, 2)))
     assert len(reading.opinions) == 0
     reading.add_opinion(make_opinion["oracle_majority"])
     assert len(reading.opinions) == 1
Ejemplo n.º 2
0
 def test_decision_posits_holdings_with_anchors(self, make_response):
     mock_client = FakeClient(responses=make_response)
     oracle_holdings_with_anchors = loaders.read_anchored_holdings_from_file(
         "holding_oracle.yaml", client=mock_client)
     reading = DecisionReading(decision=Decision(
         decision_date=date(2019, 1, 1)))
     reading.posit(oracle_holdings_with_anchors)
     assert len(reading.holdings) == 20
Ejemplo n.º 3
0
 def test_decision_reading_has_opinion_readings(self, make_decision,
                                                make_holding):
     watt = make_decision["watt"]
     reading = DecisionReading(decision=watt)
     reading.posit(make_holding["h1"])
     hamley = "hamley, circuit judge"
     assert reading.opinion_readings[0].opinion_author.lower() == hamley
     assert reading.opinion_readings[0].holdings[0].means(
         make_holding["h1"])
Ejemplo n.º 4
0
 def test_decision_posits_holding(self, fake_usc_client, make_decision):
     lotus_analysis = read_anchored_holdings_from_file(
         "holding_lotus.yaml", client=fake_usc_client)
     lotus_reading = DecisionReading(decision=make_decision["lotus"])
     lotus_reading.posit(lotus_analysis)
     assert len(lotus_reading.majority.holdings) == len(
         lotus_analysis.holdings)
     assert str(lotus_reading).startswith(
         "Reading for Lotus Development Corp.")
Ejemplo n.º 5
0
 def test_implication_of_decision_with_one_of_same_holdings(
         self, make_decision, make_decision_with_holding):
     decision = make_decision["oracle"]
     oracle = DecisionReading(decision=decision)
     oracle_with_holdings = make_decision_with_holding["oracle"]
     oracle.posit(oracle_with_holdings.holdings[0])
     assert len(oracle.holdings) == 1
     assert len(oracle_with_holdings.holdings) > 10
     assert oracle_with_holdings >= oracle
Ejemplo n.º 6
0
 def test_add_opinion_with_holdings(self, make_decision, make_opinion,
                                    make_opinion_with_holding):
     reading = DecisionReading(decision=make_decision["oracle"])
     assert len(reading.opinion_readings) == 0
     assert len(reading.holdings) == 0
     reading.add_opinion_reading(
         make_opinion_with_holding["oracle_majority"])
     assert len(reading.opinion_readings) == 1
     assert len(reading.holdings) == 20
Ejemplo n.º 7
0
 def test_passage_from_imported_statute(self, fake_usc_client):
     oracle = loaders.load_decision("oracle_h.json")
     oracle_decision = Decision(**oracle)
     reading = DecisionReading(decision=oracle_decision)
     loaded = loaders.load_holdings("holding_oracle.yaml")
     holdings = readers.read_holdings(loaded, client=fake_usc_client)
     reading.posit(holdings)
     despite_text = str(list(reading.holdings)[5])
     assert "In no case does copyright protection " in despite_text
Ejemplo n.º 8
0
    def test_posit_holdings(self, make_decision, make_holding):
        """
        "Positing" Holdings causes the Holdings to be assigned to the Decision's
        majority Opinion.
        """

        watt = make_decision["watt"]
        reading = DecisionReading(decision=watt)
        reading.posit([make_holding["h1"], make_holding["h2"]])
        assert reading.majority.holdings[-1] == make_holding["h2"]
Ejemplo n.º 9
0
 def test_decision_with_opinion_reading_posits_holding(
         self, fake_usc_client):
     lotus_analysis = read_anchored_holdings_from_file(
         "holding_lotus.yaml", client=fake_usc_client)
     decision_reading = DecisionReading(
         decision=Decision(decision_date=date(2000, 2, 2)),
         opinion_readings=[OpinionReading(opinion_type="plurality")],
     )
     decision_reading.posit(lotus_analysis)
     assert len(decision_reading.holdings) == len(lotus_analysis.holdings)
Ejemplo n.º 10
0
 def test_pass_holdings_to_decision_reading_constructor(
         self, make_decision, make_response):
     mock_client = FakeClient(responses=make_response)
     oracle = make_decision["oracle"]
     oracle_holdings = read_holdings_from_file("holding_oracle.yaml",
                                               client=mock_client)
     oracle_reading = DecisionReading(decision=oracle)
     oracle_reading.posit(oracle_holdings)
     assert (oracle_reading.opinion_readings[0].holdings[0].enactments[0].
             node == "/us/usc/t17/s102/a")
Ejemplo n.º 11
0
    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)
Ejemplo n.º 12
0
 def test_error_decision_with_no_majority_posits_holding(
         self, fake_usc_client):
     lotus_analysis = read_anchored_holdings_from_file(
         "holding_lotus.yaml", client=fake_usc_client)
     reading1 = OpinionReading(opinion_type="plurality")
     reading2 = OpinionReading(opinion_type="concurring")
     decision_reading = DecisionReading(
         decision=Decision(decision_date=date(2000, 2, 2)),
         opinion_readings=[reading1, reading2],
     )
     with pytest.raises(AttributeError):
         decision_reading.posit(lotus_analysis)
Ejemplo n.º 13
0
 def test_make_reading_with_anchored_holdings(self, make_decision,
                                              make_anchored_holding):
     watt = make_decision["watt"]
     holding = make_anchored_holding["lotus"]
     reading = DecisionReading(decision=watt)
     reading.posit(holding)
     assert (
         str(reading.majority.holdings[0].inputs[0]).lower() ==
         "the fact that <the lotus menu command hierarchy> was copyrightable"
     )
     assert reading.majority.opinion_author.startswith("HAMLEY")
     assert reading.decision.opinions[0].author.startswith("HAMLEY")
Ejemplo n.º 14
0
 def test_decision_implies_decision_without_holdings(
         self, make_decision_with_holding, make_decision):
     oracle = make_decision_with_holding["oracle"]
     blank = make_decision["lotus"]
     blank_reading = DecisionReading(decision=blank)
     explanation = oracle.explain_implication(blank_reading)
     assert not explanation.reasons
Ejemplo n.º 15
0
 def test_no_contradiction_of_majority_without_holdings(
         self, make_decision_with_holding):
     oracle = make_decision_with_holding["oracle"]
     other = Decision(decision_date=datetime.date(2020, 1, 1))
     other.opinions.append(Opinion(position="majority"))
     reading = DecisionReading(decision=other)
     assert not oracle.contradicts(reading)
Ejemplo n.º 16
0
 def test_no_contradiction_with_plurality(self, make_decision_with_holding):
     oracle = make_decision_with_holding["oracle"]
     other = Decision(
         decision_date=datetime.date(2020, 1, 1),
         opinions=[Opinion(position="plurality")],
     )
     reading = DecisionReading(decision=other)
     assert not oracle.contradicts(reading)
Ejemplo n.º 17
0
def read_decision(decision: Union[RawDecision, Decision]) -> DecisionReading:
    r"""
    Create and return a :class:`~authorityspoke.decisions.Decision` from a dict API response.

    Relies on the JSON format from the `Caselaw Access Project
    API <https://api.case.law/v1/cases/>`_.

    :param decision_dict:
        A dict created from a Caselaw Access Project API response.
    """
    if not isinstance(decision, Decision):
        decision = Decision(**decision)
    return DecisionReading(decision=decision)
Ejemplo n.º 18
0
 def test_decision_no_opinions(self):
     decision = Decision(decision_date=date(2000, 2, 2))
     reading = DecisionReading(decision=decision)
     assert reading.majority is None
     assert not reading.implied_by(None)
Ejemplo n.º 19
0
 def test_decision_implied_by_holding(self, make_decision, make_holding):
     decision = make_decision["watt"]
     reading = DecisionReading(decision=decision)
     holding = make_holding["h1"]
     reading.posit(holding)
     assert reading.implied_by(holding)
Ejemplo n.º 20
0
 def test_make_reading_with_holdings(self, make_decision, make_holding):
     watt = make_decision["watt"]
     holdings = HoldingGroup([make_holding["h1"], make_holding["h2"]])
     reading = DecisionReading(decision=watt)
     reading.posit(holdings)
     assert reading.majority.holdings[-1] == make_holding["h2"]
Ejemplo n.º 21
0
 def test_no_holdings_of_blank_decision(self):
     blank = Decision(decision_date=datetime.date(2000, 1, 2))
     reading = DecisionReading(decision=blank)
     assert len(reading.holdings) == 0
Ejemplo n.º 22
0
 def test_decision_reading_with_opinion_instead_of_decision(
         self, make_opinion):
     with pytest.raises(ValidationError):
         DecisionReading(decision=make_opinion["lotus_majority"])