Ejemplo n.º 1
0
 def test_returns_403_error_if_form_invalid(self):
     self._create_and_login_user(is_staff=True)
     form = mommy.prepare(Form, number=2, name='')
     self._set_request_data(form, 'user', 'created', 'modified')
     response = current_forms(self.request)
     self.assertEqual(response.status_code, 403)
     self.assertIn('error', json.loads(response.content))
Ejemplo n.º 2
0
 def test_provides_json_list_of_current_forms(self):
     self._create_and_login_user(is_staff=True)
     mommy.make(Form, current=True)
     response = current_forms(self.request)
     response_data = json.loads(response.content)
     self.assertEqual(len(response_data['forms']), 1)
     self.assertTrue(response_data['forms'][0]['current'])
Ejemplo n.º 3
0
 def test_creates_form_and_returns_json_number_and_version(self):
     self._create_and_login_user(is_staff=True)
     form = mommy.prepare(Form, number=2, version=3)
     self._set_request_data(form, 'user', 'created', 'modified')
     response = current_forms(self.request)
     self.assertJSONEqual(response.content, {'number': 2, 'version': 1})