annotate test/tx_Source_detector.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 6e9b9743de89
children 64b05e24dbd8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4781
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
1 #
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
2 # Example output when the web interface changes item 3 and the email
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
3 # (non pgp) interface changes item 4:
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
4 #
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
5 # tx_SourceCheckAudit(3) pre db.tx_Source: cgi
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
6 # tx_SourceCheckAudit(4) pre db.tx_Source: email
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
7 # tx_SourceCheckAudit(3) post db.tx_Source: cgi
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
8 # tx_SourceCheckAudit(4) post db.tx_Source: email
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
9 # tx_SourceCheckReact(4) pre db.tx_Source: email
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
10 # tx_SourceCheckReact(4) post db.tx_Source: email
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
11 # tx_SourceCheckReact(3) pre db.tx_Source: cgi
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
12 # tx_SourceCheckReact(3) post db.tx_Source: cgi
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
13 #
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
14 # Note that the calls are interleaved, but the proper
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
15 # tx_Source is associated with the same ticket.
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
16
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
17 import time as time
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
18
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
19 def tx_SourceCheckAudit(db, cl, nodeid, newvalues):
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
20 ''' An auditor to print the value of the source of the
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
21 transaction that trigger this change. The sleep call
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
22 is used to delay the transaction so that multiple changes will
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
23 overlap. The expected output from this detector are 2 lines
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
24 with the same value for tx_Source. Tx source is:
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
25 None - Reported when using a script or it is an error if
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
26 the change arrives by another method.
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
27 "cli" - reported when using roundup-admin
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
28 "web" - reported when using any web based technique
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
29 "email" - reported when using an unautheticated email based technique
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
30 "email-sig-openpgp" - reported when email with a valid pgp
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
31 signature is used
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
32 '''
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
33 if __debug__ and False:
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
34 print "\n tx_SourceCheckAudit(%s) db.tx_Source: %s"%(nodeid, db.tx_Source)
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
35
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
36 newvalues['tx_Source'] = db.tx_Source
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
37
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
38 # example use for real to prevent a change from happening if it's
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
39 # submited via email
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
40 #
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
41 # if db.tx_Source == "email":
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
42 # raise Reject, 'Change not allowed via email'
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
43
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
44 def tx_SourceCheckReact(db, cl, nodeid, oldvalues):
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
45 ''' An reactor to print the value of the source of the
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
46 transaction that trigger this change. The sleep call
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
47 is used to delay the transaction so that multiple changes will
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
48 overlap. The expected output from this detector are 2 lines
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
49 with the same value for tx_Source. Tx source is:
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
50 None - Reported when using a script or it is an error if
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
51 the change arrives by another method.
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
52 "cli" - reported when using roundup-admin
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
53 "web" - reported when using any web based technique
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
54 "email" - reported when using an unautheticated email based technique
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
55 "email-sig-openpgp" - reported when email with a valid pgp
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
56 signature is used
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
57 '''
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
58
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
59 if __debug__ and False:
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
60 print " tx_SourceCheckReact(%s) db.tx_Source: %s"%(nodeid, db.tx_Source)
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
61
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
62
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
63
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
64 def init(db):
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
65 db.issue.audit('create', tx_SourceCheckAudit)
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
66 db.issue.audit('set', tx_SourceCheckAudit)
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
67
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
68 db.issue.react('set', tx_SourceCheckReact)
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
69 db.issue.react('create', tx_SourceCheckReact)
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
70
6e9b9743de89 Implementation for:
John Rouillard <rouilj@ieee.org>
parents:
diff changeset
71 db.msg.audit('create', tx_SourceCheckAudit)

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