def test_dump_and_load_procedure(self, make_procedure): procedure = make_procedure["c2"] dumped = dump.to_dict(procedure) schema = schemas.ProcedureSchema() loaded = schema.load(dumped) content = loaded.despite[0].predicate.content assert "the distance between {} and {} was" in content
def test_round_trip_dict(self): data = {"exact": "method of operation"} selector = anchors.read_selector(data) selector_dict = dump.to_dict(selector) new = anchors.read_selector(selector_dict) assert not new.prefix assert new.exact == "method of operation"
def test_round_trip(self): schema = schemas.PredicateSchema() statement = schema.load( {"content": "{}'s favorite number is {}", "quantity": 42} ) dumped = to_dict(statement) new_statement = schema.load(dumped) assert "{}'s favorite number is exactly equal to 42" in str(new_statement)
def test_dump_to_dict_with_units(self): predicate = Predicate( "the distance between {} and {} was {}", truth=True, reciprocal=True, comparison="<>", quantity=Q_("35 feet"), ) dumped = to_dict(predicate) assert dumped["quantity"] == "35 foot"
def test_dump_selector(self): """ Uses text from "path": "/us/usc/t17/s102/b", but no longer includes a reference to the path. """ data = { "text": "process, system,|method of operation|, concept, principle" } selector = anchors.read_selector(data) selector_dict = dump.to_dict(selector) assert isinstance(selector_dict, dict) assert selector_dict["prefix"].startswith("process, system")
def test_dump_and_read_rule(self, make_holding, make_regime): holding = make_holding["h2"] dumped = dump.to_dict(holding) loaded = readers.read_holding(dumped, regime=make_regime) content = loaded.despite[0].predicate.content assert "the distance between {} and {} was" in content
def test_dump_holding(self, make_holding): holding = make_holding["h2"] dumped = dump.to_dict(holding) content = dumped["rule"]["procedure"]["inputs"][0]["predicate"]["content"] assert content == "{} was on the premises of {}"
def test_dump_procedure(self, make_procedure): procedure = make_procedure["c2"] dumped = dump.to_dict(procedure) content = dumped["inputs"][0]["predicate"]["content"] assert content == "{} was on the premises of {}"
def test_round_trip_dict(self, make_code): cfr = make_code["cfr37"] slogans = readers.read_enactment({"source": "/us/cfr/t37/s202.1"}, code=cfr) dumped_slogans = dump.to_dict(slogans) new = readers.read_enactment(dumped_slogans, code=cfr) assert new.source == "/us/cfr/t37/s202.1"
def test_dump_dict(self, make_enactment): d = dump.to_dict(make_enactment["securing_for_authors"]) assert "Science and useful Arts" in d["selector"]["exact"]
def test_dump_rule(self, make_rule): rule = make_rule["h2"] dumped = dump.to_dict(rule) content = dumped["procedure"]["inputs"][0]["predicate"]["content"] assert content == "{} was on the premises of {}"