1 from unittest import TestCase
2 from datetime import datetime
3 import cherrypy
4 from turbogears import widgets, config, controllers, expose, mochikit, \
5 validate, validators, testutil
6
7
15
16 myform = widgets.TableForm(fields=MyFormFields())
17
18
19 -class MyRoot(controllers.RootController):
46
54
62
68
70 """CSS should appear when asked for"""
71 testutil.create_request("/")
72 assert "calendar-system.css" in cherrypy.response.body[0]
73
75 """JavaScript should appear when asked for"""
76 testutil.create_request("/")
77 assert "calendar.js" in cherrypy.response.body[0]
78
80 """JSLinks (and MochiKit especially) can be included easily"""
81 testutil.create_request("/usemochi")
82 assert "MochiKit.js" in cherrypy.response.body[0]
83
85 """MochiKit inclusion can be suppressed"""
86 config.update({"global": {"tg.mochikit_suppress": True}})
87 testutil.create_request("/usemochi")
88 suppressed_body = cherrypy.response.body[0]
89
90 config.update({"global": {"tg.mochikit_suppress": False}})
91 testutil.create_request("/usemochi")
92 included_body = cherrypy.response.body[0]
93 assert "MochiKit.js" not in suppressed_body
94 assert "MochiKit.js" in included_body
95
97 """MochiKit can be included everywhere by setting tg.mochikit_all"""
98 config.update({"global": {"tg.mochikit_all": True}})
99 testutil.create_request("/")
100 config.update({"global": {"tg.mochikit_all": False}})
101 assert "MochiKit.js" in cherrypy.response.body[0]
102
104 """Setting tg.mochikit_suppress will prevent including it everywhere"""
105 config.update({"global": {"tg.mochikit_all": True}})
106 config.update({"global": {"tg.mochikit_suppress": True}})
107 testutil.create_request("/")
108 config.update({"global": {"tg.mochikit_all": False}})
109 config.update({"global": {"tg.mochikit_suppress": False}})
110 assert "MochiKit.js" not in cherrypy.response.body[0]
111
118
119
122
127
131
134
135