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)
 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)
 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)
    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)
    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)
 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)
 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)
 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)
 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)