Ejemplo n.º 1
0
 def test_same_quotation_from_enactments_of_differing_depths(
         self, test_client, section_11_subdivided):
     section = test_client.read_from_json(section_11_subdivided)
     section.select(
         TextQuoteSelector(exact="as they see fit to purchase a beardcoin"))
     subsection = test_client.read_from_json(
         section_11_subdivided["children"][3])
     subsection.select(
         TextQuoteSelector(exact="as they see fit to purchase a beardcoin"))
     assert subsection.means(section)
     assert section >= subsection
     assert not section > subsection
     assert not section.text_sequence() > subsection.text_sequence()
Ejemplo n.º 2
0
    def test_add_overlapping_text_selection(self, fourth_a):
        schema = ExpandableEnactmentSchema()
        search = schema.load(fourth_a)
        warrant = schema.load(fourth_a)
        search.select(TextQuoteSelector(suffix=", and no Warrants"))
        warrant.select(
            TextQuoteSelector(
                exact="shall not be violated, and no Warrants shall issue,"))
        search.select_more_text_at_current_node(warrant.selection)

        passage = ("against unreasonable searches and seizures, " +
                   "shall not be violated, " + "and no Warrants shall issue,")
        assert passage in search.selected_text()
Ejemplo n.º 3
0
 def test_str_for_text_sequence(self, test_client, section_11_subdivided):
     section = test_client.read_from_json(section_11_subdivided)
     quotes = [
         TextQuoteSelector(
             exact="The Department of Beards may issue licenses to such"),
         TextQuoteSelector(exact="hairdressers",
                           suffix=", or other male grooming"),
         TextQuoteSelector(exact="as they see fit"),
     ]
     section.select(quotes)
     text_sequence = section.text_sequence()
     assert str(text_sequence) == (
         "The Department of Beards may issue "
         "licenses to such…hairdressers…as they see fit…")
Ejemplo n.º 4
0
def make_selector() -> Dict[str, TextQuoteSelector]:
    return {
        "bad_selector":
        TextQuoteSelector(exact="text that doesn't exist in the code"),
        "preexisting material":
        TextQuoteSelector(exact=(
            "protection for a work employing preexisting material in which " +
            "copyright subsists does not extend to any part of the work in " +
            "which such material has been used unlawfully.")),
        "copyright":
        TextQuoteSelector(suffix="idea, procedure,"),
        "copyright_requires_originality":
        TextQuoteSelector(suffix="fixed in any tangible"),
    }
Ejemplo n.º 5
0
    def test_add_overlapping_enactments(self, fourth_a):
        schema = EnactmentSchema()
        search = schema.load(fourth_a)
        warrant = schema.load(fourth_a)
        search.select(TextQuoteSelector(suffix=", and no Warrants"))
        warrant.select(
            TextQuoteSelector(
                exact="shall not be violated, and no Warrants shall issue,"))
        combined = search + warrant

        passage = ("against unreasonable searches and seizures, " +
                   "shall not be violated, " + "and no Warrants shall issue,")
        assert passage in combined.text
        # Test that original Enactments unchanged
        assert "and no Warrants" not in search.selected_text()
Ejemplo n.º 6
0
    def test_fail_to_add_repeated_text_from_changed_version(
            self, section_8, old_section_8, test_client):
        """Fail to place selection because "Department of Beards" occurs twice in this scope."""
        new_version = test_client.read_from_json(section_8)
        new_version.select(
            TextQuoteSelector(prefix="Department of Beards, ",
                              exact="Australian Federal Police"))

        old_version = test_client.read_from_json(old_section_8)
        old_version.select(
            TextQuoteSelector(prefix="officer of the ",
                              exact="Department of Beards"))

        with pytest.raises(ValueError):
            _ = new_version + old_version
Ejemplo n.º 7
0
 def test_get_positions_from_quotes(self, section_11_subdivided):
     schema = EnactmentSchema()
     section = schema.load(section_11_subdivided)
     quotes = [
         TextQuoteSelector(
             exact="The Department of Beards may issue licenses to such"),
         TextQuoteSelector(exact="hairdressers",
                           suffix=", or other male grooming"),
         TextQuoteSelector(exact="as they see fit"),
     ]
     positions = section.convert_quotes_to_position(quotes)
     assert positions == TextPositionSet(
         TextPositionSelector(0, 51),
         TextPositionSelector(61, 73),
         TextPositionSelector(112, 127),
     )
Ejemplo n.º 8
0
 def test_selection_in_middle_of_enactment(self, test_client, fourth_a):
     result = test_client.read_from_json(fourth_a)
     selector = TextQuoteSelector(prefix="and",
                                  exact="the persons or things",
                                  suffix="to be seized.")
     result.select(selector)
     assert result.selected_text().endswith("or things…")
Ejemplo n.º 9
0
    def test_not_gt_if_equal_with_selection(self, test_client):

        search_clause = test_client.read(query="/us/const/amendment/IV")
        search_clause.select(TextQuoteSelector(suffix=", and no Warrants"))

        assert search_clause == search_clause
        assert search_clause.means(search_clause)
        assert not search_clause > search_clause
Ejemplo n.º 10
0
    def test_make_enactment_from_selector_without_code(self, test_client):
        selection = TextQuoteSelector(suffix=", shall be vested")
        art_3 = test_client.read(query="/us/const/article/III/1")
        art_3.select(selection)
        text = art_3.selected_text()

        assert text.startswith("The judicial Power")
        assert text.endswith("the United States…")
Ejemplo n.º 11
0
 def test_same_phrase_different_provisions_implication(self, test_client):
     amend_5 = test_client.read(query="/us/const/amendment/V")
     amend_14 = test_client.read(query="/us/const/amendment/XIV/1")
     selector = TextQuoteSelector(
         exact="life, liberty, or property, without due process of law")
     amend_5.select(selector)
     amend_14.select(selector)
     assert amend_5 >= amend_14
Ejemplo n.º 12
0
    def test_able_to_add_subsection_with_text_repeated_elsewhere(
            self, old_section_8, section_8, test_client):
        old_version = test_client.read_from_json(old_section_8)
        new_version = test_client.read_from_json(section_8)
        new_version.select(
            TextQuoteSelector(prefix="Department of Beards, ",
                              exact="Australian Federal Police"))

        old_version.select(
            TextQuoteSelector(prefix="officer of the ",
                              exact="Department of Beards"))

        new_version.children[0].select_more_text_from_changed_version(
            old_version.children[0])

        assert (new_version.selected_text() ==
                "…Department of Beards, Australian Federal Police…")
Ejemplo n.º 13
0
 def test_text_of_enactment_subset(self, section_11_together):
     schema = EnactmentSchema()
     combined = schema.load(section_11_together)
     selector = TextQuoteSelector(
         exact="barbers, hairdressers, or other male grooming professionals"
     )
     combined.select(selector)
     sequence = combined.text_sequence()
     assert str(sequence).strip("…").startswith("barbers")
Ejemplo n.º 14
0
 def test_unable_to_add_subsection_with_new_text(self, old_section_8,
                                                 section_8, test_client):
     old_version = test_client.read_from_json(old_section_8)
     new_version = test_client.read_from_json(section_8)
     old_version.select(
         TextQuoteSelector(prefix="officer of the ",
                           exact="Department of Beards"))
     new_version.select("remove the beard with electrolysis")
     with pytest.raises(TextSelectionError):
         old_version.select_more_text_from_changed_version(new_version)
Ejemplo n.º 15
0
    def test_same_phrase_selected_in_nested_provision_same_meaning(
            self, test_client):

        amend_5 = test_client.read(query="/us/const/amendment/V")
        amend_14 = test_client.read(query="/us/const/amendment/XIV")
        selector = TextQuoteSelector(
            exact="life, liberty, or property, without due process of law")
        amend_5.select(selector)
        amend_14.select(selector)
        assert amend_5.means(amend_14)
Ejemplo n.º 16
0
 def test_str_representation(self, fourth_a, test_client):
     enactment = test_client.read_from_json(fourth_a)
     selection = TextQuoteSelector(
         exact="The right of the people to be secure in their persons")
     enactment.select(selection)
     assert enactment.level == CodeLevel.CONSTITUTION
     assert enactment.start_date == date(1791, 12, 15)
     assert "secure in their persons…" in str(enactment)
     assert enactment.node in str(enactment)
     assert "1791-12-15" in str(enactment)
Ejemplo n.º 17
0
 def test_enactment_subset(self, section_11_together):
     schema = EnactmentSchema()
     combined = schema.load(section_11_together)
     combined.select_all()
     limited = schema.load(section_11_together)
     selector = TextQuoteSelector(
         exact="barbers, hairdressers, or other male grooming professionals"
     )
     limited.select(selector)
     assert not combined.means(limited)
     assert combined > limited
Ejemplo n.º 18
0
    def test_locate_anchor_by_remembering_prefix(self, old_section_8,
                                                 section_8, test_client):
        """
        Place position selector by remembering prefix from TextQuoteSelector.

        Xfails because the prefix information is lost when the selector
        becomes a position selector.
        """
        old_version = test_client.read_from_json(old_section_8)
        new_version = test_client.read_from_json(section_8)
        new_version.select(
            TextQuoteSelector(prefix="Department of Beards, ",
                              exact="Australian Federal Police"))

        old_version.select(
            TextQuoteSelector(prefix="officer of the ",
                              exact="Department of Beards"))

        combined = new_version + old_version
        assert combined.text == "…Department of Beards…Australian Federal Police…"
Ejemplo n.º 19
0
    def test_text_sequence_has_no_consecutive_Nones(self, test_client):

        amend_14 = test_client.read(query="/us/const/amendment/XIV")
        selector = TextQuoteSelector(exact="life, liberty, or property")
        amend_14.select(selector)
        selected_list = amend_14.text_sequence()

        assert len(selected_list) == 3
        assert selected_list[0] is None
        assert selected_list[1].text == "life, liberty, or property"
        assert selected_list[2] is None
Ejemplo n.º 20
0
    def test_fail_to_add_text_not_in_this_version(self, old_section_8,
                                                  section_8, test_client):
        """Fail to add selection from new version because it isn't in the old version."""
        old_version = test_client.read_from_json(old_section_8)
        new_version = test_client.read_from_json(section_8)

        new_version.select(
            TextQuoteSelector(prefix="Department of Beards, ",
                              exact="Australian Federal Police"))
        old_version.select(
            "Any such person issued a notice to remedy under subsection 1 must"
        )
        new_version.select("remove the beard with a laser")
        with pytest.raises(TextSelectionError):
            _ = old_version + new_version
Ejemplo n.º 21
0
 def test_no_space_before_ellipsis(self, test_client):
     enactment = test_client.read(query="/us/usc/t17/s102/b")
     enactment.select(TextQuoteSelector(suffix="idea, procedure,"))
     assert " …" not in enactment.selected_text()