Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for complete match on retract fact #46

Merged
merged 1 commit into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "drools_jpy"
version = "0.3.1"
version = "0.3.2"
authors = [
{ name="Madhu Kanoor", email="author@example.com" },
]
Expand Down
Binary file not shown.
27 changes: 27 additions & 0 deletions tests/test_ruleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,33 @@ def test_retract_matching_facts():
assert len(response) == 0


def test_retract_matching_facts_complete():
test_data = load_ast("asts/retract_matching_facts.yml")

my_callback1 = mock.Mock()
my_callback2 = mock.Mock()
result = Matches(data={"m": {"meta": {"uuid": "934"}, "i": 67, "n": 239}})

ruleset_data = test_data[0]["RuleSet"]
rs = Ruleset(
name=ruleset_data["name"], serialized_ruleset=json.dumps(ruleset_data)
)
rs.add_rule(Rule("r1", my_callback1))
rs.add_rule(Rule("r2", my_callback2))

rs.assert_fact(json.dumps(dict(i=67, n=239, meta=dict(uuid="934"))))
rs.assert_fact(json.dumps(dict(j=42)))
assert not my_callback1.called

assert (len(rs.get_facts())) == 1
rs.retract_matching_facts(json.dumps(dict(i=67, n=239)), True, ["meta"])

my_callback2.assert_called_with(result)
response = rs.get_facts()
rs.end_session()
assert len(response) == 0


def test_get_facts():
test_data = load_ast("asts/assert_fact.yml")

Expand Down