Exemplo n.º 1
0
    def __init__(self, exit_point, scenario, entry_url=None, pages=None, handlers=None, settings=True, driver=None,
                 debug=None):
        self.exit_point = exit_point
        self.scenario = scenario
        self.currentpage = None
        self.previous_page = None
        self.caller_function = inspect.stack()[1][3]

        self.settings = getattr(import_module("polon.conf"), "settings") if settings else None

        if entry_url:
            self.entry_url = entry_url
        else:
            try:
                self.entry_url = self.settings.DEFAULT_ENTRY_URL
            except AttributeError:
                raise AttributeError("Provide entry URL")

        if pages:
            self.pages = pages
        else:
            try:
                from polon.core.pages.loaders import load_pages
                self.pages = load_pages()
            except AttributeError:
                raise AttributeError("Provide set of page objects.")

        if handlers:
            self.handlers = handlers
        else:
            try:
                from polon.core.handlers.loaders import load_handlers
                self.handlers = load_handlers()
            except AttributeError:
                raise AttributeError("Provide set of page handlers.")

        if debug:
            self.debug = True
        else:
            try:
                self.debug = self.settings.DEBUG
            except AttributeError:
                raise AttributeError("Please provide DEBUG setting.")

        if driver:
            self.driver = driver
        else:
            self.driver = webdriver.Firefox()
Exemplo n.º 2
0
    def prepareTest(self, test):
        """ Start Stash server.

        Spawn daemon thread with Stash server.
        :param test: the test case (nose.case.Test)
        :return:
        """
        sys.stdout.write("Validating pages... ")
        for page in load_pages():
            if not issubclass(page, AbstractPage):
                sys.stdout.write("\n")
                raise NotImplementedError("{} Please set the *path* attribute.".format(page))
        sys.stdout.write("ok\n")

        stash = threading.Thread(target=main)
        stash.setDaemon(True)
        stash.start()