def test_02_sensor_selected(self): form = EventForm(data=self.event_data) soup = BeautifulSoup(str(form), 'html.parser') sensor = soup.find(attrs={ 'name': 'sensor' }).findAll('option')[1]['value'] self.event_data.update({'sensor': sensor}) form = EventForm(data=self.event_data) self.assertTrue(form.is_valid()) self.assertTrue(form.is_bound) self.assertEqual(self.event_data['sensor'], form.data['sensor'])
def test_07_status_unselected(self): del self.event_data['status'] form = EventForm(data=self.event_data) soup = BeautifulSoup(str(form), 'html.parser') sensor = soup.find(attrs={ 'name': 'sensor' }).findAll('option')[1]['value'] self.event_data.update({'sensor': sensor}) form = EventForm(data=self.event_data) self.assertFalse(form.is_valid()) self.assertTrue(form.is_bound) self.assertEqual(1, len(form.errors['status'])) self.assertEqual(u'This field is required.', form.errors['status'][0])
def test_01_sensor_unselected(self): form = EventForm(data=self.event_data) self.assertFalse(form.is_valid()) self.assertTrue(form.is_bound) self.assertEqual(1, len(form.errors['sensor'])) self.assertEqual(u'This field is required.', form.errors['sensor'][0])
def test_09_object(self): form = EventForm(data=self.event_data) self.assertIn('location', str(form)) flds_1 = '<EventForm bound=True, valid=False, fields=(sensor;timestamp;location;' flds_2 = 'status;camera;avg_temp;avg_pressure;pct_humidity;altitude;windspeed)>' self.assertEqual('{}{}'.format(flds_1, flds_2), repr(form))