def test_sets_new_form_current_and_previous_forms_old(self):
     user = mommy.make(Form, number=3, version=1, current=True).user
     form = mommy.prepare(Form, number=3, user=user)
     form_data = model_to_dict(form)
     form = forms_service.create(**form_data)
     self.assertTrue(form.current)
     self.assertFalse(Form.objects.get(number=3, version=1).current)
Пример #2
0
def _create_form(request):
    data = json.loads(request.body)['form']
    data.update({'user': request.user})
    form = forms_service.create(**data)
    return JSONResponse({'number': form.number, 'version': form.version})
 def test_creates_any_specified_form_fields(self):
     form = mommy.prepare(Form, user=mommy.make(User))
     form_data = model_to_dict(form)
     form_data['fields'] = [{'form': form, 'kind': 'info'}]
     form = forms_service.create(**form_data)
     self.assertEqual(form.formfield_set.first().kind, 'info')
 def test_increases_version_when_unspecified_and_number_specified(self):
     user = mommy.make(Form, number=3, version=4).user
     new_form = mommy.prepare(Form, number=3, user=user)
     form_data = model_to_dict(new_form, 'version')
     form = forms_service.create(**form_data)
     self.assertEqual(form.version, 5)
 def test_increases_number_when_unspecified(self):
     user = mommy.make(Form, number=3).user
     new_form = mommy.prepare(Form, user=user)
     form_data = model_to_dict(new_form, 'number')
     form = forms_service.create(**form_data)
     self.assertEqual(form.number, 4)