1
# Copyright (c) 2010 Linaro
3
# This program is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation, either version 3 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
from abrek.testdef import AbrekTest, AbrekTestInstaller, AbrekTestRunner
19
from imposters import OutputImposter, ConfigImposter
20
from fixtures import TestCaseWithFixtures
22
def maketest(name="foo", version="", installer=None, runner=None, parser=None):
24
installer = makeinstaller()
25
return AbrekTest(name, version, installer, runner, parser)
27
def makerunner(**kwargs):
28
return AbrekTestRunner(**kwargs)
30
def makeinstaller(**kwargs):
31
return AbrekTestInstaller(**kwargs)
33
class AbrekTestConfigOutput(TestCaseWithFixtures):
35
super(AbrekTestConfigOutput, self).setUp()
36
self.config = self.add_fixture(ConfigImposter())
37
self.out = self.add_fixture(OutputImposter())
40
testrunner = makerunner(steps=["echo foo"])
41
test = maketest(name="foo", runner=testrunner)
44
self.assertEqual("foo", self.out.getvalue().splitlines()[0])
45
completion_message = self.out.getvalue().splitlines()[1]
46
completion_pattern = "ABREK TEST RUN COMPLETE: Result id is 'foo\d+\.0'"
47
self.assertTrue(re.match(completion_pattern, completion_message))