1
# -*- coding: utf-8 -*-
2
# Copyright: (C) 2013 Canonical
7
# This program is free software; you can redistribute it and/or modify it under
8
# the terms of the GNU General Public License as published by the Free Software
9
# Foundation; version 3.
11
# This program is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16
# You should have received a copy of the GNU General Public License along with
17
# this program; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
from ..tools import basetestcase
26
class BaseUnitTestCase(basetestcase.BaseTestCase):
27
'''Base unit test case module, add all mocks to PATH'''
31
super(BaseUnitTestCase, cls).setUpClass()
32
cls.addToPath(os.path.join("mocks", "offline"))
33
cls.addToPath(os.path.join("mocks", "online"))
36
super(BaseUnitTestCase, self).setUp()
37
self.create_temp_workdir()
38
os.environ['MOCK_MODE'] = "0"
39
os.environ['MOCK_ERROR_MODE'] = "0"
42
class BaseUnitTestCaseWithErrors(BaseUnitTestCase):
43
'''Base unit test case module, simulating errors in mock objects'''
46
'''Reset the error mode to 1'''
47
super(BaseUnitTestCaseWithErrors, self).setUp()
48
os.environ['MOCK_ERROR_MODE'] = "1"
51
def tearDownClass(cls):
52
super(BaseUnitTestCase, cls).setUpClass()
54
os.environ.pop('MOCK_ERROR_MODE')