Exemplo n.º 1
0
    def test_dump_enactment_with_selector_to_dict(self, test_client):
        copyright_clause = test_client.read("/us/const/article/I/8/8")
        copyright_clause.select("Science and useful Arts")

        schema = EnactmentSchema()
        dumped = schema.dump(copyright_clause)
        selection = dumped["selection"][0]
        quote = dumped["text_version"]["content"][
            selection["start"]:selection["end"]]
        assert quote == "Science and useful Arts"
Exemplo n.º 2
0
 def test_fields_ordered_with_children_last(self, test_client):
     s103 = test_client.read(query="/us/usc/t17/s103", date="2020-01-01")
     schema = EnactmentSchema()
     dumped = schema.dump(s103)
     assert list(
         dumped["children"][0]["selection"][0].keys()) == ["start", "end"]
     as_json = json.dumps(dumped)
     # Start field comes before end field in selector
     assert '"selection": [{"start":' in as_json
     # "Children" field is last, since it's hard to read otherwise
     assert list(dumped.keys())[-1] == "children"