Пример #1
0
class TestEngine(object):

    def __init__(self):
        self.appargs = ApplicationArguments()
        logger.set_debug(self.appargs.degbug())
        self.manuscript = Manuscript(self.appargs.manuscripts(), self.appargs.paths(), self.appargs.placeholders())
        if self.appargs.autoexit():
            self.manuscript.add_autoexit_instruction()

    def _log_effective_manuscript(self):
        Logger.set_path(self.manuscript.get_log_path())
        Logger.add_section("Manuscript", u"%s" % self.manuscript)

    def _test(self):
        Logger.set_path(self.manuscript.get_log_path())
        Logger.set_log_dialog_descriptions(self.appargs.log_dialog_descriptions())
        Logger.add_debug("Application arguments")
        Logger.add_debug(" ".join(sys.argv))
        Logger.add_section("Manuscript", u"%s" % self.manuscript)
        instructions = Instructions(self.manuscript, self.appargs.timedelay())
        start_app(instructions, self.appargs.program())

    def run(self):
        if self.appargs.investigate():
            self._log_effective_manuscript()
        else:
            try:
                self._test()
            finally:
                Logger.log()
        return not Logger.has_errors()
Пример #2
0
class TestEngine(object):
    def __init__(self):
        self.appargs = ApplicationArguments()
        logger.set_debug(self.appargs.degbug())
        self.manuscript = Manuscript(self.appargs.manuscripts(),
                                     self.appargs.paths(),
                                     self.appargs.placeholders())
        if self.appargs.autoexit():
            self.manuscript.add_autoexit_instruction()

    def _log_effective_manuscript(self):
        Logger.set_path(self.manuscript.get_log_path())
        Logger.add_section("Manuscript", u"%s" % self.manuscript)

    def _test(self):
        Logger.set_path(self.manuscript.get_log_path())
        Logger.set_log_dialog_descriptions(
            self.appargs.log_dialog_descriptions())
        Logger.add_debug("Application arguments")
        Logger.add_debug(" ".join(sys.argv))
        Logger.add_section("Manuscript", u"%s" % self.manuscript)
        instructions = Instructions(self.manuscript, self.appargs.timedelay())
        start_app(instructions, self.appargs.program())

    def run(self):
        if self.appargs.investigate():
            self._log_effective_manuscript()
        else:
            try:
                self._test()
            finally:
                Logger.log()
        return not Logger.has_errors()
Пример #3
0
 def __init__(self):
     self.appargs = ApplicationArguments()
     logger.set_debug(self.appargs.degbug())
     self.manuscript = Manuscript(self.appargs.manuscripts(),
                                  self.appargs.paths(),
                                  self.appargs.placeholders())
     if self.appargs.autoexit():
         self.manuscript.add_autoexit_instruction()
Пример #4
0
 def test_manuscript_found_in_given_directory_returns_instruction_list(self):
     PATH = r"c:\temp\test_dialog1.txt"
     self.given_file_with_instructions(PATH, ["click OK"])
     manuscripts = ["test_dialog1.txt"]
     paths = [r"c:\temp"]
     manuscript = Manuscript(manuscripts, paths)
     instructions = manuscript.get_instructions()
     self.assertEquals(["# Loading data 'test_dialog1.txt'", "click OK"], instructions)
     os.remove(PATH)
Пример #5
0
 def test_manuscript_found_in_current_directory_returns_instruction_list(self):
     FILE = "test_dialog1.txt"
     PATH = FILE
     self.given_file_with_instructions(PATH, ["click OK"])
     manuscripts = [FILE]
     paths = []
     manuscript = Manuscript(manuscripts, paths)
     instructions = manuscript.get_instructions()
     self.assertEquals(["# Loading data 'test_dialog1.txt'", "click OK"], instructions)
     os.remove(PATH)
Пример #6
0
 def test_manuscript_found_in_autopilot_home_directory_returns_instruction_list(self):
     FILE = "test_dialog1.txt"
     DIR = r"c:\temp"
     PATH = r"%s\%s" % (DIR, FILE)
     self.given_file_with_instructions(PATH, ["click OK"])
     manuscripts = [FILE]
     paths = []
     os.environ["AUTOPILOT_HOME"] = DIR
     manuscript = Manuscript(manuscripts, paths)
     self.assertEquals(["# Loading data 'test_dialog1.txt'", "click OK"], manuscript.get_instructions())
     os.remove(PATH)
Пример #7
0
 def test_manuscripts_are_concatenated(self):
     FILE1 = "test_dialog1.txt"
     FILE2 = "test_dialog2.txt"
     DIR = r"c:\temp"
     PATH1 = r"%s\%s" % (DIR, FILE1)
     PATH2 = r"%s\%s" % (DIR, FILE2)
     self.given_file_with_instructions(PATH1, ["click OK"])
     self.given_file_with_instructions(PATH2, ["click Cancel"])
     manuscripts = [FILE1, FILE2]
     os.environ["AUTOPILOT_HOME"] = DIR
     manuscript = Manuscript(manuscripts, [])
     self.assertEquals([
         "# Loading data 'test_dialog1.txt'",
         "click OK",
         "# Loading data 'test_dialog2.txt'",
         "click Cancel",
     ], manuscript.get_instructions())
     os.remove(PATH1)
     os.remove(PATH2)
Пример #8
0
 def __init__(self):
     self.appargs = ApplicationArguments()
     logger.set_debug(self.appargs.degbug())
     self.manuscript = Manuscript(self.appargs.manuscripts(), self.appargs.paths(), self.appargs.placeholders())
     if self.appargs.autoexit():
         self.manuscript.add_autoexit_instruction()
Пример #9
0
 def test_no_manuscript_found_returns_commented_instruction_list(self):
     manuscripts = ["test_dialog1.txt"]
     paths = []
     manuscript = Manuscript(manuscripts, paths)
     instructions = manuscript.get_instructions()
     self.assertEquals(["# Loading data 'test_dialog1.txt'", "# Path not found for data file 'test_dialog1.txt'"], instructions)
Пример #10
0
 def test_no_input_returns_empty_instruction_list(self):
     manuscripts = []
     paths = []
     manuscript = Manuscript(manuscripts, paths)
     instructions = manuscript.get_instructions()
     self.assertEquals([], instructions)