summaryrefslogtreecommitdiff
path: root/tests/run_some_dependencies_test.py
blob: addb0156213e0c3c9f4976022db09d47554e8f82 (plain)
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
#!/usr/bin/env python3

# © Copyright 2021-2022, Scott Gasch

"""This is a "test" that just runs a few system utilities that have
dependencies on this library in "do nothing" mode and makes sure they
exit cleanly.

"""

import logging
import unittest

import bootstrap
import exec_utils
import unittest_utils

logger = logging.getLogger(__name__)


class RunSomeDependenciesTest(unittest.TestCase):
    def test_make_sure_random_utilities_still_seem_to_work(self):
        commands = [
            "/home/scott/cron/manage_lights.py -n --run_profiler >& /dev/null",
            "/home/scott/bin/reminder.py --logging_level=DEBUG >& /dev/null",
            "/home/scott/bin/wordle.py --mode=AUTOPLAY --template=trial >& /dev/null",
            "/home/scott/bin/tplink.py -a office_lights -c info --audit_import_events >& /dev/null",
            "/home/scott/bin/unscramble.py ethyropadratoyzrhoiectmi --trace_memory >& /dev/null",
            "/home/scott/bin/cron.py --command='sleep 0' --lockfile=/tmp/deleteme_lock >& /dev/null",
            "/home/scott/cron/manage_switch_off_timers.py >& /dev/null",
            "/home/scott/bin/smart_device.py cabin and outside and timeout:* -c print >& /dev/null",
        ]
        for command in commands:
            try:
                ret = exec_utils.cmd_exitcode(command, 25.0)
                self.assertEqual(0, ret)
            except Exception as e:
                logger.exception(e)
                self.fail(f"{command} exited with an unexpected exception: {e}")


if __name__ == '__main__':
    bootstrap.initialize(unittest.main)()