Ejemplo n.º 1
0
    def print_unused_elements_warning(self):
        unused_elements = []
        
        for page_class in Page.all():
            page = page_class()
            if hasattr(page, "register"):
                page.register()
            if not page in self.used_elements:
                unused_elements.extend(page.registered_elements.keys())
            else:
                for element in page.registered_elements.keys():
                    element_key = '[%s] %s' % \
                                (page.__class__.__name__, element)
                                
                    if element not in self.used_elements.values() and \
                                element_key not in unused_elements:
                        unused_elements.append(element_key)

        if unused_elements:
            template = """${YELLOW}WARNING!
    ------------
    The following elements are registered but are never used: 

      *%s
    ------------
    ${NORMAL}
    """
            ctrl = TerminalController()
            print ctrl.render(template % "\n  *".join(unused_elements))
Ejemplo n.º 2
0
 def print_results(self, language, results):
     if not results:
         return
     ctrl = TerminalController()
     print ctrl.render("${NORMAL}")
     print ctrl.render(results.summary_for(language))
     print "\n"
Ejemplo n.º 3
0
    def print_unused_elements_warning(self):
        unused_elements = []
        
        for page_class in Page.all():
            page = page_class()
            if hasattr(page, "register"):
                page.register()
            if not page in self.used_elements:
                unused_elements.extend(page.registered_elements.keys())
            else:
                for element in page.registered_elements.keys():
                    element_key = '[%s] %s' % \
                                (page.__class__.__name__, element)
                                
                    if element not in self.used_elements.values() and \
                                element_key not in unused_elements:
                        unused_elements.append(element_key)

        if unused_elements:
            template = """${YELLOW}WARNING!
    ------------
    The following elements are registered but are never used: 

      *%s
    ------------
    ${NORMAL}
    """
            ctrl = TerminalController()
            print ctrl.render(template % "\n  *".join(unused_elements))
Ejemplo n.º 4
0
 def print_results(self, language, results):
     if not results:
         return
     ctrl = TerminalController()
     print ctrl.render("${NORMAL}")
     print ctrl.render(results.summary_for(language))
     print "\n"
Ejemplo n.º 5
0
 def execute_after_tests(cls, results):
     ctrl = TerminalController()
     hooks_feedback = ctrl.render('${CYAN}')
     
     for hook in HOOKS['after_tests']:
         try:
             hook().execute(results)
             hooks_feedback += ctrl.render('[HOOKS] AfterTestsHook "%s" executed.\n' % hook)
         except Exception, e:
             raise HookError(e)
Ejemplo n.º 6
0
    def print_lxml_import_error(self):
        template = """${RED}REPORT ERROR
------------
Sorry, but you need to install lxml (python-lxml in aptitude or easy_install lxml)
before using the report feature in pyccuracy.
If you do not need a report use the -R=false parameter.
${NORMAL}
"""
        ctrl = TerminalController()
        print ctrl.render(template)
Ejemplo n.º 7
0
    def print_lxml_import_error(self):
        template = """${RED}REPORT ERROR
------------
Sorry, but you need to install lxml (python-lxml in aptitude or easy_install lxml)
before using the report feature in pyccuracy.
If you do not need a report use the -R=false parameter.
${NORMAL}
"""
        ctrl = TerminalController()
        print ctrl.render(template)
Ejemplo n.º 8
0
    def print_unused_actions_warning(self, unused_actions):
        template = """${YELLOW}WARNING!
------------
The following actions are never used: 

  *%s
------------
${NORMAL}
"""
        ctrl = TerminalController()
        print ctrl.render(template % "\n  *".join(unused_actions))
Ejemplo n.º 9
0
 def print_no_story_header(self, fixture, context):
     val = { 
             "has_no_header_files":True,
             "no_header_files":fixture.no_story_header
           }
     template_loader = TemplateLoader(context.language.key)
     template_string = template_loader.load('noheader')
     template = Template(template_string)
     msg = template.merge(val)
     ctrl = TerminalController()
     print ctrl.render(msg)
Ejemplo n.º 10
0
    def print_unused_actions_warning(self, unused_actions):
        template = """${YELLOW}WARNING!
------------
The following actions are never used: 

  *%s
------------
${NORMAL}
"""
        ctrl = TerminalController()
        print ctrl.render(template % "\n  *".join(unused_actions))
Ejemplo n.º 11
0
 def print_no_story_header(self, fixture, context):
     val = { 
             "has_no_header_files":True,
             "no_header_files":fixture.no_story_header
           }
     template_loader = TemplateLoader(context.language.key)
     template_string = template_loader.load('noheader')
     template = Template(template_string)
     msg = template.merge(val)
     ctrl = TerminalController()
     print ctrl.render(msg)
Ejemplo n.º 12
0
    def print_invalid_action(self, language, err):
        ctrl = TerminalController()
        template_text = TemplateLoader(language).load("invalid_scenario")
        template = Template(template_text)

        values = {
                    "action_text":err.line,
                    "scenario":err.scenario,
                    "filename":err.filename
                 }

        print ctrl.render(template.merge(values))
Ejemplo n.º 13
0
    def print_invalid_action(self, language, err):
        ctrl = TerminalController()
        print ctrl.render("${NORMAL}")
        template_text = TemplateLoader(language).load("invalid_scenario")
        template = Template(template_text)

        values = {
                    "action_text":err.line,
                    "scenario":err.scenario,
                    "filename":err.filename
                 }

        print ctrl.render(template.merge(values))
Ejemplo n.º 14
0
    def execute_before_tests(cls):
        if len(HOOKS['before_tests']) > 0:
            ctrl = TerminalController()
            hooks_feedback = ctrl.render('${CYAN}')

            for hook in HOOKS['before_tests']:
                hook().execute()
                hooks_feedback += ctrl.render('[HOOKS] BeforeTestsHook "%s" executed.\n' % hook)

            hooks_feedback += ctrl.render('${NORMAL}')
            hooks_feedback += "\n"

            print hooks_feedback
Ejemplo n.º 15
0
    def execute_after_tests(cls, results):
        if len(HOOKS['after_tests']) > 0:
            ctrl = TerminalController()
            hooks_feedback = ctrl.render('${CYAN}')

            for hook in HOOKS['after_tests']:
                hook().execute(results)
                hooks_feedback += ctrl.render('[HOOKS] AfterTestsHook "%s" executed.\n' % hook)

            hooks_feedback += ctrl.render('${NORMAL}')
            hooks_feedback += "\n"

            print hooks_feedback
Ejemplo n.º 16
0
    def execute_before_tests(cls):
        if len(HOOKS['before_tests']) > 0:
            ctrl = TerminalController()
            hooks_feedback = ctrl.render('${CYAN}')

            for hook in HOOKS['before_tests']:
                hook().execute()
                hooks_feedback += ctrl.render(
                    '[HOOKS] BeforeTestsHook "%s" executed.\n' % hook)

            hooks_feedback += ctrl.render('${NORMAL}')
            hooks_feedback += "\n"

            print hooks_feedback
Ejemplo n.º 17
0
    def execute_after_tests(cls, results):
        if len(HOOKS['after_tests']) > 0:
            ctrl = TerminalController()
            hooks_feedback = ctrl.render('${CYAN}')

            for hook in HOOKS['after_tests']:
                hook().execute(results)
                hooks_feedback += ctrl.render(
                    '[HOOKS] AfterTestsHook "%s" executed.\n' % hook)

            hooks_feedback += ctrl.render('${NORMAL}')
            hooks_feedback += "\n"

            print hooks_feedback
Ejemplo n.º 18
0
    def run_stories(self, settings, fixture, context=None):
        if not context:
            context = self.create_context_for(settings)

        fixture.start_run()
        if settings.base_url:
            base_url = settings.base_url
        else:
            base_url = "http://localhost"

        try:
            context.browser_driver.start_test(base_url)
        except DriverError, err:
            ctrl = TerminalController()
            template_text = TemplateLoader(settings.default_culture).load("driver_error")
            template = Template(template_text)
            values = {"error": err, "browser_driver": context.browser_driver}
            print ctrl.render(template.merge(values))

            if settings.should_throw:
                raise TestFailedError("The test failed!")
            else:
                return None
Ejemplo n.º 19
0
    def run_stories(self, settings, fixture, context=None):
        if not context:
            context = self.create_context_for(settings)

        fixture.start_run()
        if settings.base_url:
            base_url = settings.base_url
        else:
            base_url = "http://localhost"

        try:
            context.browser_driver.start_test(base_url)
        except DriverError, err:
            ctrl = TerminalController()
            template_text = TemplateLoader(
                settings.default_culture).load("driver_error")
            template = Template(template_text)
            values = {"error": err, "browser_driver": context.browser_driver}
            print ctrl.render(template.merge(values))

            if settings.should_throw:
                raise TestFailedError("The test failed!")
            else:
                return None