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