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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
import unittest
import turbogears
from turbogears import testutil
from funcweb.controllers import Root
import cherrypy
from funcweb.widget_automation import WidgetListFactory
cherrypy.root = Root()
class TestWidgetListFactory(unittest.TestCase):
def setUp(self):
self.widget_factory = WidgetListFactory(self.get_test_default_args())
def tearDown(self):
pass
def test_default_args(self):
compare_with = self.get_test_default_args()
widget_list=self.widget_factory.get_widgetlist()
print "The widget list is like :",widget_list
for argument_name,argument_options in compare_with.iteritems():
assert widget_list.has_key(argument_name) == True
#print "The argument name is :",argument_name
#because some of them dont have it like boolean
if argument_options.has_key('default'):
assert argument_options['default'] == getattr(widget_list[argument_name],'default')
if argument_options.has_key("description"):
assert argument_options['description']==getattr(widget_list[argument_name],'help_text')
if argument_options.has_key("options"):
assert argument_options['options'] == getattr(widget_list[argument_name],"options")
#that should be enough
def get_test_default_args(self):
return {
'string_default':{
'type':'string',
'default':'default string',
'optional':False,
'description':'default description'
},
'int_default':{
'type':'int',
'default':'default int',
'optional':False,
'description':'default description'
},
#no sense to have default
'boolean_default':{
'type':'boolean',
'optional':False,
'description':'default description'
},
'float_default':{
'type':'float',
'default':'default float',
'optional':False,
'description':'default description'
},
'hash_default':{
'type':'hash',
'default':'default hash',
'optional':False,
'description':'default description'
},
'list_default':{
'type':'list',
'default':'default list',
'optional':False,
'description':'default description'
},
#will be converted to dropdown
'special_string':{
'type':'string',
'default':'myfirst',
'options':['myfirst','mysecond','mythird'],
'optional':False,
'description':'default dropdown list'
}
}
def get_test_specialized_case(self):
pass
|