Пример #1
0
 def test_returns_403_error_if_form_data_invalid(self):
     self._create_and_login_user(is_staff=True)
     form = mommy.make(Form, number=1, version=2, name='old')
     self._set_request_data(form, 'user', 'created', 'modified', name='')
     response = form_version(self.request, 1, 2)
     self.assertEqual(response.status_code, 403)
     self.assertIn('error', json.loads(response.content))
Пример #2
0
 def test_provides_json_form_for_number_and_version(self):
     self._create_and_login_user(is_staff=True)
     form = mommy.make(Form, number=1, version=2)
     mommy.make(FormField, form=form, kind='info')
     response = form_version(self.request, 1, 2)
     form_data = json.loads(response.content)['form']
     self.assertEqual(form_data['version'], 2)
     self.assertEqual(form_data['fields'][0]['kind'], 'info')
Пример #3
0
 def test_returns_404_error_if_form_does_not_exist(self):
     self._create_and_login_user(is_staff=True)
     response = form_version(self.request, 1, 2)
     self.assertEqual(response.status_code, 404)
     self.assertIn('error', json.loads(response.content))
Пример #4
0
 def test_sets_form_user_to_current_user(self):
     user = self._create_and_login_user(is_staff=True)
     form = mommy.make(Form, number=1, version=2, name='old')
     self._set_request_data(form, 'user', 'created', 'modified', name='new')
     form_version(self.request, 1, 2)
     self.assertEqual(Form.objects.get(id=form.id).user_id, user.id)
Пример #5
0
 def test_updates_form_and_returns_modified_date(self):
     self._create_and_login_user(is_staff=True)
     form = mommy.make(Form, number=1, version=2, name='old')
     self._set_request_data(form, 'user', 'created', 'modified', name='new')
     response = form_version(self.request, 1, 2)
     self.assertIn('date', json.loads(response.content))