Skip to content

Commit

Permalink
Add unit test for patching ruleset.
Browse files Browse the repository at this point in the history
  • Loading branch information
xkww3n committed Nov 10, 2023
1 parent 7eb4c7a commit 0f289b3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions Tests/src/patch/patch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ADD:.example.com
REM:example.com
14 changes: 10 additions & 4 deletions Tests/test_2_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,22 @@ def test_is_domain(self):
assert not rule.is_domain(ipv4addr)

def test_custom_convert(self):
test_src_path = Path("./src/")
test_conv_ruleset = rule.custom_convert(test_src_path/"custom_domain.txt")
test_src_path = Path("./src/custom_ruleset/")
test_conv_ruleset = rule.custom_convert(test_src_path/"domain.txt")
assert test_conv_ruleset == rule.RuleSet("Domain",
[rule.Rule("DomainSuffix", "example.com"),
rule.Rule("DomainFull", "example.com")])

test_conv_ruleset = rule.custom_convert(test_src_path/"custom_ip.txt")
test_conv_ruleset = rule.custom_convert(test_src_path/"ipcidr.txt")
assert test_conv_ruleset == rule.RuleSet("IPCIDR",
[rule.Rule("IPCIDR", "11.4.5.14"),])

test_conv_ruleset = rule.custom_convert(test_src_path/"custom_classic.txt")
test_conv_ruleset = rule.custom_convert(test_src_path/"classic.txt")
assert test_conv_ruleset == rule.RuleSet("Classical",
[rule.Rule("Classical", "DOMAIN,example.com")])

def test_patch(self):
test_src_patch = Path("./src/patch/")
test_ruleset = rule.RuleSet("Domain", [rule.Rule("DomainFull", "example.com")])
rule.apply_patch(test_ruleset, "patch", test_src_patch)
assert test_ruleset == rule.RuleSet("Domain", [rule.Rule("DomainSuffix", "example.com")])

0 comments on commit 0f289b3

Please sign in to comment.