]> WPIA git - motion.git/blob - tests/test_motion.py
add: implement motion masking
[motion.git] / tests / test_motion.py
1 from datetime import datetime
2 from tests.test_basics import BasicTest
3 import postgresql
4 from motion import app
5
6 # no specific rights required
7 class GeneralTests(BasicTest):
8
9     def setUp(self):
10         self.init_test()
11         global user
12         user = 'testuser/'
13         global userid
14         userid = 4
15         self.db_sampledata()
16
17     def tearDown(self):
18         pass
19
20     def test_main_page(self):
21         response = self.app.get('/', environ_base={'USER_ROLES': user}, follow_redirects=True)
22         self.assertEqual(response.status_code, 200)
23
24     def test_basic_results_data(self):
25         result = self.app.get('/', environ_base={'USER_ROLES': user}, follow_redirects=True)
26         testtext= '<div class="motion card" id="motion-3">\n  <div class="motion-title card-heading alert-warning">'\
27             + '\n    <span class="title-text">Motion C</span> (Canceled)\n    <span class="motion-type">group1</span>'\
28             + '\n    <div># g1.20200402.003'\
29             + '\n    <a class="btn btn-primary" href="/motion/g1.20200402.003" role="button">Result</a>'\
30             + '\n    </div>\n    <div class="date">'\
31             + '\n      <div>Proposed: 2020-04-02 21:47:24 (UTC) by User A</div>'\
32             + '\n      <div>Canceled: 2020-04-03 21:48:24 (UTC) by User A</div>\n     </div>\n  </div>'\
33             + '\n  <div class="card-body">\n    <p><p>A third motion</p></p>'\
34             + '\n    <p>\nYes <span class="badge badge-pill badge-secondary">1</span><br>'\
35             + '\nNo <span class="badge badge-pill badge-secondary">0</span><br>'\
36             + '\nAbstain <span class="badge badge-pill badge-secondary">0</span><br>\n    </p>'\
37             + '\n    <p>Cancelation reason: Entered with wrong text</p>\n  </div>\n</div>\n'
38         self.assertIn(str.encode(testtext), result.data)
39         testtext= '<div class="motion card" id="motion-2">\n  <div class="motion-title card-heading alert-danger">'\
40             + '\n    <span class="title-text">Motion B</span> (Finished)\n    <span class="motion-type">group1</span>'\
41             + '\n    <div># g1.20200402.002'\
42             + '\n    <a class="btn btn-primary" href="/motion/g1.20200402.002" role="button">Result</a>'\
43             + '\n    </div>\n    <div class="date">\n      <div>Proposed: 2020-04-02 21:41:26 (UTC) by User A</div>'\
44             + '\n      <div>Votes until: 2020-04-04 21:41:26 (UTC)</div>\n     </div>\n  </div>'\
45             + '\n  <div class="card-body">\n    <p><p>A second motion</p></p>\n    <p>'\
46             + '\nYes <span class="badge badge-pill badge-secondary">1</span><br>'\
47             + '\nNo <span class="badge badge-pill badge-secondary">2</span><br>'\
48             + '\nAbstain <span class="badge badge-pill badge-secondary">0</span><br>\n    </p>\n  </div>\n</div>\n'
49         self.assertIn(str.encode(testtext), result.data)
50         testtext= '<div class="motion card" id="motion-1">\n  <div class="motion-title card-heading alert-success">'\
51             + '\n    <span class="title-text">Motion A</span> (Finished)\n    <span class="motion-type">group1</span>'\
52             + '\n    <div># g1.20200402.001'\
53             + '\n    <a class="btn btn-primary" href="/motion/g1.20200402.001" role="button">Result</a>'\
54             + '\n    </div>\n    <div class="date">\n      <div>Proposed: 2020-04-02 21:40:33 (UTC) by User A</div>'\
55             + '\n      <div>Votes until: 2020-04-02 21:40:33 (UTC)</div>\n     </div>\n  </div>'\
56             + '\n  <div class="card-body">\n    <p><p>My special motion</p></p>\n    <p>'\
57             + '\nYes <span class="badge badge-pill badge-secondary">2</span><br>'\
58             + '\nNo <span class="badge badge-pill badge-secondary">1</span><br>'\
59             + '\nAbstain <span class="badge badge-pill badge-secondary">0</span><br>\n    </p>\n  </div>\n</div>\n'
60         self.assertIn(str.encode(testtext), result.data)
61         testtext= 'Proxy management'
62         self.assertNotIn(str.encode(testtext), result.data)
63
64         # start with second motion
65         result = self.app.get('/', environ_base={'USER_ROLES': user}, query_string=dict(start=2))
66         testtext= 'id=\"motion-3\">'
67         self.assertNotIn(str.encode(testtext), result.data)
68         testtext= 'id=\"motion-2">'
69         self.assertIn(str.encode(testtext), result.data)
70         testtext= 'id=\"motion-1\">'
71         self.assertIn(str.encode(testtext), result.data)
72
73     def test_basic_results_data_details(self):
74         motion='g1.20200402.002'
75         result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': user}, follow_redirects=True)
76         testtext= '<p>A second motion</p></p>\n  </div>\n</div>\n<a href=\"/?start=2#motion-2\" class=\"btn btn-primary\">Back</a>'
77         self.assertIn(str.encode(testtext), result.data)
78
79     def test_vote(self):
80         motion='g1.20200402.004'
81         response = self.createVote(user, motion, 'yes', userid)
82         self.assertEqual(response.status_code, 403)
83         self.assertIn(str.encode('Forbidden'), response.data)
84
85     def test_no_user(self):
86         result = self.app.get('/', follow_redirects=True)
87         self.assertEqual(result.status_code, 500)
88         self.assertIn(str.encode('Server misconfigured'), result.data)
89
90     def test_user_invalid(self):
91         result = self.app.get('/', environ_base={'USER_ROLES': '<invalid>/'}, follow_redirects=True)
92         self.assertEqual(result.status_code, 403)
93         self.assertIn(str.encode('Access denied'), result.data)
94
95     def test_basic_env(self):
96         result = self.app.get('/', environ_base={'USER': 'testuser', 'ROLES':''}, follow_redirects=True)
97         testtext= 'id=\"motion-3\">'
98         self.assertIn(str.encode(testtext), result.data)
99
100     def test_basic_results_data_details_not_given(self):
101         motion='g1.30190402.001'
102         result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': user}, follow_redirects=True)
103         self.assertEqual(result.status_code, 404)
104         self.assertIn(str.encode('Error, Not found'), result.data)
105
106     def test_no_proxy(self):
107         result = self.app.get('proxy', environ_base={'USER_ROLES': user}, follow_redirects=True)
108         self.assertEqual(result.status_code, 403)
109         self.assertIn(str.encode('Forbidden'), result.data)
110
111     def test_no_proxy_add(self):
112         result = self.app.post('proxy/add', environ_base={'USER_ROLES': user}, follow_redirects=True)
113         self.assertEqual(result.status_code, 403)
114         self.assertIn(str.encode('Forbidden'), result.data)
115
116     def test_no_proxy_revoke(self):
117         result = self.app.post('proxy/revoke', environ_base={'USER_ROLES': user}, follow_redirects=True)
118         self.assertEqual(result.status_code, 403)
119         self.assertIn(str.encode('Forbidden'), result.data)
120
121     def test_no_proxy_revokeAll(self):
122         result = self.app.post('proxy/revokeall', environ_base={'USER_ROLES': user}, follow_redirects=True)
123         self.assertEqual(result.status_code, 403)
124         self.assertIn(str.encode('Forbidden'), result.data)
125         
126 class VoterTests(BasicTest):
127
128     def setUp(self):
129         self.init_test()
130         global user
131         user='testuser/vote:*'
132         global userid
133         userid = 4
134         self.db_sampledata()
135
136     def tearDown(self):
137         pass
138
139     def test_main_page(self):
140         response = self.app.get('/', environ_base={'USER_ROLES': user}, follow_redirects=True)
141         self.assertEqual(response.status_code, 200)
142
143     def test_home_data(self):
144         result = self.app.get('/', environ_base={'USER_ROLES': user})
145         self.assertNotIn("<select class=\"float form-control\" name=\"category\">", str(result.data) )
146
147     def test_vote_yes(self):
148         motion='g1.20200402.004'
149         response = self.createVote(user, motion, 'yes', userid)
150         self.assertEqual(response.status_code, 302)
151         result = self.app.get('/', environ_base={'USER_ROLES': user})
152         resulttext=self.buildResultText('A fourth motion', 1, 0, 0)
153         result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': user}, follow_redirects=True)
154         testtext= 'class=\"btn btn-success\" name=\"vote\" value="yes" id="vote-yes">Yes</button>'
155         self.assertIn(str.encode(testtext), result.data)
156         testtext= 'class=\"btn btn-primary\" name=\"vote\" value=\"no\" id=\"vote-no\">No</button>'
157         self.assertIn(str.encode(testtext), result.data)
158         testtext= 'class=\"btn btn-primary\" name=\"vote\" value=\"abstain\" id=\"vote-abstain\">Abstain</button>'
159         self.assertIn(str.encode(testtext), result.data)
160
161     def test_vote_no(self):
162         motion='g1.20200402.004'
163         response = self.createVote(user, motion, 'no', userid)
164         self.assertEqual(response.status_code, 302)
165         result = self.app.get('/', environ_base={'USER_ROLES': user})
166         resulttext=self.buildResultText('A fourth motion', 0, 1, 0)
167         self.assertIn(str.encode(resulttext), result.data)
168         result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': user}, follow_redirects=True)
169         testtext= 'class="btn btn-primary" name="vote\" value=\"yes\" id=\"vote-yes\">Yes</button>'
170         self.assertIn(str.encode(testtext), result.data)
171         testtext= 'class=\"btn btn-success\" name=\"vote\" value=\"no\" id=\"vote-no\">No</button>'
172         self.assertIn(str.encode(testtext), result.data)
173         testtext= 'class=\"btn btn-primary\" name=\"vote\" value=\"abstain\" id=\"vote-abstain\">Abstain</button>'
174         self.assertIn(str.encode(testtext), result.data)
175
176     def test_vote_abstain(self):
177         motion='g1.20200402.004'
178         response = self.createVote(user, motion, 'abstain', userid)
179         self.assertEqual(response.status_code, 302)
180         result = self.app.get('/', environ_base={'USER_ROLES': user})
181         resulttext=self.buildResultText('A fourth motion', 0, 0, 1)
182         self.assertIn(str.encode(resulttext), result.data)
183         result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': user}, follow_redirects=True)
184         testtext= 'class=\"btn btn-primary\" name=\"vote\" value=\"yes\" id=\"vote-yes\">Yes</button>'
185         self.assertIn(str.encode(testtext), result.data)
186         testtext= 'class=\"btn btn-primary\" name=\"vote\" value=\"no\" id=\"vote-no\">No</button>'
187         self.assertIn(str.encode(testtext), result.data)
188         testtext= 'class=\"btn btn-success\" name=\"vote\" value=\"abstain\" id=\"vote-abstain\">Abstain</button>'
189         self.assertIn(str.encode(testtext), result.data)
190
191     def test_vote_change(self):
192         motion='g1.20200402.004'
193         response = self.createVote(user, motion, 'yes', userid)
194         self.assertEqual(response.status_code, 302)
195         result = self.app.get('/', environ_base={'USER_ROLES': user})
196         resulttext=self.buildResultText('A fourth motion', 1, 0, 0)
197         self.assertIn(str.encode(resulttext), result.data)
198         response = self.createVote(user, motion, 'no', userid)
199         self.assertEqual(response.status_code, 302)
200         result = self.app.get('/', environ_base={'USER_ROLES': user})
201         resulttext=self.buildResultText('A fourth motion', 0, 1, 0)
202         self.assertIn(str.encode(resulttext), result.data)
203         response = self.createVote(user, motion, 'abstain', userid)
204         self.assertEqual(response.status_code, 302)
205         result = self.app.get('/', environ_base={'USER_ROLES': user})
206         resulttext=self.buildResultText('A fourth motion', 0, 0, 1)
207         self.assertIn(str.encode(resulttext), result.data)
208
209     def test_vote_group(self):
210         motion='g1.20200402.004'
211         response = self.createVote(user, motion, 'yes', userid)
212         self.assertEqual(response.status_code, 302)
213
214         motion='g1.20200402.004'
215         user1='testuser/vote:group1'
216         response = self.createVote(user1, motion, 'yes', userid)
217         self.assertEqual(response.status_code, 302)
218
219         motion='g1.20200402.004'
220         user1='testuser/vote:group1 vote:group2'
221         response = self.createVote(user1, motion, 'yes', userid)
222         self.assertEqual(response.status_code, 302)
223
224     def test_vote_wrong_group(self):
225         motion='g1.20200402.004'
226         user1='testuser/vote:group2'
227         response = self.createVote(user1, motion, 'yes', userid)
228         self.assertEqual(response.status_code, 403)
229         self.assertIn(str.encode('Forbidden'), response.data)
230
231     def test_vote_closed(self):
232         motion='g1.20200402.002'
233         response = self.createVote(user, motion, 'abstain', userid)
234         self.assertEqual(response.status_code, 403)
235         self.assertIn(str.encode('Error, out of time'), response.data)
236
237     def test_vote_canceled(self):
238         motion='g1.20200402.003'
239         response = self.createVote(user, motion, 'abstain', userid)
240         self.assertEqual(response.status_code, 403)
241         self.assertIn(str.encode('Error, motion was canceled'), response.data)
242
243     def test_vote_not_given(self):
244         motion='g1.30190402.001'
245         response = self.createVote(user, motion, 'abstain', userid)
246         self.assertEqual(response.status_code, 404)
247         self.assertIn(str.encode('Error, Not found'), response.data)
248
249     def test_cancelMotion(self):
250         motion='g1.20200402.004'
251         reason="none"
252         response = self.cancelMotion(user, motion, reason)
253         self.assertEqual(response.status_code, 403)
254         self.assertIn(str.encode('Forbidden'), response.data)
255
256     def test_finishMotion(self):
257         motion='g1.20200402.004'
258         response = self.finishMotion(user, motion)
259         self.assertEqual(response.status_code, 403)
260         self.assertIn(str.encode('Forbidden'), response.data)
261
262     def test_see_old_vote(self):
263         motion='g1.20200402.002'
264         result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': user}, follow_redirects=True)
265         testtext= '<div>Proposed: 2020-04-02 21:41:26 (UTC) by User A</div>\n      <div>Votes until: 2020-04-04 21:41:26 (UTC)</div>'\
266             + '\n     </div>\n  </div>\n  <div class="card-body">\n    <p><p>A second motion</p></p>\n  </div>\n</div>'\
267             + '\n<a href="/?start=2#motion-2" class="btn btn-primary">Back</a>'
268         self.assertIn(str.encode(testtext), result.data)
269
270     def test_createMotion(self):
271         title='My Motion'
272         content='My body'
273         response = self.createMotion(user, title, content, '3', 'group1')
274         self.assertEqual(response.status_code, 403)
275         self.assertIn(str.encode('Forbidden'), response.data)
276
277
278 class CreateMotionTests(BasicTest):
279
280     def setUp(self):
281         self.init_test()
282         global user
283         user='testuser/vote:* create:* cancel:* finish:*'
284         self.db_clear()
285
286     def tearDown(self):
287         pass
288
289     def test_main_page(self):
290         response = self.app.get('/', environ_base={'USER_ROLES': user}, follow_redirects=True)
291         self.assertEqual(response.status_code, 200)
292
293     def test_home_data(self):
294         result = self.app.get('/', environ_base={'USER_ROLES': user})
295
296         # assert the response data
297         self.assertIn(b'User: testuser', result.data)
298         self.assertIn("<select class=\"float form-control\" name=\"category\">", str(result.data) )
299
300     def test_createMotion(self):
301         title='My Motion'
302         content='My body'
303         response = self.createMotion(user, title, content, '3', 'group1')
304         self.assertEqual(response.status_code, 302)
305         result = self.app.get('/', environ_base={'USER_ROLES': user})
306         self.assertIn(str.encode(title), result.data)
307         self.assertIn(str.encode(content), result.data)
308         self.assertIn(str.encode('g1.'+datetime.today().strftime('%Y%m%d')+'.001'), result.data)
309         testtext='<a class=\"btn btn-primary" href=\"/motion/g1.'+datetime.today().strftime('%Y%m%d')+'.001\" role=\"button\">Vote</a>'
310         self.assertIn(str.encode(testtext), result.data)
311
312         title='My Motion1'
313         content='My body1'
314         response = self.createMotion(user, title, content, '3', 'group1')
315         self.assertEqual(response.status_code, 302)
316         result = self.app.get('/', environ_base={'USER_ROLES': user})
317         self.assertIn(str.encode(title), result.data)
318         self.assertIn(str.encode(content), result.data)
319         self.assertIn(str.encode('g1.'+datetime.today().strftime('%Y%m%d')+'.002'), result.data)
320
321         title='My Motion2'
322         content='My body2'
323         response = self.createMotion(user, title, content, '3', 'group2')
324         self.assertEqual(response.status_code, 302)
325         result = self.app.get('/', environ_base={'USER_ROLES': user})
326         self.assertIn(str.encode(title), result.data)
327         self.assertIn(str.encode(content), result.data)
328         self.assertIn(str.encode('g2.'+datetime.today().strftime('%Y%m%d')+'.001'), result.data)
329
330         title='My Motion3'
331         content='My body3'
332         user1='testuser/vote:* create:group1 cancel:*'
333         response = self.createMotion(user1, title, content, '3', 'group1')
334         self.assertEqual(response.status_code, 302)
335
336         title='My Motion4'
337         content='My body4'
338         user1='testuser/vote:* create:group1 create:group2 cancel:*'
339         response = self.createMotion(user1, title, content, '3', 'group1')
340         self.assertEqual(response.status_code, 302)
341
342
343     def test_createMotionMarkdown(self):
344         title='Markdown Test'
345         content= 'MyMotionBody MD [text](https//domain.tld/link)'
346         response = self.createMotion(user, title, content, '3', 'group1')
347         self.assertEqual(response.status_code, 302)
348         result = self.app.get('/', environ_base={'USER_ROLES': user})
349         self.assertIn(str.encode(title), result.data)
350         self.assertIn(b'MyMotionBody MD <a href=\"https//domain.tld/link\">text</a>', result.data)
351
352     def test_createMotionMarkdownDirectLink(self):
353         title='Markdown Test Link'
354         content='MyMotionBody MD <a href=\"https//domain.tld/link\">direct</a'
355         response = self.createMotion(user, title, content, '3', 'group1')
356         self.assertEqual(response.status_code, 302)
357         result = self.app.get('/', environ_base={'USER_ROLES': user})
358         self.assertIn(str.encode(title), result.data)
359         self.assertIn(b'MyMotionBody MD &lt;a href="https//domain.tld/link"&gt;direct&lt;/a', result.data)
360
361     def test_createMotionMarkdownCombined(self):
362         title='Markdown Test Link'
363         content='Body [combined](https//domain.tld/link) <a href=\"https//domain.tld/link\">combined1</a'
364         response = self.createMotion(user, title, content, '3', 'group1')
365         self.assertEqual(response.status_code, 302)
366         result = self.app.get('/', environ_base={'USER_ROLES': user})
367         self.assertIn(str.encode(title), result.data)
368         self.assertIn(b'Body <a href=\"https//domain.tld/link\">combined</a> &lt;a href="https//domain.tld/link"&gt;combined1&lt;/a', result.data)
369
370     def test_createMotionWrongDayLength(self):
371         title='My Motion'
372         content='My body'
373         response = self.createMotion(user, title, content, '21', 'group1')
374         self.assertEqual(response.status_code, 400)
375         self.assertIn(str.encode('Error, invalid length'), response.data)
376
377     def test_createMotionMissingData(self):
378         title=''
379         content=''
380         response = self.createMotion(user, title, content, '3', 'group1')
381         self.assertEqual(response.status_code, 400)
382         self.assertIn(str.encode('Error, missing title'), response.data)
383         title='New Motion'
384         response = self.createMotion(user, title, content, '3', 'group1')
385         self.assertEqual(response.status_code, 400)
386         self.assertIn(str.encode('Error, missing content'), response.data)
387         title=''
388         content='New Content'
389         response = self.createMotion(user, title, content, '3', 'group1')
390         self.assertEqual(response.status_code, 400)
391         self.assertIn(str.encode('Error, missing title'), response.data)
392
393     def test_createMotionWrongGroup(self):
394         title='My Motion'
395         content='My body'
396         response = self.createMotion(user, title, content, '3', 'test1')
397         self.assertEqual(response.status_code, 403)
398         self.assertIn(str.encode('Forbidden'), response.data)
399
400         user1='testuser/vote:* create:group1 cancel:*'
401         response = self.createMotion(user1, title, content, '3', 'group2')
402         self.assertEqual(response.status_code, 403)
403         self.assertIn(str.encode('Forbidden'), response.data)
404
405     def test_SeeCancelMotion(self):
406         self.db_sampledata()
407
408         motion='g1.20200402.004'
409         result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': user}, follow_redirects=True)
410         testtext= '<button type="submit" class="btn btn-danger" name="cancel" value="cancel" id="cancel">Cancel</button>'
411         self.assertIn(str.encode(testtext), result.data)
412
413         motion='g1.20200402.004'
414         result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': 'testuser/vote:*'}, follow_redirects=True)
415         testtext= '<button type="submit" class="btn btn-danger" name="cancel" value="cancel" id="cancel">Cancel</button>'
416         self.assertNotIn(str.encode(testtext), result.data)
417
418     def test_cancelMotion(self):
419         self.db_sampledata()
420
421         motion='g1.20200402.004'
422         reason="none"
423         response = self.cancelMotion(user, motion, reason)
424         self.assertEqual(response.status_code, 500)
425         self.assertIn(str.encode('Error, form requires reason'), response.data)
426
427         reason='cancel-test'
428         response = self.cancelMotion(user, motion, reason)
429         self.assertEqual(response.status_code, 302)
430         result = self.app.get('/', environ_base={'USER_ROLES': user})
431         self.assertIn(b'Cancelation reason: ' + str.encode(reason), result.data)
432
433         motion='g1.20190402.001'
434         reason="none"
435         response = self.cancelMotion(user, motion, reason)
436         self.assertEqual(response.status_code, 404)
437         self.assertIn(str.encode('Error, Not found'), response.data)
438
439         motion='g1.30200402.001'
440         reason="cancel-test"
441         response = self.cancelMotion(user, motion, reason)
442         self.assertEqual(response.status_code, 404)
443         self.assertIn(str.encode('Error, Not found'), response.data)
444
445         motion='g1.20200402.004'
446         response = self.cancelMotion(user, motion, reason)
447         self.assertEqual(response.status_code, 403)
448         self.assertIn(str.encode('Error, motion was canceled'), response.data)
449
450     def test_SeeFinishMotion(self):
451         self.db_sampledata()
452
453         motion='g1.20200402.004'
454         result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': user}, follow_redirects=True)
455         testtext= '<button type="submit" class="btn btn-danger" name="finish" value="finish" id="finish">Finish</button>'
456         self.assertIn(str.encode(testtext), result.data)
457
458         motion='g1.20200402.004'
459         result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': 'testuser/vote:*'}, follow_redirects=True)
460         testtext= '<button type="submit" class="btn btn-danger" name="finish" value="finish" id="finish">Finish</button>'
461         self.assertNotIn(str.encode(testtext), result.data)
462
463     def test_finishMotion(self):
464         self.db_sampledata()
465
466         motion='g1.20200402.004'
467         response = self.finishMotion(user, motion)
468         self.assertEqual(response.status_code, 302)
469         result = self.app.get('/', environ_base={'USER_ROLES': user})
470         self.assertIn(b'Motion D</span> (Finished)', result.data)
471
472         motion='g1.30190402.001'
473         response = self.finishMotion(user, motion)
474         self.assertEqual(response.status_code, 404)
475         self.assertIn(str.encode('Error, Not found'), response.data)
476         
477         motion='g1.20200402.001'
478         response = self.finishMotion(user, motion)
479         self.assertEqual(response.status_code, 403)
480         self.assertIn(str.encode('Error, out of time'), response.data)
481
482 class AuditMotionTests(BasicTest):
483
484     def setUp(self):
485         self.init_test()
486         global user
487         user='testuser/audit:*'
488         self.db_sampledata()
489
490     def tearDown(self):
491         pass
492
493     def test_see_old_vote(self):
494         motion='g1.20200402.002'
495         result = self.app.get('/motion/' + motion, environ_base={'USER_ROLES': user}, follow_redirects=True)
496         testtext= '<div class="motion card" id="votes">\n  <div class="card-heading text-white bg-info">\n    Motion Votes\n  </div>'\
497             + '\n  <div class="card-body">\n    <div>User A: yes</div>\n    <div>User B: no</div>'\
498             + '\n    <div>User C: no</div>\n  </div>\n</div>\n<a href="/?start=2#motion-2" class="btn btn-primary">Back</a>'
499         self.assertIn(str.encode(testtext), result.data)
500
501
502 if __name__ == "__main__":
503     unittest.main()