23
23
from hwtest.plugin import Plugin
24
from hwtest.question import Question
25
24
from hwtest.template import Template
28
class QuestionsInfo(Plugin):
25
from hwtest.test import Test
28
class SuitesInfo(Plugin):
30
30
required_attributes = ["directories", "scripts_path", "data_path"]
31
31
optional_attributes = ["blacklist", "whitelist"]
33
33
def register(self, manager):
34
super(QuestionsInfo, self).register(manager)
34
super(SuitesInfo, self).register(manager)
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)
50
50
elements = template.load_directories(directories, blacklist, whitelist)
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)
58
self._manager.reactor.fire(("question", question.plugin), question)
58
self._manager.reactor.fire(("test", test.plugin), test)
60
def report_question(self, question):
61
self.questions[question.name] = question
60
def report_test(self, test):
61
self.tests[test.name] = test
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)
74
factory = QuestionsInfo
71
self._manager.reactor.fire(("report", "tests"), message)