comparison test/db_test_base.py @ 5112:8901cc4ef0e0

- issue1714899: Feature Request: Optional Change Note. Added a new quiet=True/False option for all property types. When quiet=True changes to the property will not be displayed in the:: confirmation banner (shown in green) when a change is made property change section of change note (nosy emails) web history display for an item. Note that this may confuse users if used on a property that is meant to be changed by a user. It is most useful on administrative properties that are changed by an auditor as part of a user generated change. Original patch by Daniel Diniz (ajaksu2) discussed also at: http://psf.upfronthosting.co.za/roundup/meta/issue249 Support for setting quiet when calling the class specifiers: E.G. prop=String(quiet=True) rather than:: prop=String() prop.quiet=True support for anydb backend, added tests, doc updates, support for ignoring quiet setting using showall=True in call to history() function in templates by John Rouillard. In addition to documenting quiet, I also documented required and default_value additions to the hyperdb property classes. Only place I could find is design.txt. Note tests for history in web interface are not done. It was manually checked but there are no automated tests. The template for setup is in db_test_base.py::testQuietJournal but it has no asserts. I need access to template.py::_HTMLItem::history() and I don't know how to do that. test_templates.py isn't helping me any at all and I want to get this patch in because it handles nicely an issue I have in the design of my own tracker. The issue is: The properties of an issue are displayed in framesets/subframes. The user can roll up the frameset leaving only the title bar. When the user saves the changes, the current state of the framesets (collapsed/uncollapsed) is saved to a property in the user's object. However there is no reason the user should see that this is updated since it's an administrative detail. Similarly, you could count the number of times an issue is reopened or reassigned. Updates to properties that are an indirect result of a user's change should not be displayed to the user as they can be confusing and distracting.
author John Rouillard <rouilj@ieee.org>
date Thu, 30 Jun 2016 20:38:23 -0400
parents 87b0358790ed
children e098536107ea
comparison
equal deleted inserted replaced
5111:1c94afabb2cb 5112:8901cc4ef0e0
78 mls.setkey("name") 78 mls.setkey("name")
79 status = module.Class(db, "status", name=String(), mls=Multilink("mls")) 79 status = module.Class(db, "status", name=String(), mls=Multilink("mls"))
80 status.setkey("name") 80 status.setkey("name")
81 priority = module.Class(db, "priority", name=String(), order=String()) 81 priority = module.Class(db, "priority", name=String(), order=String())
82 priority.setkey("name") 82 priority.setkey("name")
83 user = module.Class(db, "user", username=String(), password=Password(), 83 user = module.Class(db, "user", username=String(), password=Password(quiet=True),
84 assignable=Boolean(), age=Number(), roles=String(), address=String(), 84 assignable=Boolean(quiet=True), age=Number(quiet=True), roles=String(), address=String(),
85 rating=Integer(), supervisor=Link('user'),realname=String()) 85 rating=Integer(quiet=True), supervisor=Link('user'),realname=String(quiet=True))
86 user.setkey("username") 86 user.setkey("username")
87 file = module.FileClass(db, "file", name=String(), type=String(), 87 file = module.FileClass(db, "file", name=String(), type=String(),
88 comment=String(indexme="yes"), fooz=Password()) 88 comment=String(indexme="yes"), fooz=Password())
89 file_nidx = module.FileClass(db, "file_nidx", content=String(indexme='no')) 89 file_nidx = module.FileClass(db, "file_nidx", content=String(indexme='no'))
90
91 # initialize quiet mode a second way without using Multilink("user", quiet=True)
92 mynosy = Multilink("user")
93 mynosy.quiet = True
90 issue = module.IssueClass(db, "issue", title=String(indexme="yes"), 94 issue = module.IssueClass(db, "issue", title=String(indexme="yes"),
91 status=Link("status"), nosy=Multilink("user"), deadline=Date(), 95 status=Link("status"), nosy=mynosy, deadline=Date(quiet=True),
92 foo=Interval(), files=Multilink("file"), assignedto=Link('user'), 96 foo=Interval(quiet=True, default_value=date.Interval('-1w')), files=Multilink("file"), assignedto=Link('user', quiet=True),
93 priority=Link('priority'), spam=Multilink('msg'), 97 priority=Link('priority'), spam=Multilink('msg'),
94 feedback=Link('msg')) 98 feedback=Link('msg'))
95 stuff = module.Class(db, "stuff", stuff=String()) 99 stuff = module.Class(db, "stuff", stuff=String())
96 session = module.Class(db, 'session', title=String()) 100 session = module.Class(db, 'session', title=String())
97 msg = module.FileClass(db, "msg", date=Date(), 101 msg = module.FileClass(db, "msg", date=Date(),
875 self.db.user.audit('create', test.c, 2) 879 self.db.user.audit('create', test.c, 2)
876 self.db.user.create(username="mary") 880 self.db.user.create(username="mary")
877 self.assertEqual(test.call_a, 0) 881 self.assertEqual(test.call_a, 0)
878 self.assertEqual(test.call_b, 1) 882 self.assertEqual(test.call_b, 1)
879 self.assertEqual(test.call_c, 2) 883 self.assertEqual(test.call_c, 2)
884
885 def testDefault_Value(self):
886 new_issue=self.db.issue.create(title="title", deadline=date.Date('2016-6-30.22:39'))
887
888 # John Rouillard claims this should return the default value of 1 week for foo,
889 # but the hyperdb doesn't assign the default value for missing properties in the
890 # db on creation.
891 result=self.db.issue.get(new_issue, 'foo')
892 # When the defaultis automatically set by the hyperdb, change this to
893 # match the Interval test below.
894 self.assertEqual(result, None)
895
896 # but verify that the default value is retreivable
897 result=self.db.issue.properties['foo'].get_default_value()
898 self.assertEqual(result, date.Interval('-7d'))
899
900 def testQuietProperty(self):
901 # make sure that the quiet properties: "assignable" and "age" are not
902 # returned as part of the proplist
903 new_user=self.db.user.create(username="pete", age=10, assignable=False)
904 new_issue=self.db.issue.create(title="title", deadline=date.Date('2016-6-30.22:39'))
905 # change all quiet params. Verify they aren't returned in object.
906 # between this and the issue class every type represented in hyperdb
907 # should be initalized with a quiet parameter.
908 result=self.db.user.set(new_user, username="new", age=20, supervisor='3', assignable=True,
909 password=password.Password("3456"), rating=4, realname="newname")
910 self.assertEqual(result, {'supervisor': '3', 'username': "new"})
911 result=self.db.user.get(new_user, 'age')
912 self.assertEqual(result, 20)
913
914 # change all quiet params. Verify they aren't returned in object.
915 result=self.db.issue.set(new_issue, title="title2", deadline=date.Date('2016-7-13.22:39'),
916 assignedto="2", nosy=["3", "2"])
917 self.assertEqual(result, {'title': 'title2'})
918
919 # also test that we can make a property noisy
920 self.db.user.properties['age'].quiet=False
921 result=self.db.user.set(new_user, username="old", age=30, supervisor='2', assignable=False)
922 self.assertEqual(result, {'age': 30, 'supervisor': '2', 'username': "old"})
923 self.db.user.properties['age'].quiet=True
924
925 def testQuietChangenote(self):
926 # create user 3 for later use
927 self.db.user.create(username="pete", age=10, assignable=False)
928
929 new_issue=self.db.issue.create(title="title", deadline=date.Date('2016-6-30.22:39'))
930
931 # change all quiet params. Verify they aren't returned in CreateNote.
932 result=self.db.issue.set(new_issue, title="title2", deadline=date.Date('2016-6-30.22:39'),
933 assignedto="2", nosy=["3", "2"])
934 result=self.db.issue.generateCreateNote(new_issue)
935 self.assertEqual(result, '\n----------\ntitle: title2')
936
937 # also test that we can make a property noisy
938 self.db.issue.properties['nosy'].quiet=False
939 self.db.issue.properties['deadline'].quiet=False
940 result=self.db.issue.set(new_issue, title="title2", deadline=date.Date('2016-7-13.22:39'),
941 assignedto="2", nosy=["1", "2"])
942 result=self.db.issue.generateCreateNote(new_issue)
943 self.assertEqual(result, '\n----------\ndeadline: 2016-07-13.22:39:00\nnosy: admin, fred\ntitle: title2')
944 self.db.issue.properties['nosy'].quiet=True
945 self.db.issue.properties['deadline'].quiet=True
946
947 def testQuietJournal(self):
948 # FIXME this doesn't work. I need to call
949 # template.py::_HTMLItem::history() and verify the output.
950 # not sure how to get there from here. -- rouilj
951 # make sure that the quiet properties: "assignable" and "age" are not
952 # returned as part of the journal
953 # so comment out tests here but leave framework for later.
954 new_user=self.db.user.create(username="pete", age=10, assignable=False)
955 new_issue=self.db.issue.create(title="title", deadline=date.Date('2016-6-30.22:39'))
956
957 # change all quiet params. Verify they aren't returned in journal.
958 # between this and the issue class every type represented in hyperdb
959 # should be initalized with a quiet parameter.
960 result=self.db.user.set(new_user, username="new", age=20, supervisor='3', assignable=True,
961 password=password.Password("3456"), rating=4, realname="newname")
962 result=self.db.user.history(new_user)
963 #self.assertEqual(result, 20)
964
965 # change all quiet params. Verify they aren't returned in object.
966 result=self.db.issue.set(new_issue, title="title2", deadline=date.Date('2016-6-30.22:39'),
967 assignedto="2", nosy=["3", "2"])
968 result=self.db.issue.generateCreateNote(new_issue)
969 #self.assertEqual(result, '\n----------\ntitle: title2')
970
971 # also test that we can make a property noisy
972 self.db.issue.properties['nosy'].quiet=False
973 self.db.issue.properties['deadline'].quiet=False
974 result=self.db.issue.set(new_issue, title="title2", deadline=date.Date('2016-7-13.22:39'),
975 assignedto="2", nosy=["1", "2"])
976 result=self.db.issue.generateCreateNote(new_issue)
977 #self.assertEqual(result, '\n----------\ndeadline: 2016-07-13.22:39:00\nnosy: admin, fred\ntitle: title2')
978 self.db.issue.properties['nosy'].quiet=True
979 self.db.issue.properties['deadline'].quiet=True
880 980
881 def testJournals(self): 981 def testJournals(self):
882 muid = self.db.user.create(username="mary") 982 muid = self.db.user.create(username="mary")
883 self.db.user.create(username="pete") 983 self.db.user.create(username="pete")
884 self.db.issue.create(title="spam", status='1') 984 self.db.issue.create(title="spam", status='1')

Roundup Issue Tracker: http://roundup-tracker.org/