#11273 closed enhancement (fixed)
Extended TestTicketHistory functional test case
Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.2 |
Component: | ticket system | Version: | 1.0-stable |
Severity: | normal | Keywords: | functional test |
Cc: | olemis+trac@… | Branch: | |
Release Notes: |
Extended |
||
API Changes: |
The test utility function |
||
Internal Changes: |
Description
When viewing a version of a page (e.g. ticket/9595) the #propertyform
form and the #modify
link are hidden. The TestTicketHistory functional test case will be extended to these behaviors.
Attachments (0)
Change History (13)
comment:1 by , 11 years ago
Cc: | added |
---|
comment:2 by , 11 years ago
comment:3 by , 11 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Committed to 1.0-stable in [11941:11942] and merged to trunk in [11943].
comment:4 by , 11 years ago
Not entirely sure if this was due to r11941 or if the problem could have happened before, but I had a one-time failure in that test:
====================================================================== FAIL: runTest (trac.ticket.tests.functional.TestTicketHistory) Test ticket history ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/cboos/trac/1.0-stable/trac/ticket/tests/functional.py", line 178, in runTest tc.notfind(comment) File "/home/cboos/trac/1.0-stable/trac/tests/functional/better_twill.py", line 224, in better_notfind raise twill.errors.TwillAssertionError(*args) TwillAssertionError: ("match to 'one.'", '/home/cboos/trac/1.0-stable/testenv/trac/log/TestTicketHistory.html', '/home/cboos/trac/1.0-stable/testenv/trac/log/TestTicketHistory.html')
Of course 'one.'
is too short and was already present several time elsewhere in the page. For example, the ticket description (as seen in TestTicketHistory.html
) contained:
<p> one three seven.<br /> </p> <p> five five three ten two four six one.<br /> </p> ...
follow-up: 6 comment:5 by , 11 years ago
It looks like it was due to the refactoring I did in [11941]. Previously the random sentence would have 5 words, now it has a random number of words.
In general, I think it would be best for FunctionalTester.add_comment
to generate a comment with at least 5 words. So I propose:
- Add a
min_word_count
keyword argument torandom_sentence
. - Call
random_sentence
withmin_word_count=5
inFunctionalTester.add_comment
. - Run tests several dozen times locally to verify these changes before committing ;)
follow-up: 7 comment:6 by , 11 years ago
Replying to rjollos:
- Run tests several dozen times locally to verify these changes before committing ;)
Well, to be really safe, we should probably add a unique id of some sort to the random content (in general). A timestamp would probably not be enough in case we add two comments in sequence, but using module uuid
(new in Python 2.5) would be fine for Trac 1.0.
follow-up: 8 comment:7 by , 11 years ago
Replying to cboos:
Well, to be really safe, we should probably add a unique id of some sort to the random content (in general). A timestamp would probably not be enough in case we add two comments in sequence, but using module
uuid
(new in Python 2.5) would be fine for Trac 1.0.
I see now that this appears on Windows due to the fallback of not having a dictionary to import.
Did you have in mind a very simple change such as this?
-
trac/tests/contentgen.py
diff --git a/trac/tests/contentgen.py b/trac/tests/contentgen.py index 434e33a..509846d 100644
a b 12 12 # history and logs, available at http://trac.edgewall.org/log/. 13 13 14 14 import random 15 15 import uuid 16 16 17 17 try: 18 18 all_words = [x.strip() for x in open('/usr/share/dict/words').readlines() i … … except Exception: 30 30 'ten', 31 31 ] 32 32 33 33 34 def random_word(): 34 35 word = random.choice(all_words) 35 36 # Do not return CamelCase words … … def random_sentence(word_count=None): 51 52 if word_count == None: 52 53 word_count = random.randint(1, 20) 53 54 words = [random_word() for x in range(word_count)] 55 words += str(uuid.uuid1()) 54 56 return '%s.' % ' '.join(words) 55 57 56 58 def random_paragraph(sentence_count=None):
Those changes are prepare in rjollos.git:t11273.2. I had to make a minor change to TestTimelineTicketDetails
to avoid dealing with shortening the summary of the expected result: [92287cb3/rjollos.git].
follow-up: 9 comment:8 by , 11 years ago
Replying to rjollos:
Replying to cboos:
Well, to be really safe, we should probably add a unique id of some sort to the random content (in general). A timestamp would probably not be enough in case we add two comments in sequence, but using module
uuid
(new in Python 2.5) would be fine for Trac 1.0.I see now that this appears on Windows due to the fallback of not having a dictionary to import.
Ah right, well spotted.
Did you have in mind a very simple change such as this?
Yes.
Those changes are prepare in rjollos.git:t11273.2. I had to make a minor change to
TestTimelineTicketDetails
to avoid dealing with shortening the summary of the expected result: [92287cb3/rjollos.git].
And what if supercalifragilisticexpialidocious is part of your dictionary?
If the uuid would be prepended instead of appended, one could deal with truncation more easily, as one could use startswith
(or similar when regexps are involved).
comment:9 by , 11 years ago
Replying to cboos:
And what if supercalifragilisticexpialidocious is part of your dictionary?
If the uuid would be prepended instead of appended, one could deal with truncation more easily, as one could use
startswith
(or similar when regexps are involved).
That sounds good. I'll plan to modify the function such that the first word in the sentence is a uuid, and then wordcount-1
additional words from the dictionary are added.
comment:10 by , 11 years ago
I had a test case failure today while running the whole suite against the work in #11069, and the issue seems related to the discussion we've had here.
====================================================================== FAIL: Test custom textarea field with no format explicitly specified, ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/user/Workspace/t11069/teo-rjollos.git/trac/ticket/tests/functional.py", line 349, in runTest tc.find('<td headers="h_newfield"[^>]*>\s*%s\s*</td>' % wiki) File "/home/user/Workspace/t11069/teo-rjollos.git/trac/tests/functional/better_twill.py", line 216, in better_find raise twill.errors.TwillAssertionError(*args) TwillAssertionError: ('no match to \'<td headers="h_newfield"[^>]*>\\s*<p>\\s*<a [^>]*>OvertaxingM\\??</a> eschewed<br />\\s*</p>\\s*</td>\'', '/home/user/Workspace/t11069/teo-rjollos.git/testenv/trac/log/TestTicketCustomFieldTextAreaWikiFormat.html') ---------------------------------------------------------------------- Ran 1337 tests in 234.683s FAILED (failures=1)
A camelcase word was expected in the output, but OvertaxingM was generated. At least from the dictionary on Ubunutu 13.04, single letter "words" can be generated.
>>> from trac.tests import contentgen >>> words = sorted(contentgen.all_words) >>> for w in words: >>> if len(w) == 1: >>> print w A B C D ...
I think the solution is to add a min_length
parameter to random_word
, and modify random_unique_camel
to call random_word(2).
comment:11 by , 11 years ago
A new set of changes to address comment:4 and comment:10 have been prepared in rjollos.git:t11273.3.
comment:12 by , 11 years ago
Changes in rjollos.git:t11273.3 committed to 1.0-stable in [11966:11967] and merged to trunk in [11968].
comment:13 by , 11 years ago
API Changes: | modified (diff) |
---|
Proposed changes in rjollos.git:t11273.