1
# vim:set encoding=utf-8:
2
###############################################################################
4
# © 2008 Jelmer Vernooij <jelmer@samba.org>
6
# Redistribution and use in source and binary forms, with or without
7
# modification, are permitted provided that the following conditions
9
# 1. Redistributions of source code must retain the above copyright
10
# notice, this list of conditions and the following disclaimer.
11
# 2. Redistributions in binary form must reproduce the above copyright
12
# notice, this list of conditions and the following disclaimer in the
13
# documentation and/or other materials provided with the distribution.
14
# 3. The names of its contributors may not be used to endorse or promote
15
# products derived from this software without specific prior written
18
# THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
19
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
21
# EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
###############################################################################
30
from cStringIO import StringIO
31
from remote.trac import TracTicket
33
from unittest import TestCase
36
class TestTracTicket(TestCase):
37
def parse(self, text):
38
return TracTicket(text)
40
def test_tabformat(self):
41
ticket = self.parse("""id\tsummary\treporter\towner\tdescription\ttype\tstatus\tpriority\tmilestone\tcomponent\tversion\tresolution\tkeywords\tcc
42
42\tWe should not foo\tanonymous\tsomebody\tThis is a long description\\r\\nAnd it includes whitespace stuff.\tdefect\tclosed\tnormal\t3.0.2\tcore\t3.0\tfixed\t\t""")
43
self.assertEquals(ticket.id, 42)
44
self.assertEquals(ticket.summary, "We should not foo")
45
self.assertEquals(ticket.milestone, "3.0.2")
46
self.assertEquals(ticket.version, "3.0")
47
self.assertEquals(ticket.reporter, "anonymous")
48
self.assertEquals(ticket.owner, "somebody")
49
self.assertEquals(ticket.description, "This is a long description\r\n" +
50
"And it includes whitespace stuff.")
51
self.assertEquals(ticket.status, "closed")
52
self.assertEquals(ticket.priority, "normal")
54
def test_fromhtml(self):
55
ticket = self.parse("""
57
<span class="status"><strong>(closed fixed)<strong></span>
60
self.assertEquals("closed", ticket.status)
61
self.assertEquals("fixed", ticket.resolution)
64
def test_fromhtml_noresolution(self):
65
ticket = self.parse("""
67
<span class="status"><strong>open<strong></span>
70
self.assertEquals("open", ticket.status)
71
self.assertEquals(None, ticket.resolution)