~ara/checkbox/fixes_554202

« back to all changes in this revision

Viewing changes to plugins/suites_info.py

  • Committer: Marc Tardif
  • Date: 2008-03-06 15:25:51 UTC
  • Revision ID: marc.tardif@canonical.com-20080306152551-tub8ba9itnmkwxu9
Renamed questions and results to tests and answers respectively.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import re
22
22
 
23
23
from hwtest.plugin import Plugin
24
 
from hwtest.question import Question
25
24
from hwtest.template import Template
26
 
 
27
 
 
28
 
class QuestionsInfo(Plugin):
 
25
from hwtest.test import Test
 
26
 
 
27
 
 
28
class SuitesInfo(Plugin):
29
29
 
30
30
    required_attributes = ["directories", "scripts_path", "data_path"]
31
31
    optional_attributes = ["blacklist", "whitelist"]
32
32
 
33
33
    def register(self, manager):
34
 
        super(QuestionsInfo, self).register(manager)
35
 
        self.questions = {}
 
34
        super(SuitesInfo, self).register(manager)
 
35
        self.tests = {}
36
36
 
37
37
        for (rt, rh) in [
38
38
             ("gather", self.gather),
39
39
             ("report", self.report),
40
 
             (("report", "question"), self.report_question)]:
 
40
             (("report", "test"), self.report_test)]:
41
41
            self._manager.reactor.call_on(rt, rh)
42
42
 
43
43
    def gather(self):
50
50
        elements = template.load_directories(directories, blacklist, whitelist)
51
51
 
52
52
        for element in elements:
53
 
            question = Question(self._manager.registry, element)
54
 
            for command in question.command, question.description:
 
53
            test = Test(self._manager.registry, element)
 
54
            for command in test.command, test.description:
55
55
                command.add_path(self.config.scripts_path)
56
56
                command.add_variable("data_path", self.config.data_path)
57
57
 
58
 
            self._manager.reactor.fire(("question", question.plugin), question)
 
58
            self._manager.reactor.fire(("test", test.plugin), test)
59
59
 
60
 
    def report_question(self, question):
61
 
        self.questions[question.name] = question
 
60
    def report_test(self, test):
 
61
        self.tests[test.name] = test
62
62
 
63
63
    def report(self):
64
64
        message = []
65
 
        for question in self.questions.values():
66
 
            attributes = dict(question.attributes)
67
 
            attributes["command"] = str(question.command)
68
 
            attributes["description"] = str(question.description)
69
 
            attributes["answer"] = question.answer.attributes
 
65
        for test in self.tests.values():
 
66
            attributes = dict(test.attributes)
 
67
            attributes["command"] = str(test.command)
 
68
            attributes["description"] = str(test.description)
 
69
            attributes["result"] = test.result.attributes
70
70
            message.append(attributes)
71
 
        self._manager.reactor.fire(("report", "questions"), message)
72
 
 
73
 
 
74
 
factory = QuestionsInfo
 
71
        self._manager.reactor.fire(("report", "tests"), message)
 
72
 
 
73
 
 
74
factory = SuitesInfo