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:
authorSascha Silbe <sascha-pgp@silbe.org>2010-07-21 17:30:43 (GMT)
committer Sascha Silbe <sascha-pgp@silbe.org>2010-07-21 17:30:43 (GMT)
commit5ab8ddb8ddb8dc6925cb3bb5f52e0a06b7a1c439 (patch)
tree01e6ca6d9d6eaa54052480200f039c8e50f0166f /tests/test_checker.py
parentd4fe57f377d8f78f02a9e5f6d9c201b4e9eb86f4 (diff)
rearrange source tree to match that of the tarball
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)