Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/tests/test_checker.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_checker.py')
-rw-r--r--tests/test_checker.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/test_checker.py b/tests/test_checker.py
new file mode 100644
index 0000000..ab19920
--- /dev/null
+++ b/tests/test_checker.py
@@ -0,0 +1,50 @@
+from util import Checker
+from os import chmod, chown, mkdir, system
+from stat import S_IFDIR, S_IFREG
+from os import R_OK, W_OK, X_OK
+
+system('rm -rf 321 d321')
+
+open('321', 'w').close()
+ck = Checker('321', 500, 500)
+chown('321', 500, 500)
+chmod('321', 0321)
+assert not ck.positive(R_OK, S_IFDIR)
+assert ck.negative(R_OK, S_IFDIR)
+
+assert ck.positive(W_OK | X_OK, S_IFREG)
+assert not ck.negative(W_OK | X_OK, S_IFREG)
+
+mkdir('d321')
+chown('d321', 500, 500)
+chmod('d321', 0321)
+ck = Checker('d321', 500, 500)
+assert not ck.positive(R_OK, S_IFREG)
+assert ck.negative(R_OK, S_IFREG)
+
+assert ck.positive(W_OK | X_OK, S_IFDIR)
+assert not ck.negative(W_OK | X_OK, S_IFDIR)
+
+
+
+
+
+open('241', 'w').close()
+ck = Checker('241', 100, 500)
+chown('241', 500, 500)
+chmod('241', 0241)
+assert not ck.positive(W_OK, S_IFDIR)
+assert ck.negative(W_OK, S_IFDIR)
+
+assert ck.positive(R_OK | X_OK, S_IFREG)
+assert not ck.negative(R_OK | X_OK, S_IFREG)
+
+mkdir('d241')
+chown('d241', 500, 500)
+chmod('d241', 0241)
+ck = Checker('d241', 100, 500)
+assert not ck.positive(W_OK, S_IFREG)
+assert ck.negative(W_OK, S_IFREG)
+
+assert ck.positive(R_OK | X_OK, S_IFDIR)
+assert not ck.negative(R_OK | X_OK, S_IFDIR)