Logo Search packages:      
Sourcecode: rainbow version File versions  Download package

test_checker.py

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)

Generated by  Doxygen 1.6.0   Back to index