1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
import os
import unittest
from .. import generator
from . import TestDir
class TestGen(unittest.TestCase):
def test_system(self):
with TestDir() as t:
confname = t.dir+'/procServ.d/blah.conf'
with open(confname, 'w') as F:
F.write("""
[blah]
command = /bin/sh -c blah
chdir = /somedir
user = someone
group = controls
""")
generator.run(t.dir+'/run')
service = t.dir+'/run/procserv-blah.service'
self.assertTrue(os.path.isfile(service))
with open(service, 'r') as F:
content = F.read()
self.assertEqual(content, """
[Unit]
Description=procServ for blah
After=network.target remote-fs.target
ConditionPathIsDirectory=/somedir
[Service]
Type=simple
ExecStart=%s --system blah
RuntimeDirectory=procserv-blah
StandardOutput=syslog
StandardError=inherit
SyslogIdentifier=procserv-blah
User=someone
Group=controls
[Install]
WantedBy=multi-user.target
""" % generator.which('procServ-launcher'))
|