~linaro-validation/lava-test/trunk

« back to all changes in this revision

Viewing changes to tests/test_abrektest.py

  • Committer: Paul Larson
  • Date: 2010-10-15 16:23:55 UTC
  • mfrom: (46.3.2 abrek-trunk)
  • Revision ID: paul.larson@canonical.com-20101015162355-z1qpg985euzdlcnv
Add a message at the end of test runs to let the user know the test id
of the result

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2010 Linaro
 
2
#
 
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.
 
7
#
 
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.
 
12
#
 
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/>.
 
15
 
 
16
import re
 
17
 
 
18
from abrek.testdef import AbrekTest, AbrekTestInstaller, AbrekTestRunner
 
19
from imposters import OutputImposter, ConfigImposter
 
20
from fixtures import TestCaseWithFixtures
 
21
 
 
22
def maketest(name="foo", version="", installer=None, runner=None, parser=None):
 
23
    if installer is None:
 
24
        installer = makeinstaller()
 
25
    return AbrekTest(name, version, installer, runner, parser)
 
26
 
 
27
def makerunner(**kwargs):
 
28
    return AbrekTestRunner(**kwargs)
 
29
 
 
30
def makeinstaller(**kwargs):
 
31
    return AbrekTestInstaller(**kwargs)
 
32
 
 
33
class AbrekTestConfigOutput(TestCaseWithFixtures):
 
34
    def setUp(self):
 
35
        super(AbrekTestConfigOutput, self).setUp()
 
36
        self.config = self.add_fixture(ConfigImposter())
 
37
        self.out = self.add_fixture(OutputImposter())
 
38
 
 
39
    def test_run(self):
 
40
        testrunner = makerunner(steps=["echo foo"])
 
41
        test = maketest(name="foo", runner=testrunner)
 
42
        test.install()
 
43
        test.run()
 
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))
 
48