Edgewall Software
Modify

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#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 TestTicketHistory functional test case to check that visibility of buttons and sections on the ticket page is dependent on whether a version of the ticket is specified.

API Changes:

The test utility function random_sentence includes a uuid fragment for uniqueness, and a defect was fixed in random_unique_camel whereby single letter words would be used to form the output and the resulting word would not be camelcase (e.g. CamelW).

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 olemis+trac@…, 11 years ago

Cc: olemis+trac@… added

comment:2 by Ryan J Ollos, 11 years ago

Proposed changes in rjollos.git:t11273.

comment:3 by Ryan J Ollos, 11 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: newclosed

Committed to 1.0-stable in [11941:11942] and merged to trunk in [11943].

comment:4 by Christian Boos, 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>
...

comment:5 by Ryan J Ollos, 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 to random_sentence.
  • Call random_sentence with min_word_count=5 in FunctionalTester.add_comment.
  • Run tests several dozen times locally to verify these changes before committing ;)

in reply to:  5 ; comment:6 by Christian Boos, 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.

in reply to:  6 ; comment:7 by Ryan J Ollos, 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  
    1212# history and logs, available at http://trac.edgewall.org/log/.
    1313
    1414import random
    15 
     15import uuid
    1616
    1717try:
    1818    all_words = [x.strip() for x in open('/usr/share/dict/words').readlines() i
    except Exception:  
    3030        'ten',
    3131    ]
    3232
     33
    3334def random_word():
    3435    word = random.choice(all_words)
    3536    # Do not return CamelCase words
    def random_sentence(word_count=None):  
    5152    if word_count == None:
    5253        word_count = random.randint(1, 20)
    5354    words = [random_word() for x in range(word_count)]
     55    words += str(uuid.uuid1())
    5456    return '%s.' % ' '.join(words)
    5557
    5658def 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].

in reply to:  7 ; comment:8 by Christian Boos, 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).

in reply to:  8 comment:9 by Ryan J Ollos, 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 Ryan J Ollos, 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 Ryan J Ollos, 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 Ryan J Ollos, 11 years ago

Changes in rjollos.git:t11273.3 committed to 1.0-stable in [11966:11967] and merged to trunk in [11968].

Last edited 11 years ago by Ryan J Ollos (previous) (diff)

comment:13 by Ryan J Ollos, 11 years ago

API Changes: modified (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.