def test_provides_json_list_of_versions_for_number(self): self._create_and_login_user(is_staff=True) form = mommy.make(Form, number=1, version=1) mommy.make(FormField, form=form, kind='info') response = form_versions(self.request, form.number) forms_data = json.loads(response.content)['forms'] self.assertEqual(len(forms_data), 1) self.assertEqual(forms_data[0]['version'], 1) self.assertEqual(forms_data[0]['fields'][0]['kind'], 'info')
def test_returns_404_error_if_number_does_not_exist(self): self._create_and_login_user(is_staff=True) response = form_versions(self.request, 1) self.assertEqual(response.status_code, 404) self.assertIn('error', json.loads(response.content))