aboutsummaryrefslogtreecommitdiffstats
path: root/tests/testbasic.py
blob: 231481ae6b76760f4c5a6d5ab3555b6f94b24c15 (plain) (blame)
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
49
50
51
52
53
54
55
56
57
58
59
import os, sys, shutil
from commons import *
from nose.tools import *
from sos.sosreport import *
from glob import glob

class GlobalVars:
    pass

class TestBasicSos:
    def __init__(self):
        GlobalVars.dstroot = None
        GlobalVars.commons = commons
        # clean pre-existing dummy plugins
        for i in glob(GlobalVars.commons['pluginpath']+'/dummyPlugin*'):
            os.remove(os.path.join(GlobalVars.commons['pluginpath'],i))

    def setup(self):
        """ prework """
        pass

    def teardown(self):
        """ cleanup dstroot and other miscellaneous files """
        if os.path.isdir(GlobalVars.dstroot) and not None:
            shutil.rmtree(GlobalVars.dstroot)

    def testSosreportBin(self):
        """ test existence of sosreport bin """
        if not os.path.isfile(GlobalVars.commons['bin']):
            raise AssertionError("Sosreport executable does not exist")


    def testUnattended(self):
        """ test unattended """
        GlobalVars.commons['testOptions'].append("-ofilesys")
        GlobalVars.dstroot = sosreport(GlobalVars.commons['testOptions'])
        if not os.path.isdir(GlobalVars.dstroot):
            raise AssertionError("No sosreport created")

    def testPluginEnable(self):
        """ test success of plugin enable """
        if os.path.isdir(GlobalVars.commons['pluginpath']):
            shutil.copy('fixture/dummyPluginEnabled.py',GlobalVars.commons['pluginpath'])
        GlobalVars.commons['testOptions'].append('-odummyPluginEnabled')
        GlobalVars.dstroot = sosreport(GlobalVars.commons['testOptions'])
        if os.path.isdir(GlobalVars.dstroot) \
        and os.path.isfile(os.path.join(GlobalVars.dstroot,'tmp/testenabled.file')):
            return True
        raise AssertionError("testenabled.file not found")

    def testPluginDisable(self):
        """ test plugin disable """
        if os.path.isdir(GlobalVars.commons['pluginpath']):
            shutil.copy('fixture/dummyPluginDisabled.py',GlobalVars.commons['pluginpath'])
        GlobalVars.dstroot = sosreport(["-nrpm","-nselinux","--batch","--build"])
        if os.path.isdir(GlobalVars.dstroot) \
        and os.path.isfile(os.path.join(GlobalVars.dstroot,'tmp/testenabled.file')):
            raise AssertionError("plugin not disabled")
        return True