def test_form_prep(): document = Document() models.load_json(document, testmodule, TEST_DOCUMENT) expected = { 'id': u'ddr-test-123', 'timestamp': u'2014-09-19T03:14:59', 'status': 1, 'title': u'TITLE', 'description': u'DESCRIPTION', } assert models.form_prep(document, testmodule) == expected
def test_form_post(): document = Document() form = Form() form.cleaned_data = { 'id': 'ddr-test-123', 'timestamp': '2014-09-19T12:34:56', 'status': 0, 'title': 'NEW TITLE', 'description': 'NEW DESCRIPTION', } models.load_json(document, testmodule, TEST_DOCUMENT) models.form_post(document, testmodule, form) assert document.id == "ddr-test-123" assert document.timestamp == "2014-09-19T12:34:56" assert document.status == 0 assert document.title == "NEW TITLE" assert document.description == "NEW DESCRIPTION"