def test_form_includes_fields_loaded(self):
     form = mommy.make(Form, number=3, version=2)
     mommy.make(FormField, form=form, kind='info')
     form = forms_service.version(3, 2)
     with self.assertNumQueries(0):
         fields = form.formfield_set.all()
         self.assertEqual(len(fields), 1)
Exemplo n.º 2
0
def _get_form_version(request, number, version):
    form = forms_service.version(number, version)
    exclude = ['user', 'created', 'modified']
    update = {'username': lambda f: f.user.username,
              'date': lambda f: _format_date(f.modified),
              'fields': lambda f: [model_to_dict(fld, 'form')
                                   for fld in f.formfield_set.all()]}
    return JSONResponse({'form': model_to_dict(form, *exclude, **update)})
 def test_form_includes_user_loaded(self):
     mommy.make(Form, number=3, version=2)
     form = forms_service.version(3, 2)
     with self.assertNumQueries(0):
         form.user.username
 def test_returns_form_with_specified_number_and_version(self):
     form = mommy.make(Form, number=3, version=2)
     self.assertEqual(forms_service.version(3, 2).id, form.id)