[Zope3-checkins] CVS: Products3/bugtracker/browser/tests - test_bug.py:1.1

Stephan Richter srichter@cosmos.phy.tufts.edu
Mon, 28 Jul 2003 16:38:41 -0400


Update of /cvs-repository/Products3/bugtracker/browser/tests
In directory cvs.zope.org:/tmp/cvs-serv13012/browser/tests

Added Files:
	test_bug.py 
Log Message:
More tests in the browser code.


=== Added File Products3/bugtracker/browser/tests/test_bug.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Bug Tracker Mail Subscription and Mailer Tests

$Id: test_bug.py,v 1.1 2003/07/28 20:38:37 srichter Exp $
"""
import unittest

from zope.publisher.browser import TestRequest
from zopeproducts.bugtracker.browser.bug import BugBaseView, Overview
from zopeproducts.bugtracker.tests.placelesssetup import PlacelessSetup

class BugBaseViewTest(PlacelessSetup, unittest.TestCase):

    def setUp(self):
        PlacelessSetup.setUp(self)
        self.view = BugBaseView()
        self.view.context = self.generateBug()
        self.view.request = TestRequest()

    def test_created(self):
        self.assertEqual(self.view.created(), '3/3/03 3:00 AM ')

    def test_modified(self):
        self.assertEqual(self.view.modified(), '3/3/03 4:00 AM ')

    def test_description(self):
        self.assertEqual(self.view.description(), '<p>This is Bug 1.</p>\n')

    def test_status(self):
        self.assertEqual(self.view.status().value, 'new')
        self.assertEqual(self.view.status().title, 'New')

    def test_type(self):
        self.assertEqual(self.view.type().value, 'bug')
        self.assertEqual(self.view.type().title, 'Bug')

    def test_priority(self):
        self.assertEqual(self.view.priority().value, 'normal')
        self.assertEqual(self.view.priority().title, 'Normal')

    def test_release(self):
        self.assertEqual(self.view.release().value, 'None')
        self.assertEqual(self.view.release().title, '(not specified)')

    def test_owners(self):
        self.assertEqual(self.view.owners()[0].principal['login'], 'jim')
        self.assertEqual(self.view.owners()[0].principal['title'], 'Jim Fulton')
        self.assertEqual(self.view.owners()[1].principal['login'], 'stevea')
        self.assertEqual(self.view.owners()[1].principal['title'],
                         'Steve Alexander')


class OverviewTest(PlacelessSetup, unittest.TestCase):

    def setUp(self):
        PlacelessSetup.setUp(self)
        self.view = Overview()
        self.view.context = self.generateBug()
        self.view.request = TestRequest()

    def test_comments(self):
        comments = self.view.comments()
        self.assertEqual(comments[0].creator(), 'srichter')
        self.assertEqual(comments[0].modified(), '3/3/03 6:00 AM ')
        self.assertEqual(comments[0].body(), '<p>This is comment 1.</p>\n')

    def test_attachments(self):
        attachments = self.view.attachments()
        self.assertEqual(attachments[0]['name'], 'attach.txt')
        self.assertEqual(attachments[0]['size'], '1 KB')

    def test_dependencies(self):
        self.assertEqual(self.view.dependencies(), ())


def test_suite():
    return unittest.TestSuite((
        unittest.makeSuite(BugBaseViewTest),
        unittest.makeSuite(OverviewTest),
        ))

if __name__ == '__main__':
    unittest.main()