diff --git a/Tests/src/custom_classic.txt b/Tests/src/custom_ruleset/classic.txt similarity index 100% rename from Tests/src/custom_classic.txt rename to Tests/src/custom_ruleset/classic.txt diff --git a/Tests/src/custom_domain.txt b/Tests/src/custom_ruleset/domain.txt similarity index 100% rename from Tests/src/custom_domain.txt rename to Tests/src/custom_ruleset/domain.txt diff --git a/Tests/src/custom_ip.txt b/Tests/src/custom_ruleset/ipcidr.txt similarity index 100% rename from Tests/src/custom_ip.txt rename to Tests/src/custom_ruleset/ipcidr.txt diff --git a/Tests/src/patch/patch.txt b/Tests/src/patch/patch.txt new file mode 100644 index 0000000..b802cf9 --- /dev/null +++ b/Tests/src/patch/patch.txt @@ -0,0 +1,2 @@ +ADD:.example.com +REM:example.com \ No newline at end of file diff --git a/Tests/test_2_utils.py b/Tests/test_2_utils.py index bef0244..ea43496 100644 --- a/Tests/test_2_utils.py +++ b/Tests/test_2_utils.py @@ -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")])