Beispiel #1
0
    def test_get_position_in_stack(self):
        """ verify that the position of a template can be reliably found
        """
        stack = self.template.get_template_stack(self.command)
        self.assertRaises(
            ValueError, self.template.get_position_in_stack, stack)

        new_template = NestedNamespace('joe')
        self.assertEqual(
            new_template.get_position_in_stack(stack), len(stack) - 1)
Beispiel #2
0
    def test_should_print_subcommands(self):
        """ Subcommands should be printed after the template runs
        """
        b_template = BasicNamespace('tom')
        n_template = NestedNamespace('bob')
        # pretend the nested_namespace template provides localcommands (it
        # doesn't have to actually provide them, just claim that it does)
        n_template.use_local_commands = True

        self.assertFalse(b_template.should_print_subcommands(self.command))
        self.assertTrue(n_template.should_print_subcommands(self.command))
Beispiel #3
0
    def test_get_template_stack(self):
        """ verify that running this command against a create command
            with the argument '-t nested_namespace' returns the expected vals
        """
        stack = self.template.get_template_stack(self.command)
        self.assertEqual(len(stack), 1)

        self.assertFalse(self.template.__class__ in
                    [t.__class__ for t in stack], "%s" % stack)
        new_template = NestedNamespace('joe')
        self.assertTrue(new_template.__class__ in
                        [t.__class__ for t in stack], "%s" % stack)

        errmsg = "%s does not appear to be a subclass of %s"
        for c in [t.__class__ for t in stack]:
            self.assertTrue(isinstance(new_template, c),
                            errmsg % (new_template, c))