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