Beispiel #1
0
    def test_script_errors(self):
        """Verify that the run method catches errors correctly"""
        # non-existent templates are not caught until in 'run'
        args = ['no-template', 'my.package']
        output = run(*args)
        self.assertTrue('ERROR: No such template' in output)

        # calling the script with no arguments at all prints usage
        output = run()
        self.assertTrue('Usage:' in output)
Beispiel #2
0
    def test_show_help(self):
        # --help produces the DESCRIPTION string
        args = ['templer', '--help']
        output = run(*args)
        comp = self.runner.texts['description'] % {'script_name': 'templer'}
        self.assertTrue(comp in output,
                        '--help produces incorrect output: %s' % output)

        # the name of the given runner is interposed into the help text
        self.runner.name = newname = 'buzbee berkeley'
        output = run(*args, runner=self.runner)
        self.assertTrue(newname in output)
Beispiel #3
0
    def test_show_help(self):
        oldargv = sys.argv

        # --help produces the DESCRIPTION string
        sys.argv = ["templer", "--help"]
        output = run()
        comp = self.runner.texts["description"] % {"script_name": "templer"}
        self.assertTrue(comp in output, "--help produces incorrect output: %s" % output)

        # the name of the given runner is interposed into the help text
        self.runner.name = newname = "buzbee berkeley"
        output = run(self.runner)
        self.assertTrue(newname in output)

        sys.argv = oldargv
Beispiel #4
0
    def test_script_errors(self):
        """Verify that the run method catches errors correctly"""
        oldargv = sys.argv

        # non-existent templates are not caught until in 'run'
        sys.argv = ["templer", "no-template", "my.package"]
        output = run()
        self.assertTrue("ERROR: No such template" in output)

        # calling the script with no arguments at all prints usage
        sys.argv = sys.argv[:1]
        output = run()
        self.assertTrue("Usage:" in output)

        sys.argv = oldargv
Beispiel #5
0
    def test_script_errors(self):
        """Verify that the run method catches errors correctly"""
        oldargv = sys.argv

        # non-existent templates are not caught until in 'run'
        sys.argv = ['templer', 'no-template', 'my.package']
        output = run()
        self.assertTrue('ERROR: No such template' in output)

        # calling the script with no arguments at all prints usage
        sys.argv = sys.argv[:1]
        output = run()
        self.assertTrue('Usage:' in output)

        sys.argv = oldargv
Beispiel #6
0
    def test_show_help(self):
        oldargv = sys.argv

        # --help produces the DESCRIPTION string
        sys.argv = ['templer', '--help']
        output = run()
        comp = self.runner.texts['description'] % {'script_name': 'templer'}
        self.assertTrue(comp in output,
                        '--help produces incorrect output: %s' % output)

        # the name of the given runner is interposed into the help text
        self.runner.name = newname = 'buzbee berkeley'
        output = run(self.runner)
        self.assertTrue(newname in output)

        sys.argv = oldargv
Beispiel #7
0
    def test_script_no_localcommands(self):
        import templer.core.control_script
        old_has_local = templer.core.control_script.HAS_LOCAL_COMMANDS
        templer.core.control_script.HAS_LOCAL_COMMANDS = False
        output = run(*['add', 'foo'])
        templer.core.control_script.HAS_LOCAL_COMMANDS = old_has_local

        comp = self.runner.texts['no_localcommands_warning']
        self.assertTrue(comp in output)
Beispiel #8
0
    def test_version(self):
        oldargv = sys.argv
        # --version should output a version number.  make sure it finds
        # something
        sys.argv = ["templer", "--version"]
        output = run()
        self.assertFalse("unable" in output)

        sys.argv = oldargv
Beispiel #9
0
    def test_version(self):
        oldargv = sys.argv
        # --version should output a version number.  make sure it finds
        # something
        sys.argv = ['templer', '--version']
        output = run()
        self.assertFalse('unable' in output)

        sys.argv = oldargv
def templer(cmd, runner=None, silent=False):
    if not silent:
        print "templer %s" % cmd
    from templer.core.control_script import run
    args = cmd.split()
    kwargs = {'exit': False}
    if runner is not None:
        kwargs['runner'] = runner
    if silent:
        run = capture_stdout(run)
    return run(*args, **kwargs)
Beispiel #11
0
    def test_script_features(self):
        """Verify that the help features of the script function correctly"""
        oldargv = sys.argv

        # --help produces the DESCRIPTION string
        sys.argv = ['templer', '--help']
        output = run()
        self.assertTrue(DESCRIPTION in output,
                        '--help produces incorrect output: %s' % output)

        # --list produces a verbose list of all templates by category
        sys.argv = ['templer', '--list']
        output = run()
        cats = list_sorted_templates()
        catnames = cats.keys()
        templates = sum(cats.values(), [])
        tempnames = [t['name'] for t in templates]
        tempsums = [t['summary'] for t in templates]
        for cat in catnames:
            self.assertTrue(cat in output, '%s not in --list output' % cat)
        for tname in tempnames:
            self.assertTrue(tname in output, '%s not in --list output' % tname)
        for summary in tempsums:
            self.assertTrue(summary in output,
                            '%s not in --list output' % summary)

        # --make-config-file produces a config file with headings for each
        # template
        sys.argv = ['templer', '--make-config-file']
        output = run()
        for theading in ['[' + name + ']' for name in tempnames]:
            self.assertTrue(theading in output,
                            '%s does not appear in .templer' % theading)

        # --version should output a version number.  make sure it finds
        # something
        sys.argv = ['templer', '--version']
        output = run()
        self.assertFalse('unable' in output)

        sys.argv = oldargv
Beispiel #12
0
    def test_generate_dotfile(self):
        """Verify that the help features of the script function correctly"""
        cats = list_sorted_templates()
        templates = sum(cats.values(), [])
        tempnames = [t['name'] for t in templates]

        # --make-config-file produces a config file with headings for each
        # template
        output = run('--make-config-file')
        for theading in ['[' + name + ']' for name in tempnames]:
            self.assertTrue(theading in output,
                            '%s does not appear in .templer' % theading)
Beispiel #13
0
 def test_list_verbose(self):
     output = run('--list')
     cats = list_sorted_templates()
     catnames = cats.keys()
     templates = sum(cats.values(), [])
     tempnames = [t['name'] for t in templates]
     tempsums = [t['summary'] for t in templates]
     for cat in catnames:
         self.assertTrue(cat in output, '%s not in --list output' % cat)
     for tname in tempnames:
         self.assertTrue(tname in output, '%s not in --list output' % tname)
     for summary in tempsums:
         self.assertTrue(summary in output,
                         '%s not in --list output' % summary)
Beispiel #14
0
    def test_generate_dotfile(self):
        """Verify that the help features of the script function correctly"""
        oldargv = sys.argv

        cats = list_sorted_templates()
        catnames = cats.keys()
        templates = sum(cats.values(), [])
        tempnames = [t["name"] for t in templates]

        # --make-config-file produces a config file with headings for each
        # template
        sys.argv = ["templer", "--make-config-file"]
        output = run()
        for theading in ["[" + name + "]" for name in tempnames]:
            self.assertTrue(theading in output, "%s does not appear in .templer" % theading)

        sys.argv = oldargv
Beispiel #15
0
    def test_list_verbose(self):
        oldargv = sys.argv

        sys.argv = ["templer", "--list"]
        output = run()
        cats = list_sorted_templates()
        catnames = cats.keys()
        templates = sum(cats.values(), [])
        tempnames = [t["name"] for t in templates]
        tempsums = [t["summary"] for t in templates]
        for cat in catnames:
            self.assertTrue(cat in output, "%s not in --list output" % cat)
        for tname in tempnames:
            self.assertTrue(tname in output, "%s not in --list output" % tname)
        for summary in tempsums:
            self.assertTrue(summary in output, "%s not in --list output" % summary)

        sys.argv = oldargv
Beispiel #16
0
    def test_generate_dotfile(self):
        """Verify that the help features of the script function correctly"""
        oldargv = sys.argv

        cats = list_sorted_templates()
        catnames = cats.keys()
        templates = sum(cats.values(), [])
        tempnames = [t['name'] for t in templates]

        # --make-config-file produces a config file with headings for each
        # template
        sys.argv = ['templer', '--make-config-file']
        output = run()
        for theading in ['[' + name + ']' for name in tempnames]:
            self.assertTrue(theading in output,
                            '%s does not appear in .templer' % theading)

        sys.argv = oldargv
Beispiel #17
0
    def test_list_verbose(self):
        oldargv = sys.argv

        sys.argv = ['templer', '--list']
        output = run()
        cats = list_sorted_templates()
        catnames = cats.keys()
        templates = sum(cats.values(), [])
        tempnames = [t['name'] for t in templates]
        tempsums = [t['summary'] for t in templates]
        for cat in catnames:
            self.assertTrue(cat in output, '%s not in --list output' % cat)
        for tname in tempnames:
            self.assertTrue(tname in output, '%s not in --list output' % tname)
        for summary in tempsums:
            self.assertTrue(summary in output,
                            '%s not in --list output' % summary)

        sys.argv = oldargv
Beispiel #18
0
 def test_version(self):
     # --version should output a version number.  make sure it finds
     # something
     output = run('--version')
     self.assertFalse('unable' in output)