Пример #1
0
    def test_do_prompt_empty_default(self):
        """Tests Var.do_prompt() with empty default"""
        resps = ['']
        self.input_mock.side_effect = lambda x: resps.pop(0)

        var = Var('foo', default='')
        self.assertEqual(var.do_prompt(), '')
        self.assertEqual(self.input_mock.call_count, 1)
Пример #2
0
    def test_do_prompt_empty_default(self):
        """Tests Var.do_prompt() with empty default"""
        resps = ['']
        self.input_mock.side_effect = lambda x: resps.pop(0)

        var = Var('foo', default='')
        self.assertEqual(var.do_prompt(), '')
        self.assertEqual(self.input_mock.call_count, 1)
Пример #3
0
class Jinja(Static):
    """Skeleton dynamic content using jinja syntax"""

    src = 'skeletons/jinja'
    use_jinja = True
    variables = [
        Var('foo'),
        Var('bar'),
    ]
Пример #4
0
    def test_do_prompt(self):
        """Tests Var.do_prompt()
        """
        resps = ['', 'bar']
        self.input_mock.side_effect = lambda x: resps.pop(0)

        var = Var('foo')
        self.assertEqual(var.do_prompt(), 'bar')
        self.assertEqual(self.input_mock.call_count, 2)
Пример #5
0
    def test_do_prompt(self):
        """Tests Var.do_prompt()
        """
        resps = ['', 'bar']
        self.input_mock.side_effect = lambda x: resps.pop(0)

        var = Var('foo')
        self.assertEqual(var.do_prompt(), 'bar')
        self.assertEqual(self.input_mock.call_count, 2)
Пример #6
0
    def test_pep8_var_name(self):
        """Tests long string formatting of options added by vars_to_optparser.

        All lower case with hyphen instead of underscore

        """
        parser = vars_to_optparser([Var('Foo'), Var('foo_bar')])
        self.assertEqual(parser.get_option('--foo').dest, 'Foo')
        self.assertEqual(parser.get_option('--foo-bar').dest, 'foo_bar')
Пример #7
0
 def test_prompt(self):
     """Tests Var.prompt()"""
     var = Var('foo')
     self.assertEqual(var.prompt, 'Enter Foo: ')
Пример #8
0
class Required(Static):
    """Just a ${FileName}.txt file"""
    src = "skeletons/required"
    variables = [Var('file_name')]
Пример #9
0
class DynamicContent(Static):
    """Skeleton dynamic content (bar/bax.txt_tmpl)"""
    src = 'skeletons/dynamic-content'
    variables = [
        Var('baz', 'Dummy variable'),
    ]
Пример #10
0
 def test_default_metavar(self):
     """Tests option's metavar"""
     parser = vars_to_optparser([Var('Foo'), Var('bar_name')])
     self.assertEqual(parser.get_option('--foo').metavar, 'FOO')
     self.assertEqual(parser.get_option('--bar-name').metavar, 'NAME')
Пример #11
0
 def test_prompt_empty_default(self):
     """Tests Var.prompt with empty default"""
     var = Var('foo', default='')
     self.assertEqual(var.prompt, """Enter Foo ['']: """)
Пример #12
0
 def test_prompt_with_default(self):
     """Tests Var.prompt with default"""
     var = Var('foo', default='baz')
     self.assertEqual(var.prompt, """Enter Foo ['baz']: """)
Пример #13
0
 def test_pep8_name(self):
     """Tests Var full description (missing description)"""
     var = Var('foo_bar')
     self.assertEqual(var.full_description, 'Foo Bar')
Пример #14
0
 def test_basic_full_description(self):
     """Tests Var full description (missing description)"""
     var = Var('foo')
     self.assertEqual(var.full_description, 'Foo')
Пример #15
0
 def test_full_description(self):
     """Tests Var full description (complete)"""
     var = Var('foo', description='dummy var')
     self.assertEqual(var.full_description, 'Foo (dummy var)')
Пример #16
0
 def test_repr(self):
     """Tests Var representation"""
     var = Var('foo', description='dummy var')
     self.assertEqual(repr(var), '<Var foo default=None>')
Пример #17
0
class WithRequirement(Skeleton):
    """Skeleton with other skeleton required"""
    variables = [Var('foo', default=1)]
    required_skeletons = [
        WithDefault,
    ]
Пример #18
0
class WithDefault(Skeleton):
    """Skeleton with variables with default"""
    variables = [Var('foo'), Var('bar', default=2), Var('baz')]