-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathtest_form_from_model.py
31 lines (26 loc) · 1.29 KB
/
test_form_from_model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# -*- coding: utf-8 -*-
# from tests.deep_eq import deep_eq
from pprint import pprint
from zengine.lib.test_utils import BaseTestCase
from zengine.models import User
from zengine.lib.forms import JsonForm
class TestCase(BaseTestCase):
def test_serialize(self):
self.prepare_client('/login/')
serialized_form = JsonForm(User(), types={"password": "password"}, all=True).serialize()
# print("=====================================")
# pprint(serialized_form)
# print("=====================================")
# assert len(serialized_form['form']) == 4
# perms = serialized_form['schema']['properties']['Permissions']
# assert perms['fields'][0]['name'] == 'idx'
serialized_form = JsonForm(self.client.user,
types={"password": "password"},
all=True
).serialize()
# print("\n\n=====================================\n\n")
# pprint(serialized_form)
# print("\n\n=====================================\n\n")
# perms = serialized_form['schema']['properties']['Permissions']
# assert perms['models'][0]['content'][0]['value'] == 'crud'
assert serialized_form['model']['username'] == 'test_user'