Skip to content

Commit 3305f97

Browse files
committed
Test _generic.item.html to mke sure submit button displayed properly
Login as admin and new fred user. Admin user should see submit button when viewing /status7. User fred should not see it. Both should see the word 'done-cbb' which is the name of status7. Chose that since done-cbb is unliely to occur naturally while unread (name of /status1) could occur by chance in the future.
1 parent 86d96dc commit 3305f97

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/test_liveserver.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import shutil, errno, pytest, json, gzip, os, re
22

33
from roundup import i18n
4+
from roundup import password
45
from roundup.anypy.strings import b2s
56
from roundup.cgi.wsgi_handler import RequestDispatcher
67
from .wsgi_liveserver import LiveServerTestCase
@@ -62,6 +63,10 @@ def setup_class(cls):
6263
# open the database
6364
cls.db = cls.instance.open('admin')
6465

66+
# add a user without edit access for status.
67+
cls.db.user.create(username="fred", roles='User',
68+
password=password.Password('sekrit'), address='[email protected]')
69+
6570
# set the url the test instance will run at.
6671
cls.db.config['TRACKER_WEB'] = "http://localhost:9001/"
6772
# set up mailhost so errors get reported to debuging capture file
@@ -914,6 +919,34 @@ def test_login_fail_then_succeed(self):
914919
# look for change in text in sidebar post login
915920
self.assertIn('<b>Hello, admin</b>', f.text)
916921

922+
def test__generic_item_template(self):
923+
"""Load /status1 object. Admin has edit rights so should see
924+
a submit button. fred doesn't have edit rights
925+
so should not have a submit button.
926+
"""
927+
for user in ["admin", "fred"]:
928+
# Set up session to manage cookies <insert blue monster here>
929+
session = requests.Session()
930+
session.headers.update({'Origin': self.url_base()})
931+
932+
# login using form
933+
login = {"__login_name": user, '__login_password': 'sekrit',
934+
"@action": "login"}
935+
f = session.post(self.url_base()+'/', data=login)
936+
# look for change in text in sidebar post login
937+
self.assertIn('Hello, %s'%user, f.text)
938+
f = session.post(self.url_base()+'/status7', data=login)
939+
print(f.content)
940+
941+
# status1's name is unread
942+
self.assertIn(b'done-cbb', f.content)
943+
944+
if user == 'admin':
945+
self.assertIn(b'<input name="submit_button" type="submit" value="Submit Changes">', f.content)
946+
else:
947+
self.assertNotIn(b'<input name="submit_button" type="submit" value="Submit Changes">', f.content)
948+
949+
917950
def test_new_issue_with_file_upload(self):
918951
# Set up session to manage cookies <insert blue monster here>
919952
session = requests.Session()

0 commit comments

Comments
 (0)