Changeset 6297 for main/waeup.sirp/trunk


Ignore:
Timestamp:
8 Jun 2011, 00:14:45 (13 years ago)
Author:
uli
Message:

Fix testing problems simply by turning basic unittests into functional
ones.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_applicants.py

    r6288 r6297  
    2222"""Tests for applicants and related.
    2323"""
    24 import logging
    2524import unittest
    26 from StringIO import StringIO
    27 from hurry.file.file import IdFileRetrieval
    28 from hurry.file.interfaces import IFileRetrieval
    29 from zope.app.testing import placelesssetup
     25from zope.app.testing.functional import FunctionalTestCase
    3026from zope.component import (
    3127    provideAdapter, adapts, getGlobalSiteManager, provideUtility)
     
    3531from zope.publisher.base import TestRequest
    3632from zope.publisher.interfaces import NotFound
    37 from waeup.sirp.interfaces import IWAeUPSIRPPluggable
    3833from waeup.sirp.image.image import WAeUPImageFile
    3934from waeup.sirp.image.interfaces import IWAeUPImageFile
     
    4439    IResultEntry, IApplicant,
    4540    )
     41from waeup.sirp.testing import FunctionalLayer
    4642
    4743class FakeImageLocation(object):
     
    6965        assert entry.score == 3.7
    7066
    71 class ApplicantTest(unittest.TestCase):
     67class ApplicantTest(FunctionalTestCase):
     68
     69    layer = FunctionalLayer
    7270
    7371    def setUp(self):
    74         placelesssetup.setUp()
    75         provideUtility(IdFileRetrieval(), IFileRetrieval)
    7672        self.applicant = Applicant()
    7773
    7874    def tearDown(self):
    79         placelesssetup.tearDown()
    8075        pass
    8176
     
    8479        verify.verifyObject(IApplicant, self.applicant)
    8580
    86 class ApplicantFactoryTest(unittest.TestCase):
     81class ApplicantFactoryTest(FunctionalTestCase):
     82
     83    layer = FunctionalLayer
    8784
    8885    def setUp(self):
     
    104101        assert implemented_by.isOrExtends(IApplicant)
    105102
    106 class ApplicantTraverserTest(unittest.TestCase):
     103
     104class ApplicantTraverserTest(FunctionalTestCase):
     105
     106    layer = FunctionalLayer
    107107
    108108    def setUp(self):
     109        super(ApplicantTraverserTest, self).setUp()
     110        provideAdapter(FakeImageLocation)
    109111        self.applicant = Applicant()
     112
    110113        self.request = TestRequest('')
    111         self.gsm = getGlobalSiteManager()
    112         self.gsm.registerAdapter(FakeImageLocation)
    113         self.fileretrieval = IdFileRetrieval()
    114         provideUtility(self.fileretrieval, IFileRetrieval)
    115114        return
    116115
    117116    def tearDown(self):
    118         self.gsm.unregisterAdapter(FakeImageLocation)
    119         self.gsm.unregisterUtility(self.fileretrieval, IFileRetrieval)
     117        gsm = getGlobalSiteManager()
     118        gsm.unregisterAdapter(FakeImageLocation)
     119        super(ApplicantTraverserTest, self).tearDown()
    120120        return
    121121
     
    162162        self.assertTrue(isinstance(result, FakeImageLocation))
    163163        return
    164 
    165 def test_suite():
    166     suite = unittest.TestSuite()
    167     for testcase in [
    168         ResultEntryTest, ApplicantTest, ApplicantFactoryTest,
    169         ApplicantTraverserTest,
    170         ]:
    171         suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
    172                 testcase
    173                 )
    174         )
    175     return suite
Note: See TracChangeset for help on using the changeset viewer.