Exemplo n.º 1
0
class TestHostForm(TestCase):
    def setUp(self):
        self.form = HostForm(data={
          'name': 'foo',
          'ip': '127.0.0.1',
          'unique_id': 'bar',
        })

    def test_initial_conditions(self):
        self.assertTrue(self.form.is_valid())

    def test_invalid_ip(self):
        self.form.data['ip'] = 'invalidipaddress' 
        self.assertFalse(self.form.is_valid())

    def test_no_unique_id(self):
        self.form.data['unique_id'] = ''
        self.assertTrue(self.form.is_valid())

    def test_invalid_name(self):
        self.form.data['name'] = (Host._meta.get_field('name').max_length + 1) * 'a'
        self.assertFalse(self.form.is_valid())
Exemplo n.º 2
0
 def setUp(self):
     self.form = HostForm(data={
       'name': 'foo',
       'ip': '127.0.0.1',
       'unique_id': 'bar',
     })