File: test_generator.py

package info (click to toggle)
procserv 2.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,356 kB
  • sloc: sh: 4,154; cpp: 1,715; ansic: 1,417; python: 870; makefile: 65
file content (48 lines) | stat: -rwxr-xr-x 1,026 bytes parent folder | download
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'))