Exemple #1
0
class EmptyFormTestCase(TestCase):
    @setup
    def build_form(self):
        self.form = Form()

    def test(self):
        content, content_type = self.form.get_value()

        assert_equal(content, "")
        assert_equal(content_type, "application/x-www-form-urlencoded")
Exemple #2
0
class FileFormTestCase(TestCase):
    @setup
    def build_form(self):
        self.form = Form()
        self.form['value'] = 10

    @setup
    def add_file(self):
        self.file = open(__file__, 'r')
        self.form.add_file(__file__, self.file)

    @teardown
    def close_file(self):
        self.file.close()

    def test(self):
        content, content_type = self.form.get_value()

        lines = content.split('\n')
        assert_true(lines[0].startswith('--'))
        assert_true(content_type.startswith("multipart/form-data"))
Exemple #3
0
class ParamFormTestCase(TestCase):
    @setup
    def build_form(self):
        self.form = Form()
        self.form['value'] = 10
        self.form['text'] = 'A quick brown fox'

    def test(self):
        content, content_type = self.form.get_value()

        assert_equal(content, "text=A+quick+brown+fox&value=10")
        assert_equal(content_type, "application/x-www-form-urlencoded")
Exemple #4
0
 def build_form(self):
     self.form = Form()
     self.form['value'] = 10
Exemple #5
0
 def build_form(self):
     self.form = Form()
     self.form['value'] = 10
     self.form['text'] = 'A quick brown fox'
Exemple #6
0
 def build_form(self):
     self.form = Form()