mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-10 05:55:25 +00:00
Add a rudimentary test for sogo-tool
Monotone-Parent: 986c53393f0caccafae8ec72f8b2d56477f587b6 Monotone-Revision: 7f7501b1bb5b05b31afe18481c6a203e70e2222b Monotone-Author: jraby@inverse.ca Monotone-Date: 2011-05-20T20:22:56 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -21,3 +21,6 @@ testput_nbrdays = 30
|
||||
|
||||
sieve_server = "localhost"
|
||||
sieve_port = 2000
|
||||
|
||||
sogo_user = "sogo"
|
||||
sogo_tool_path = "/usr/local/sbin/sogo-tool"
|
||||
|
||||
Executable
+43
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# XXX this script has to be run as root because it su to sogo_user
|
||||
# in order to use its .GNUstepDefaults prefs
|
||||
# Would be much better to have another way to specify which Defaults to use
|
||||
|
||||
from config import sogo_user, sogo_tool_path
|
||||
|
||||
import os
|
||||
import pwd
|
||||
import shutil
|
||||
import sogotests
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
class sogoToolTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.backupdir = tempfile.mkdtemp()
|
||||
|
||||
def tearDown(self):
|
||||
os.chdir("/")
|
||||
shutil.rmtree(self.backupdir)
|
||||
|
||||
def testBackupAll(self):
|
||||
""" sogo-tool backup ALL """
|
||||
|
||||
(uid, gid) = pwd.getpwnam(sogo_user)[2:4]
|
||||
|
||||
# We need to run as root since there's no way
|
||||
# of using another user's GNUstepDefaults
|
||||
self.assertEqual(os.getuid(), 0, "this test must run as root...")
|
||||
|
||||
os.chown(self.backupdir, uid, gid)
|
||||
status = os.system("su - %s -c \"(cd %s && %s backup . ALL >/dev/null 2>&1)\""
|
||||
% (sogo_user, self.backupdir, sogo_tool_path))
|
||||
|
||||
rc=os.WEXITSTATUS(status)
|
||||
self.assertEqual(rc, 0, "sogo-tool failed RC=%d" % rc)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sogotests.runTests()
|
||||
Reference in New Issue
Block a user