def test_copy_save_propogates_to_search_index(): db = SQLiteBackend("foo") ds = { ("foo", "bar"): { "database": "foo", "code": "bar", "name": "lollipop" } } db.write(ds) assert db.search("lollipop") cp = db.get("bar").copy(code="baz") cp["name"] = "candy" cp.save() assert db.search("candy")
def test_case_sensitivity_convert_lowercase(): db = SQLiteBackend("foo") ds = { ("foo", "bar"): { "database": "foo", "code": "bar", "name": "LOLLIpop" } } db.write(ds) assert db.search("LOLLIpop".lower()) assert db.search("lollipop") assert db.search("LOLLipop") assert db.search("LOLL*") assert db.search("Lollipop") assert not db.search("nope")
def test_case_sensitivity_mask(): db = SQLiteBackend("foo") ds = { ("foo", "bar"): { "database": "foo", "code": "bar", "name": "lollipop", "location": "CH", }, ("foo", "baz"): { "database": "foo", "code": "baz", "name": "ice lollipop", "location": "FR", "reference product": "ZEBRA", }, } db.write(ds) assert len(db.search("lollipop")) == 2 assert len(db.search("lollipop", mask={"product": "ZEbra"})) == 1
def test_case_sensitivity_filter(): db = SQLiteBackend("foo") ds = { ("foo", "bar"): { "database": "foo", "code": "bar", "name": "lollipop", "location": "CH", }, ("foo", "baz"): { "database": "foo", "code": "baz", "name": "ice lollipop", "location": "FR", }, } db.write(ds) assert len(db.search("lollipop")) == 2 assert len(db.search("lollipop", filter={"location": "fr"})) == 1 assert len(db.search("lollipop", filter={"location": "FR"})) == 1