Пример #1
0
 def test_output_with_value(self):
     renderer = self.Renderer()
     field = Field("id", value="PUT", renderer=renderer)
     output = field.render()
     assert "type=hidden" in output
     assert "name" in output
     assert 'value="PUT"' in output
Пример #2
0
 def test_output(self):
     renderer = self.Renderer()
     field = Field("id", renderer=renderer)
     output = field.render()
     assert "type=hidden" in output
     assert "name" in output
     assert "value" not in output
Пример #3
0
 def test_field_set_renderer(self):
     renderer = DummyRenderer()
     field = Field('id', renderer=renderer)
     assert field.renderer
     field = Field('id')
     assert not field.renderer
     field.renderer = renderer
     assert field.renderer
Пример #4
0
 def test_output_with_seclected(self):
     renderer = self.Renderer()
     choices = [("foo", "Foo")]
     field = Field("id", value="foo", choices=choices, renderer=renderer)
     output = field.render()
     assert "name" in output
     assert "<select" in output
     assert "option" in output
     assert 'value="foo" selected' in output
Пример #5
0
 def test_output_with_value(self):
     renderer = self.Renderer()
     field = Field("id", value="foo", renderer=renderer)
     output = field.render()
     assert "type=text" in output
     assert "id" in output
     assert "label" in output
     assert "name" in output
     assert 'value="foo"' in output
Пример #6
0
 def test_output(self):
     renderer = self.Renderer()
     choices = [("foo", "Foo")]
     field = Field("id", choices=choices, renderer=renderer)
     output = field.render()
     assert "name" in output
     assert "<select" in output
     assert "option" in output
     assert "foo" in output
     assert "selected" not in output
Пример #7
0
 def test_output(self):
     renderer = self.Renderer()
     field = Field("id", renderer=renderer)
     output = field.render()
     assert "type=text" in output
     assert "id" in output
     assert "label" in output
     assert "name" in output
     assert "value" not in output
     assert "required" not in output
Пример #8
0
    def test_output_with_required(self):
        renderer = self.Renderer()
        choices = [("foo", "Foo")]
        # Test not required
        field = Field("id", value="foo", choices=choices, renderer=renderer, required=False)
        output = field.render()
        assert '<option value="" />' in output

        # Test required
        field = Field("id", value="foo", choices=choices, renderer=renderer, required=True)
        output = field.render()
        assert '<option value="" />' not in output
Пример #9
0
 def test_field_validator_success(self):
     validator = int
     field = Field('id', value='10', validator=validator)
     field.validate()
     assert field.value == 10
Пример #10
0
 def test_field_render_with_renderer(self):
     renderer = DummyRenderer()
     field = Field('id', renderer=renderer)
     output = field.render()
     assert isinstance(output, basestring)
Пример #11
0
 def test_required_field(self):
     renderer = self.Renderer()
     field = Field("id", value="value", renderer=renderer, required=True)
     output = field.render()
     assert "required" in output