Ejemplo n.º 1
0
    def test_parse_field(self):
        s = """

        What is your favourite color?

        radio:
           * red
           * green
           * blue


        Please choose your
        favourite color.

        You can choose only one

        """
        result = parse_field(s)
        expected = 'radio', {
                    'label': 'What is your favourite color?',
                    'help_text': 'Please choose your favourite color.\nYou can choose only one',
                    'choices': [
                                ('red', 'red'),
                                ('green', 'green'),
                                ('blue', 'blue')],
                   }

        self.assertEquals(expected, result)
Ejemplo n.º 2
0
 def test_parse_field_text(self):
     s = "bar\n\ntext"
     result = parse_field(s)
     self.assertEquals(('text', {'label': 'bar', 'help_text': ''}), result)
Ejemplo n.º 3
0
 def test_parse_field_text_with_help(self):
     s = "bar\n\ntext\n\ncontent\n123\n\nfoo\n\nbar"
     result = parse_field(s)
     self.assertEquals(('text', {'help_text': 'content 123\nfoo\nbar', 'label': 'bar'}), result)
Ejemplo n.º 4
0
 def test_parse_field_default(self):
     s = "foo"
     result = parse_field(s)
     self.assertEquals((None, {'label': 'foo', 'help_text': ''}), result)