summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas Feldmann <mail@tfeldmann.de>2022-03-31 10:59:17 +0200
committerThomas Feldmann <mail@tfeldmann.de>2022-03-31 10:59:17 +0200
commitabd6cc90bd3f0012fb1194e25d52b77ce67e19c3 (patch)
tree434c01434ea95da55f9104a7a6666b94bc6fea1c /tests
parent76e8a9cd98c80a2775f1ceede20e499f6a3f77c1 (diff)
add tests
Diffstat (limited to 'tests')
-rw-r--r--tests/core/test_tags.py46
1 files changed, 39 insertions, 7 deletions
diff --git a/tests/core/test_tags.py b/tests/core/test_tags.py
index dfdf297..57e4cd5 100644
--- a/tests/core/test_tags.py
+++ b/tests/core/test_tags.py
@@ -1,10 +1,42 @@
from organize.core import should_execute
-def test_tags():
- assert should_execute(rule_tags=[], tags=[], skip_tags=[])
- assert should_execute(rule_tags=["anything"], tags=[], skip_tags=[])
- assert should_execute(rule_tags=["always"], tags=["debug", "test"], skip_tags=[])
- assert not should_execute(rule_tags=[], tags=["debug", "test"], skip_tags=[])
- assert not should_execute(rule_tags=["test"], tags=["debug"], skip_tags=["test"])
- assert not should_execute(rule_tags=["never"], tags=[], skip_tags=[])
+def test_no_tags_given():
+ assert should_execute(rule_tags=None, tags=None, skip_tags=None)
+ assert should_execute(rule_tags=["tag"], tags=None, skip_tags=None)
+ assert should_execute(rule_tags=["tag", "tag2"], tags=None, skip_tags=None)
+
+
+def test_run_tagged():
+ assert not should_execute(rule_tags=None, tags=["tag"], skip_tags=None)
+ assert should_execute(rule_tags=["tag"], tags=["tag"], skip_tags=None)
+ assert should_execute(rule_tags=["tag", "tag2"], tags=["tag"], skip_tags=None)
+ assert not should_execute(rule_tags=["foo", "bar"], tags=["tag"], skip_tags=None)
+ assert not should_execute(rule_tags=["taggity"], tags=["tag"], skip_tags=None)
+
+
+def test_skip():
+ assert should_execute(rule_tags=None, tags=None, skip_tags=["tag"])
+ assert not should_execute(rule_tags=["tag"], tags=None, skip_tags=["tag"])
+ assert not should_execute(rule_tags=["tag", "tag2"], tags=None, skip_tags=["tag"])
+
+
+def test_combination():
+ assert not should_execute(rule_tags=None, tags=["tag"], skip_tags=["foo"])
+ assert not should_execute(rule_tags=["foo", "tag"], tags=["tag"], skip_tags=["foo"])
+
+
+def test_always():
+ assert should_execute(rule_tags=["always"], tags=["debug", "test"], skip_tags=None)
+ assert should_execute(rule_tags=["always", "tag"], tags=None, skip_tags=["tag"])
+ # skip only if specifically requested
+ assert not should_execute(
+ rule_tags=["always", "tag"], tags=None, skip_tags=["always"]
+ )
+
+
+def test_never():
+ assert not should_execute(rule_tags=["never"], tags=None, skip_tags=None)
+ assert not should_execute(rule_tags=["never", "tag"], tags=["tag"], skip_tags=None)
+ # run only if specifically requested
+ assert should_execute(rule_tags=["never", "tag"], tags=["never"], skip_tags=None)