4
py.test test cases to test OpenStudio.
5
These tests run based on webclient and need web2py server running.
8
from gluon.contrib.populate import populate
10
from populate_os_tables import populate_tasks
13
def test_task_list(client, web2py):
15
Test if the task list is working
17
# get url so admin user is created
20
assert client.status == 200
22
populate_tasks(web2py)
24
# get the page again now everything's been populated
26
assert client.status == 200
28
assert 'grapes' in client.text
30
# check colors for tasks today & yesterday
31
assert 'red' in client.text
32
assert 'green' in client.text
35
def test_task_list_finished(client, web2py):
37
Test if the task list is working for finished tasks
39
# get url so admin user is created
42
assert client.status == 200
44
populate_tasks(web2py)
46
# get the page again now everything's been populated
47
url = '/tasks/index?filter=finished'
49
assert client.status == 200
51
assert 'bananas' in client.text
52
assert 'line-through' in client.text # class for finished tasks in table row
55
def test_task_list_all(client, web2py):
57
Test if the task list is working for finished tasks
59
# get url so admin user is created
62
assert client.status == 200
64
populate_tasks(web2py)
66
# get the page again now everything's been populated
67
url = '/tasks/index?filter=all'
69
assert client.status == 200
71
assert 'bananas' in client.text
72
assert 'grapes' in client.text
75
def test_task_pinboard(client, web2py):
77
Test if open tasks for today are listed on the pin board
79
# get url so admin user is created
80
url = '/pinboard/index'
82
assert client.status == 200
84
populate_tasks(web2py)
86
# get the page again now everything's been populated
88
assert client.status == 200
90
# make sure the item for today is in the list on the pin board
91
assert 'grapes' in client.text
94
def test_task_add(client, web2py):
96
Can we add a new task?
98
# get url so admin user is created
101
assert client.status == 200
103
populate_tasks(web2py)
106
data = { 'Task' : 'Hello world!',
107
'Description' : 'Adding some items to the list',
108
'Duedate' : '2014-01-01',
113
client.post(url, data=data)
114
assert client.status == 200
116
assert 'world!' in client.text
119
def test_task_customer_add(client, web2py):
121
Can we add a new task linked to a customer?
123
# get url so admin user is created
126
assert client.status == 200
128
populate_tasks(web2py)
131
data = { 'Task' : 'Hello world!',
132
'Description' : 'Adding some items to the list',
133
'Duedate' : '2014-01-01',
137
url = '/tasks/add?cuID=1001'
138
client.post(url, data=data)
139
assert client.status == 200
141
assert 'world!' in client.text
144
query = (web2py.db.tasks.auth_customer_id == 1001)
145
count = web2py.db(query).count()
150
def test_task_workshop_add(client, web2py):
152
Can we add a new task linked to a workshop?
154
# get url so admin user is created
157
assert client.status == 200
159
populate_tasks(web2py)
162
data = { 'Task' : 'Hello world!',
163
'Description' : 'Adding some items to the list',
164
'Duedate' : '2014-01-01',
168
url = '/tasks/add?wsID=1'
169
client.post(url, data=data)
170
assert client.status == 200
172
assert 'world!' in client.text
175
query = (web2py.db.tasks.workshops_id == 1)
176
count = web2py.db(query).count()
181
def test_task_edit(client, web2py):
185
# get url so admin user is created
188
assert client.status == 200
190
populate_tasks(web2py)
191
web2py.db.auth_user.insert(
192
first_name = 'tasks',
194
email = 'tasks@openstudioproject.com',
200
url = '/tasks/edit?tID=1'
202
assert client.status == 200
205
'Task' : 'Hello world!',
206
'Description' : 'Adding some items to the list',
207
'Duedate' : '2014-01-01',
213
url = '/tasks/edit?tID=1'
214
client.post(url, data=data)
215
assert client.status == 200
217
assert 'Tasks' in client.text # verify redirection
219
assert 'world!' in client.text