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
 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
Exemple #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
 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
 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
 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
 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
    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
Exemple #9
0
 def test_field_validator_success(self):
     validator = int
     field = Field('id', value='10', validator=validator)
     field.validate()
     assert field.value == 10
Exemple #10
0
 def test_field_render_with_renderer(self):
     renderer = DummyRenderer()
     field = Field('id', renderer=renderer)
     output = field.render()
     assert isinstance(output, basestring)
 def test_required_field(self):
     renderer = self.Renderer()
     field = Field("id", value="value", renderer=renderer, required=True)
     output = field.render()
     assert "required" in output