Skip to content

Commit

Permalink
change Client to FakeClient in two tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mscarey committed Mar 8, 2021
1 parent b65ab4f commit 764c80e
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 80 deletions.
10 changes: 5 additions & 5 deletions docs/api/factors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Facts
==============

.. inheritance-diagram:: authorityspoke.facts.Fact
:top-classes: authorityspoke.comparisons.Comparable
:top-classes: nettlesome.quantities.Comparable
:parts: 1

.. autoclass:: authorityspoke.facts.Fact
Expand All @@ -15,7 +15,7 @@ Exhibits
==============

.. inheritance-diagram:: authorityspoke.evidence.Exhibit
:top-classes: authorityspoke.comparisons.Comparable
:top-classes: nettlesome.quantities.Comparable
:parts: 1

.. autoclass:: authorityspoke.evidence.Exhibit
Expand All @@ -24,7 +24,7 @@ Evidence
==============

.. inheritance-diagram:: authorityspoke.evidence.Evidence
:top-classes: authorityspoke.comparisons.Comparable
:top-classes: nettlesome.quantities.Comparable
:parts: 1

.. autoclass:: authorityspoke.evidence.Evidence
Expand All @@ -33,7 +33,7 @@ Pleadings
==============

.. inheritance-diagram:: authorityspoke.pleadings.Pleading
:top-classes: authorityspoke.comparisons.Comparable
:top-classes: nettlesome.quantities.Comparable
:parts: 1

.. autoclass:: authorityspoke.pleadings.Pleading
Expand All @@ -42,7 +42,7 @@ Allegations
================

.. inheritance-diagram:: authorityspoke.pleadings.Allegation
:top-classes: authorityspoke.comparisons.Comparable
:top-classes: nettlesome.quantities.Comparable
:parts: 1

.. autoclass:: authorityspoke.pleadings.Allegation
2 changes: 1 addition & 1 deletion docs/api/procedures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Procedures
==============

.. inheritance-diagram:: authorityspoke.procedures.Procedure
:top-classes: authorityspoke.comparisons.Comparable
:top-classes: nettlesome.quantities.Comparable
:parts: 1

.. autoclass:: authorityspoke.procedures.Procedure
Expand Down
2 changes: 1 addition & 1 deletion docs/api/rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Rules
==============

.. inheritance-diagram:: authorityspoke.rules.Rule
:top-classes: authorityspoke.comparisons.Comparable
:top-classes: nettlesome.quantities.Comparable
:parts: 1

.. autoclass:: authorityspoke.rules.Rule
Expand Down
60 changes: 23 additions & 37 deletions docs/guides/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -318,45 +318,31 @@ using the :mod:`~authorityspoke.io.dump` module.

>>> from authorityspoke.io.dump import to_json, to_dict
>>> to_dict(oracle_holdings[0])["rule"]["procedure"]
{'inputs': [{'predicate': {'sign': '',
'content': '{} was an original work',
'quantity': None,
{'outputs': [{'predicate': {'content': '${the_java_api} was copyrightable',
'expression': None,
'truth': False},
'name': 'false the Java API was an original work',
'generic': False,
'standard_of_proof': None,
'anchors': [OrderedDict([('exact', 'a work must be “original”'),
('prefix', ''),
('suffix', '')])],
'terms': [{'name': 'the Java API',
'anchors': [],
'plural': False,
'terms': [{'plural': False,
'name': 'the Java API',
'generic': True,
'type': 'Entity'}],
'absent': False,
'type': 'Fact'}],
'outputs': [{'predicate': {'sign': '',
'content': '{} was copyrightable',
'quantity': None,
'truth': False},
'name': 'false the Java API was copyrightable',
'generic': False,
'standard_of_proof': None,
'anchors': [OrderedDict([('exact', 'copyright protection.'),
('prefix', 'must be “original” to qualify for '),
('suffix', '')]),
OrderedDict([('exact',
'whether the non-literal elements of a program “are protected'),
('prefix', ''),
('suffix', '')])],
'terms': [{'name': 'the Java API',
'anchors': [],
'plural': False,
'generic': False,
'type': 'Fact'}],
'despite': [],
'inputs': [{'predicate': {'content': '${the_java_api} was an original work',
'expression': None,
'truth': False},
'terms': [{'plural': False,
'name': 'the Java API',
'generic': True,
'type': 'Entity'}],
'absent': False,
'type': 'Fact'}],
'despite': []}
'name': 'false the Java API was an original work',
'standard_of_proof': None,
'generic': False,
'type': 'Fact'}]}


Linking Holdings to Opinions
Expand Down Expand Up @@ -456,18 +442,18 @@ Generic Factors
------------------

The two instances of the phrase “the Java API” are in angle brackets to
indicate that the Java API is a generic :class:`~authorityspoke.entities.Entity` mentioned
indicate that the Java API is a generic :class:`nettlesome.entities.Entity` mentioned
in the :class:`~authorityspoke.facts.Fact`\.

>>> oracle.holdings[0].generic_factors
[Entity(name='the Java API', generic=True, plural=False, anchors=[])]


A generic :class:`~authorityspoke.entities.Entity` is “generic”
A generic :class:`~nettlesome.entities.Entity` is “generic”
in the sense that in the context of
the :class:`~authorityspoke.factors.Factor` where
the :class:`~authorityspoke.entities.Entity` appears, it could be replaced with
some other generic :class:`~authorityspoke.entities.Entity` without
the :class:`~nettlesome.entities.Entity` appears, it could be replaced with
some other generic :class:`~nettlesome.entities.Entity` without
changing the meaning of the
:class:`~authorityspoke.factors.Factor` or the :class:`~authorityspoke.rules.Rule` where it appears.

Expand Down Expand Up @@ -871,7 +857,7 @@ for protection under the Copyright Act. This is a two-step analysis.

The first step results in
the :class:`~authorityspoke.facts.Fact` it is false that a generic
:class:`~authorityspoke.entities.Entity` was “an original work”:
:class:`~nettlesome.entities.Entity` was “an original work”:

>>> print(feist.holdings[10])
the Holding to ACCEPT
Expand All @@ -890,7 +876,7 @@ the :class:`~authorityspoke.facts.Fact` it is false that a generic

And the second step relies on the result of the first step to reach the
further result of “absence of the Fact that” a
generic :class:`~authorityspoke.entities.Entity` was “copyrightable”.
generic :class:`nettlesome.entities.Entity` was “copyrightable”.

>>> print(feist.holdings[3])
the Holding to ACCEPT that the EXCLUSIVE way to reach the fact that
Expand Down Expand Up @@ -934,7 +920,7 @@ Holding ``listings_not_copyrightable`` is that
``listings_not_copyrightable`` has
two :class:`~authorityspoke.factors.Factor`\s under its “RESULT”, not
just one. Notice that it doesn’t matter that the two original Holdings
reference different generic :class:`~authorityspoke.entities.Entity` objects
reference different generic :class:`nettlesome.entities.Entity` objects
(“Rural’s telephone directory” versus “Rural’s telephone listings”).
Because they’re generic, they’re interchangeable for this purpose.

Expand Down
60 changes: 30 additions & 30 deletions docs/guides/template_strings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ Predicate objects
-----------------

Here’s an example of a template string used to create
a :class:`~authorityspoke.predicates.Predicate` object
a :class:`~nettlesome.predicates.Predicate` object
in AuthoritySpoke version 0.5:

>>> from authorityspoke import Predicate
>>> parent_sentence = Predicate("$mother was ${child}'s parent")

The phrase that we passed to
the :class:`~authorityspoke.predicates.Predicate` constructor is used to create
the :class:`~nettlesome.predicates.Predicate` constructor is used to create
a Python template string. `Template
strings <https://docs.python.org/3/library/string.html#string.Template>`__
are part of the Python standard library. The dollar signs and curly
Expand All @@ -47,7 +47,7 @@ with a mapping showing how to replace the placeholders with new text.
"Ann was Bob's parent"

Don’t worry: the use of the past tense doesn’t indicate that a tragedy
has befallen Ann or Bob. The :class:`~authorityspoke.predicates.Predicate` class
has befallen Ann or Bob. The :class:`~nettlesome.predicates.Predicate` class
is designed to be used only
with an English-language phrase in the past tense. The past tense is
used because legal analysis is usually backward-looking, determining the
Expand All @@ -56,16 +56,16 @@ or end punctuation to signal the beginning or end of the phrase, because
the phrase may be used in a context where it’s only part of a longer
sentence.

Predicates can be compared using AuthoritySpoke’s :meth:`~authorityspoke.predicates.Predicate.means`\,
:meth:`~authorityspoke.predicates.Predicate.implies`\,
and :meth:`~authorityspoke.predicates.Predicate.contradicts` methods.
The :meth:`~authorityspoke.predicates.Predicate.means` method
checks whether one :class:`~authorityspoke.predicates.Predicate` has
the same meaning as another :class:`~authorityspoke.predicates.Predicate`\.
Predicates can be compared using AuthoritySpoke’s :meth:`~nettlesome.predicates.Predicate.means`\,
:meth:`~nettlesome.predicates.Predicate.implies`\,
and :meth:`~nettlesome.predicates.Predicate.contradicts` methods.
The :meth:`~nettlesome.predicates.Predicate.means` method
checks whether one :class:`~nettlesome.predicates.Predicate` has
the same meaning as another :class:`~nettlesome.predicates.Predicate`\.
One reason for comparing Predicates using
the :meth:`~authorityspoke.predicates.Predicate.means` method instead
the :meth:`~nettlesome.predicates.Predicate.means` method instead
of Python’s ``==`` operator is
that the :meth:`~authorityspoke.predicates.Predicate.means` method can still
that the :meth:`~nettlesome.predicates.Predicate.means` method can still
consider Predicates to have the same meaning even if they use different
identifiers for their placeholders.

Expand Down Expand Up @@ -114,10 +114,10 @@ identifiers <https://docassemble.org/docs/fields.html#variable%20names>`__.
Comparison objects
------------------

AuthoritySpoke’s :class:`~authorityspoke.predicates.Comparison` class
AuthoritySpoke’s :class:`~nettlesome.predicates.Comparison` class
extends the concept of a
:class:`~authorityspoke.predicates.Predicate`\.
A :class:`~authorityspoke.predicates.Comparison` still contains a ``truth`` value and a
:class:`~nettlesome.predicates.Predicate`\.
A :class:`~nettlesome.predicates.Comparison` still contains a ``truth`` value and a
``template`` string, but that template should be used to identify a
quantity that will be compared to an ``expression`` using a ``sign``
such as an equal sign or a greater-than sign. This ``expression`` must
Expand Down Expand Up @@ -149,8 +149,8 @@ when rendering them as text.)

By making the quantitative part of the phrase explicit, you make it
possible for AuthoritySpoke to consider quantities when checking whether
one Comparison :meth:`~authorityspoke.predicates.Comparison.implies` or
:meth:`~authorityspoke.predicates.Comparison.contradicts` another.
one Comparison :meth:`~nettlesome.predicates.Comparison.implies` or
:meth:`~nettlesome.predicates.Comparison.contradicts` another.

>>> smaller_drug_comparison = Comparison(
>>> "the weight of marijuana that $defendant possessed was",
Expand All @@ -165,7 +165,7 @@ kilograms, that implies it was also at least 250 grams.
>>> drug_comparison.implies(smaller_drug_comparison)
True

If you phrase a :class:`~authorityspoke.predicates.Comparison` with an
If you phrase a :class:`~nettlesome.predicates.Comparison` with an
inequality sign using ``truth=False``, AuthoritySpoke will silently
modify your statement so
it can have ``truth=True`` with a different sign. In this example, the
Expand All @@ -182,7 +182,7 @@ that the weight was no more than 10 grams.
'that the weight of marijuana that $defendant possessed was no more than 10 gram'


Of course, this Comparison :meth:`~authorityspoke.predicates.Comparison.contradicts`
Of course, this Comparison :meth:`~nettlesome.predicates.Comparison.contradicts`
the other Comparisons that
asserted the weight was much greater.

Expand All @@ -197,7 +197,7 @@ Comparisons with Integer and Float Expressions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When the number needed for
a :class:`~authorityspoke.predicates.Comparison` isn’t a
a :class:`~nettlesome.predicates.Comparison` isn’t a
physical :class:`~pint.quantity.Quantity` that
can be described with the units in the `pint
library <https://pint.readthedocs.io/en/stable/>`__, you should
Expand All @@ -214,8 +214,8 @@ floating point number, not a string to be parsed.
"that the number of children in ${taxpayer}'s household was exactly equal to 3"

The numeric expression will still be available for comparison methods
like :meth:`~authorityspoke.predicates.Comparison.implies`
or :meth:`~authorityspoke.predicates.Comparison.contradicts`\,
like :meth:`~nettlesome.predicates.Comparison.implies`
or :meth:`~nettlesome.predicates.Comparison.contradicts`\,
but no unit conversion will be available.

>>> at_least_two_children = Comparison("the number of children in ${taxpayer}'s household was", sign=">=", expression=2)
Expand All @@ -234,7 +234,7 @@ Comparisons with Dates
~~~~~~~~~~~~~~~~~~~~~~

The ``expression`` field of
a :class:`~authorityspoke.predicates.Comparison` can be a :py:class:`datetime.date`\.
a :class:`~nettlesome.predicates.Comparison` can be a :py:class:`datetime.date`\.

>>> from datetime import date
>>> copyright_date_range = Comparison("the date when $work was created was", sign=">=", expression = date(1978,1,1))
Expand All @@ -253,13 +253,13 @@ Using Entities as Context Terms
-------------------------------

AuthoritySpoke isn’t limited to
comparing :class:`~authorityspoke.predicates.Predicate`\s
and :class:`~authorityspoke.predicates.Comparison`\s
comparing :class:`~nettlesome.predicates.Predicate`\s
and :class:`~nettlesome.predicates.Comparison`\s
containing unassigned placeholder text. You can
use :class:`~authorityspoke.entities.Entity` objects to
use :class:`nettlesome.entities.Entity` objects to
assign specific terms to the placeholders. You then link the terms to
the :class:`~authorityspoke.predicates.Predicate`
or :class:`~authorityspoke.predicates.Comparison` inside
the :class:`~nettlesome.predicates.Predicate`
or :class:`~nettlesome.predicates.Comparison` inside
a :class:`~authorityspoke.facts.Fact` object.

>>> from authorityspoke import Entity, Fact
Expand All @@ -275,7 +275,7 @@ a :class:`~authorityspoke.facts.Fact` object.


Before, we saw that the Comparison ``specific_tax_rate``
:meth:`~authorityspoke.predicates.Comparison.implies`
:meth:`~nettlesome.predicates.Comparison.implies`
``tax_rate_over_25``. But when we have a fact about the tax rate of a
specific person named Ann, it doesn’t imply anything about Claude’s tax
rate.
Expand Down Expand Up @@ -309,9 +309,9 @@ to different Entities when being compared to other objects.
"the fact that <Elaine>'s marginal income tax rate was greater than 0.25"


When the :meth:`~authorityspoke.predicates.Comparison.implies` method
When the :meth:`~nettlesome.predicates.Comparison.implies` method
produces the answer ``True``, we can also
use the :meth:`~authorityspoke.comparisons.Comparable.explain_implication`
use the :meth:`~nettlesome.quantities.Comparable.explain_implication`
method to find out which pairs of
generic terms can be considered analagous to one another.

Expand Down
7 changes: 3 additions & 4 deletions tests/io/test_holding.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
from authorityspoke.io.downloads import FakeClient
from authorityspoke.io.loaders import (
load_holdings,
read_holdings_from_file,
load_anchored_holdings,
read_anchored_holdings_from_file,
)
from authorityspoke.io import filepaths, text_expansion
from authorityspoke.rules import Rule
Expand Down Expand Up @@ -624,9 +624,8 @@ def test_holding_flagged_exclusive(
`originality_rule` will be a little broader because it's based on
less Enactment text
"""
holdings, _, _, _ = read_anchored_holdings_from_file(
"holding_feist.json", client=self.client
)
fake_client = FakeClient(responses=make_response)
holdings = read_holdings_from_file("holding_feist.json", client=fake_client)

directory = Entity("Rural's telephone directory")
original = Fact(Predicate("$work was an original work"), directory)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_enactments.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ def test_multiple_non_Factor_selectors_for_Holding(self):
"|may|possess the requisite originality"
]
"""

client = FakeClient.from_file("usc.json")
holdings, holding_anchors, _, _ = loaders.read_anchored_holdings_from_file(
"holding_feist.json", client=self.client
"holding_feist.json", client=client
)
assert len(holding_anchors[6]) == 2

0 comments on commit 764c80e

Please sign in to comment.