~vcs-imports/bts-lin/trunk

« back to all changes in this revision

Viewing changes to remote/tests/test_trac.py

  • Committer: Pierre Habouzit
  • Date: 2008-07-21 06:22:39 UTC
  • mfrom: (213.1.6)
  • Revision ID: git-v1:e761b3ccd37febd7ff65835d59706e21e49566f0
Merge commit 'jv/master'

Conflicts:

        remote/launchpad.py

Signed-off-by: Pierre Habouzit <madcoder@debian.org>

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim:set encoding=utf-8:
 
2
###############################################################################
 
3
# Copyright:
 
4
#   © 2008 Jelmer Vernooij <jelmer@samba.org>
 
5
#
 
6
# Redistribution and use in source and binary forms, with or without
 
7
# modification, are permitted provided that the following conditions
 
8
# are met:
 
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
 
16
#    permission.
 
17
 
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
###############################################################################
 
29
 
 
30
from cStringIO import StringIO
 
31
from remote.trac import TracTicket
 
32
from remote import *
 
33
from unittest import TestCase
 
34
 
 
35
 
 
36
class TestTracTicket(TestCase):
 
37
    def parse(self, text):
 
38
        return TracTicket(text)
 
39
 
 
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")
 
53
 
 
54
    def test_fromhtml(self):
 
55
        ticket = self.parse("""
 
56
        <html><body>
 
57
        <span class="status"><strong>(closed fixed)<strong></span>
 
58
        </body></html>
 
59
""")
 
60
        self.assertEquals("closed", ticket.status)
 
61
        self.assertEquals("fixed", ticket.resolution)
 
62
 
 
63
 
 
64
    def test_fromhtml_noresolution(self):
 
65
        ticket = self.parse("""
 
66
        <html><body>
 
67
        <span class="status"><strong>open<strong></span>
 
68
        </body></html>
 
69
""")
 
70
        self.assertEquals("open", ticket.status)
 
71
        self.assertEquals(None, ticket.resolution)
 
72