aboutsummaryrefslogtreecommitdiff
path: root/python/action_TEST.py
blob: 95e999e706f33f963c5f0f4a2000301e3099aea3 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env python
# vim: set fileencoding=utf-8 sw=4 sts=4 et :

#
# Copyright (c) 2007 Piotr JaroszyƄski
#
# This file is part of the Paludis package manager. Paludis is free software;
# you can redistribute it and/or modify it under the terms of the GNU General
# Public License version 2, as published by the Free Software Foundation.
#
# Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA  02111-1307  USA
#

from paludis import *
import unittest

Log.instance.log_level = LogLevel.WARNING

class TestCase_01_InstallActionOptions(unittest.TestCase):
    def setUp(self):
        global repo1, repo2
        env = TestEnvironment()
        repo1 = FakeRepository(env, "1")
        repo2 = FakeRepository(env, "2")

    def test_01_create(self):
        InstallActionOptions(True, InstallActionDebugOption.values[0], InstallActionChecksOption.values[0], repo1)

    def test_02_data_members(self):
        iao = InstallActionOptions(True, InstallActionDebugOption.values[0],
                InstallActionChecksOption.values[0], repo1)

        self.assertEquals(iao.no_config_protect, True)
        self.assertEquals(iao.debug_build, InstallActionDebugOption.values[0])
        self.assertEquals(iao.checks, InstallActionChecksOption.values[0])
        self.assertEquals(str(iao.destination.name), "1")

        iao.no_config_protect = False
        iao.debug_build = InstallActionDebugOption.values[1]
        iao.checks = InstallActionChecksOption.values[1]
        iao.destination = repo2

        self.assertEquals(iao.no_config_protect, False)
        self.assertEquals(iao.debug_build, InstallActionDebugOption.values[1])
        self.assertEquals(iao.checks, InstallActionChecksOption.values[1])
        self.assertEquals(str(iao.destination.name), "2")

class TestCase_02_FetchActionOptions(unittest.TestCase):
    def test_01_create(self):
        FetchActionOptions(True, True)

    def test_02_data_members(self):
        fao = FetchActionOptions(True, True)

        self.assertEquals(fao.fetch_unneeded, True)
        self.assertEquals(fao.safe_resume, True)

        fao.fetch_unneeded = False
        fao.safe_resume = False

        self.assertEquals(fao.fetch_unneeded, False)
        self.assertEquals(fao.safe_resume, False)

class TestCase_03_UninstallActionOptions(unittest.TestCase):
    def test_01_create(self):
        UninstallActionOptions(True)

    def test_02_data_members(self):
        uao = UninstallActionOptions(True)

        self.assertEquals(uao.no_config_protect, True)
        uao.no_config_protect = False
        self.assertEquals(uao.no_config_protect, False)


class TestCase_04_InstallAction(unittest.TestCase):
    def test_01_create(self):
        env = TestEnvironment()
        repo1 = FakeRepository(env, "1")
        iao = InstallActionOptions(True, InstallActionDebugOption.values[0],
                InstallActionChecksOption.values[0], repo1)
        InstallAction(iao)

class TestCase_05_FetchAction(unittest.TestCase):
    def test_01_create(self):
        FetchAction(FetchActionOptions(True, True))

class TestCase_06_UninstallAction(unittest.TestCase):
    def test_01_create(self):
        UninstallAction(UninstallActionOptions(True))

class TestCase_07_InstalledAction(unittest.TestCase):
    def test_01_create(self):
        InstalledAction()

class TestCase_08_PretendAction(unittest.TestCase):
    def test_01_create(self):
        PretendAction()

class TestCase_09_ConfigAction(unittest.TestCase):
    def test_01_create(self):
        ConfigAction()

class TestCase_10_InfoAction(unittest.TestCase):
    def test_01_create(self):
        InfoAction()

class TestCase_10_SupportsActionTests(unittest.TestCase):
    def test_01_create(self):
        SupportsInstallActionTest()
        SupportsFetchActionTest()
        SupportsUninstallActionTest()
        SupportsInstalledActionTest()
        SupportsPretendActionTest()
        SupportsConfigActionTest()
        SupportsInfoActionTest()


if __name__ == "__main__":
    unittest.main()