示例#1
0
 def test_filled_required_set(self):
     command = CommandFiller('ef [name {/names/@text}, age {/age/@text}]')
     inputValues = dict([('/age/@text', '21')])
     command.fill_command(inputValues)
     actual = command.command
     expected = 'ef age 21'
     self.assertEqual(expected, actual)
示例#2
0
 def test_unfilled_optionals_removed(self):
     command = CommandFiller('ef [name {/names/@text},] and [{/age/@text}]')
     inputValues = dict([('/age/@text', '20')])
     command.fill_command(inputValues)
     actual = command.command
     expected = 'ef and 20'
     self.assertEqual(expected, actual)
示例#3
0
 def test_unfilled_required_single_discard_command(self):
     command = CommandFiller('ef age {/age/@text}')
     inputValues = dict([])
     command.fill_command(inputValues)
     actual = command.command
     expected = ''
     self.assertEqual(expected, actual)
示例#4
0
    def test_formatting_numbers(self):
        command = CommandFiller('ef {/name/@text:x}')
        inputValues = dict([('/name/@text', 10)])
        actual = command.fill_command(inputValues)
        expected = "ef a"
        self.assertEqual(expected, actual)

        command = CommandFiller('ef {/name/@text:+05}')
        actual = command.fill_command(inputValues)
        expected = "ef +0010"
        self.assertEqual(expected, actual)
示例#5
0
    def test_filled_optionals_substitutes_keep_one(self):
        command = CommandFiller('ef [name {/names/@text}, age {/age/@text}]')
        inputValues = [('/names/@text', 'theo'), ('/age/@text', '20')]
        command.fill_command(dict(inputValues))
        actual = command.command
        expected = 'ef name theo'
        self.assertEqual(expected, actual)

        command = CommandFiller('ef [name {/names/@text}, age {/age/@text}]')
        inputValues.pop(0)
        command.fill_command(dict(inputValues))
        actual = command.command
        expected = 'ef age 20'
        self.assertEqual(expected, actual)
示例#6
0
 def test_conditional_with_references(self):
     command = CommandFiller(
         'ef $if|age {/age/@text},name {/name/@text}|md5==md{/ver/@text},$')
     inputValues = dict([('/age/@text', 21), ('/name/@text', 'mm'),
                         ('/ver/@text', 5)])
     actual = command.fill_command(inputValues)
     expected = 'ef age 21'
     self.assertEqual(expected, actual)
示例#7
0
 def test_formatting_loop(self):
     command = CommandFiller('ef {/name/@text:for:{{element}} }')
     inputValues = dict([('/name/@text', ['a', 'b', 'c'])])
     actual = command.fill_command(inputValues)
     expected = "ef a b c "
     self.assertEqual(expected, actual)
示例#8
0
 def test_formatting_string(self):
     command = CommandFiller('ef {/name/@text!r:s>5}')
     inputValues = dict([('/name/@text', 'mm')])
     actual = command.fill_command(inputValues)
     expected = "ef s'mm'"
     self.assertEqual(expected, actual)
示例#9
0
 def test_None_value_parsed(self):
     command = CommandFiller('ef {/name/@text}')
     inputValues = dict([('/name/@text', None)])
     actual = command.fill_command(inputValues)
     expected = "ef None"
     self.assertEqual(expected, actual)