Changeset 5676 for main/waeup.sirp/trunk/src/waeup/sirp/applicants
- Timestamp:
- 25 Jan 2011, 13:21:00 (14 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/applicants
- Files:
-
- 6 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/__init__.py
r5637 r5676 1 """This package contains everything regarding student applications.1 """This package contains everything regarding university applicants. 2 2 """ 3 3 # Make this a package. -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/container.py
r5650 r5676 21 21 ## 22 22 """ 23 Containers for student applications.23 Containers for university applicants. 24 24 """ 25 25 import grok 26 from waeup.sirp.applica tions.interfaces import IApplicationContainer26 from waeup.sirp.applicants.interfaces import IApplicantsContainer 27 27 28 class Applica tionContainer(grok.Container):29 """An applica tion container contains student applications.28 class ApplicantsContainer(grok.Container): 29 """An applicants container contains university applicants. 30 30 """ 31 grok.implements(IApplica tionContainer)31 grok.implements(IApplicantsContainer) 32 32 33 33 id = None … … 39 39 40 40 def archive(self, app_ids=None): 41 """Create on-dist archive of applica tions stored in this term.41 """Create on-dist archive of applicants stored in this term. 42 42 43 If app_ids is `None`, all applica tions are archived.43 If app_ids is `None`, all applicants are archived. 44 44 45 45 If app_ids contains a single id string, only the respective 46 applica tions are archived.46 applicants are archived. 47 47 48 48 If app_ids contains a list of id strings all of the respective 49 applica tiontypes are saved to disk.49 applicants types are saved to disk. 50 50 """ 51 51 raise NotImplemented() 52 52 53 53 def clear(self, app_ids=None, archive=True): 54 """Remove applica tions of type given by 'id'.54 """Remove applicants of type given by 'id'. 55 55 56 Optionally archive the applica tions.56 Optionally archive the applicants. 57 57 58 If id is `None`, all applica tions are archived.58 If id is `None`, all applicants are archived. 59 59 60 60 If id contains a single id string, only the respective 61 applica tions are archived.61 applicants are archived. 62 62 63 63 If id contains a list of id strings all of the respective 64 applica tiontypes are saved to disk.64 applicant types are saved to disk. 65 65 66 66 If `archive` is ``False`` none of the archive-handling is done 67 and respective applica tions are simply removed from the67 and respective applicants are simply removed from the 68 68 database. 69 69 """ -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py
r5645 r5676 20 20 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 21 ## 22 """Interfaces regarding student applica tions and related components.22 """Interfaces regarding student applicants and related components. 23 23 """ 24 24 from zope import schema 25 25 from waeup.sirp.interfaces import IWAeUPObject 26 26 27 class IApplica tionsRoot(IWAeUPObject):28 """A container for student applicationcontainers.27 class IApplicantsRoot(IWAeUPObject): 28 """A container for university applicants containers. 29 29 """ 30 def addApplica tionContainer(container, name=None):31 """Add an applica tioncontainer.30 def addApplicantsContainer(container, name=None): 31 """Add an applicants container. 32 32 33 Adds an applica tioncontainer that implements `interface`33 Adds an applicants container that implements `interface` 34 34 under the name `name`. 35 35 36 36 `container` the container instance to be added. Should 37 implement :class:`IApplica tionContainer`.37 implement :class:`IApplicantsContainer`. 38 38 39 39 `name` 40 40 the name under which the container will be accessible. We 41 41 usually use names like ``pume_2011`` to indicate, that the 42 new container will contain student applications for a42 new container will contain university applicants for a 43 43 certain screening type (``pume``) and of the year 2011. 44 44 """ 45 45 46 class IApplica tionContainer(IWAeUPObject):47 """An applica tion container contains student applications.46 class IApplicantsContainer(IWAeUPObject): 47 """An applicants container contains university applicants. 48 48 49 49 """ … … 54 54 55 55 title = schema.TextLine( 56 title = u'Short description of the type of applica tions stored here.',56 title = u'Short description of the type of applicants stored here.', 57 57 required = True, 58 58 default = u'Untitled', … … 84 84 85 85 def archive(id=None): 86 """Create on-dist archive of applica tions stored in this term.86 """Create on-dist archive of applicants stored in this term. 87 87 88 If id is `None`, all applica tions are archived.88 If id is `None`, all applicants are archived. 89 89 90 90 If id contains a single id string, only the respective 91 applica tions are archived.91 applicants are archived. 92 92 93 93 If id contains a list of id strings all of the respective 94 applica tiontypes are saved to disk.94 applicants types are saved to disk. 95 95 """ 96 96 97 97 def clear(id=None, archive=True): 98 """Remove applica tions of type given by 'id'.98 """Remove applicants of type given by 'id'. 99 99 100 Optionally archive the applica tions.100 Optionally archive the applicants. 101 101 102 If id is `None`, all applica tions are archived.102 If id is `None`, all applicants are archived. 103 103 104 104 If id contains a single id string, only the respective 105 applica tions are archived.105 applicants are archived. 106 106 107 107 If id contains a list of id strings all of the respective 108 applica tiontypes are saved to disk.108 applicant types are saved to disk. 109 109 110 110 If `archive` is ``False`` none of the archive-handling is done 111 and respective applica tions are simply removed from the111 and respective applicants are simply removed from the 112 112 database. 113 113 """ -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/root.py
r5670 r5676 21 21 ## 22 22 """ 23 The root for applica tions.23 The root for applicants. 24 24 """ 25 25 import grok 26 26 from waeup.sirp.interfaces import IWAeUPSIRPPluggable 27 from waeup.sirp.applica tions.interfaces import IApplicationsRoot27 from waeup.sirp.applicants.interfaces import IApplicantsRoot 28 28 29 class ApplicationsRoot(grok.Container): 30 """The root of student applications-related components. 29 class ApplicantsRoot(grok.Container): 30 """The root of applicants-related components. It contains primarily 31 containers for applicants. 31 32 """ 32 grok.implements(IApplica tionsRoot)33 grok.implements(IApplicantsRoot) 33 34 34 def addApplica tionContainer(self, container, name=None):35 """Add an applica tioncontainer.35 def addApplicantsContainer(self, container, name=None): 36 """Add an applicants container. 36 37 37 Adds an applica tioncontainer that implements `interface`38 Adds an applicants container that implements `interface` 38 39 under the name `name`. 39 40 40 41 `container` 41 42 the container instance to be added. Should 42 implement :class:`IApplica tionContainer`.43 implement :class:`IApplicantsContainer`. 43 44 44 45 `name` 45 46 the name under which the container will be accessible. We 46 47 usually use names like ``pume_2011`` to indicate, that the 47 new container will contain student applica tions for a48 new container will contain student applicants for a 48 49 certain screening type (``pume``) and of the year 2011. 49 50 … … 52 53 return 53 54 54 class Applica tionsPlugin(grok.GlobalUtility):55 """A WAeUPSIRPPlugin that creates an applica tions root in portal.55 class ApplicantsPlugin(grok.GlobalUtility): 56 """A WAeUPSIRPPlugin that creates an applicants root in portal. 56 57 57 58 This plugin should be called by a typical … … 62 63 Implements :class:`waeup.sirp.interfaces.IWAeUPSIRPPluggable` 63 64 """ 64 grok.name('applica tions')65 grok.name('applicants') 65 66 grok.implements(IWAeUPSIRPPluggable) 66 log_prefix = 'Applica tionsPlugin'67 log_prefix = 'ApplicantsPlugin' 67 68 68 69 def setup(self, site, name, logger): 69 """Create a new :class:`Applica tionsRoot` instance in `site`.70 """Create a new :class:`ApplicantsRoot` instance in `site`. 70 71 """ 71 site['applica tions'] = ApplicationsRoot()72 site['applicants'] = ApplicantsRoot() 72 73 logger.info( 73 '%s: Installed applica tions root.' % (self.log_prefix,)74 '%s: Installed applicants root.' % (self.log_prefix,) 74 75 ) 75 76 return 76 77 77 78 def update(self, site, name, logger): 78 """Update site wide ``applica tions`` root.79 """Update site wide ``applicants`` root. 79 80 80 If the site already contains a suitable ``applica tions`` root,81 If the site already contains a suitable ``applicants`` root, 81 82 leave it that way. If not create one and delete the old one if 82 83 appropriate. 83 84 """ 84 app_folder = site.get('applica tions', None)85 app_folder = site.get('applicants', None) 85 86 site_name = getattr(site, '__name__', 'Unnamed Site?') 86 if IApplica tionsRoot.providedBy(app_folder):87 # Applica tions up to date. Return.87 if IApplicantsRoot.providedBy(app_folder): 88 # Applicants up to date. Return. 88 89 logger.info( 89 90 '%s: Updating site at %s: Nothing to do.' % ( … … 92 93 return 93 94 elif app_folder is not None: 94 # Applica tions need update. Remove old instance.95 # Applicants need update. Remove old instance. 95 96 logger.warn( 96 '%s: Outdated applica tions folder detected at site %s.'97 '%s: Outdated applicants folder detected at site %s.' 97 98 'Removing it.' % (self.log_prefix, site_name) 98 99 ) 99 del site['applica tions']100 # Add new applica tions.100 del site['applicants'] 101 # Add new applicants. 101 102 logger.info( 102 103 '%s: Updating site at %s. Installing ' 103 'applica tions.' % (self.log_prefix, site_name,)104 'applicants.' % (self.log_prefix, site_name,) 104 105 ) 105 106 self.setup(site, name, logger) -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_container.py
r5647 r5676 21 21 ## 22 22 """ 23 Tests for applica tioncontainers.23 Tests for applicants containers. 24 24 """ 25 25 import unittest 26 26 from zope.interface.verify import verifyClass, verifyObject 27 from waeup.sirp.applica tions import interfaces28 from waeup.sirp.applica tions.container import ApplicationContainer27 from waeup.sirp.applicants import interfaces 28 from waeup.sirp.applicants.container import ApplicantsContainer 29 29 30 class Applica tionContainerTestCase(unittest.TestCase):30 class ApplicantsContainerTestCase(unittest.TestCase): 31 31 32 32 def test_interfaces(self): … … 34 34 self.assertTrue( 35 35 verifyClass( 36 interfaces.IApplica tionContainer, ApplicationContainer)36 interfaces.IApplicantsContainer, ApplicantsContainer) 37 37 ) 38 38 self.assertTrue( 39 39 verifyObject( 40 interfaces.IApplica tionContainer, ApplicationContainer())40 interfaces.IApplicantsContainer, ApplicantsContainer()) 41 41 ) 42 42 return … … 46 46 suite.addTests( 47 47 unittest.TestLoader().loadTestsFromTestCase( 48 Applica tionContainerTestCase,48 ApplicantsContainerTestCase, 49 49 ) 50 50 ) -
main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_root.py
r5659 r5676 21 21 ## 22 22 """ 23 Test applica tions root.23 Test applicants root. 24 24 """ 25 25 import logging … … 27 27 from StringIO import StringIO 28 28 from zope.interface.verify import verifyClass, verifyObject 29 from waeup.sirp.applica tions import interfaces30 from waeup.sirp.applica tions.root import (31 Applica tionsRoot, ApplicationsPlugin,29 from waeup.sirp.applicants import interfaces 30 from waeup.sirp.applicants.root import ( 31 ApplicantsRoot, ApplicantsPlugin, 32 32 ) 33 33 … … 35 35 pass 36 36 37 class Applica tionsRootTestCase(unittest.TestCase):37 class ApplicantsRootTestCase(unittest.TestCase): 38 38 39 39 def test_interfaces(self): … … 41 41 self.assertTrue( 42 42 verifyClass( 43 interfaces.IApplica tionsRoot, ApplicationsRoot)43 interfaces.IApplicantsRoot, ApplicantsRoot) 44 44 ) 45 45 self.assertTrue( 46 46 verifyObject( 47 interfaces.IApplica tionsRoot, ApplicationsRoot())47 interfaces.IApplicantsRoot, ApplicantsRoot()) 48 48 ) 49 49 return 50 50 51 class Applica tionsRootPluginTestCase(unittest.TestCase):51 class ApplicantsRootPluginTestCase(unittest.TestCase): 52 52 def create_logger(self): 53 53 # create a logger suitable for local tests. 54 test_logger = logging.getLogger('waeup.sirp.applica tions.testlogger')54 test_logger = logging.getLogger('waeup.sirp.applicants.testlogger') 55 55 log = StringIO() 56 56 handler = logging.StreamHandler(log) … … 83 83 # Real tests start here... 84 84 def test_pluginsetup(self): 85 # Make sure we can add Applica tionsRoot to sites.85 # Make sure we can add ApplicantsRoot to sites. 86 86 site = FakeSite() 87 plugin = Applica tionsPlugin()87 plugin = ApplicantsPlugin() 88 88 plugin.setup(site, 'blah', self.logger) 89 self.assertTrue('applica tions' in site.keys())89 self.assertTrue('applicants' in site.keys()) 90 90 log = self.get_log() 91 self.assertTrue('Installed applica tions root.' in log)91 self.assertTrue('Installed applicants root.' in log) 92 92 return 93 93 94 94 def test_update_new(self): 95 # Run update on a site without applica tions root.95 # Run update on a site without applicants root. 96 96 site = FakeSite() 97 plugin = Applica tionsPlugin()97 plugin = ApplicantsPlugin() 98 98 plugin.update(site, 'blah', self.logger) 99 self.assertTrue('applica tions' in site.keys())99 self.assertTrue('applicants' in site.keys()) 100 100 log = self.get_log() 101 101 self.assertTrue('Updating site at Unnamed Site' in log) 102 self.assertTrue('Installed applica tions root.' in log)102 self.assertTrue('Installed applicants root.' in log) 103 103 return 104 104 105 105 def test_update_outdated(self): 106 # Run update on a site with outdated applica tions root.106 # Run update on a site with outdated applicants root. 107 107 site = FakeSite() 108 root = object() # # This is not a proper applica tions root109 site['applica tions'] = root110 plugin = Applica tionsPlugin()108 root = object() # # This is not a proper applicants root 109 site['applicants'] = root 110 plugin = ApplicantsPlugin() 111 111 plugin.update(site, 'blah', self.logger) 112 self.assertTrue(site['applica tions'] is not root)113 self.assertTrue(isinstance(site['applica tions'], ApplicationsRoot))112 self.assertTrue(site['applicants'] is not root) 113 self.assertTrue(isinstance(site['applicants'], ApplicantsRoot)) 114 114 log = self.get_log() 115 self.assertTrue('Outdated applica tions folder detected' in log)115 self.assertTrue('Outdated applicants folder detected' in log) 116 116 self.assertTrue('Updating site at Unnamed Site' in log) 117 self.assertTrue('Installed applica tions root.' in log)117 self.assertTrue('Installed applicants root.' in log) 118 118 return 119 119 120 120 def test_update_uptodate(self): 121 # Run update on a site with proper applica tions root.121 # Run update on a site with proper applicants root. 122 122 site = FakeSite() 123 root = Applica tionsRoot()124 site['applica tions'] = root125 plugin = Applica tionsPlugin()123 root = ApplicantsRoot() 124 site['applicants'] = root 125 plugin = ApplicantsPlugin() 126 126 plugin.update(site, 'blah', self.logger) 127 self.assertTrue(site['applica tions'] is root)127 self.assertTrue(site['applicants'] is root) 128 128 log = self.get_log() 129 129 self.assertTrue('Updating site at Unnamed Site' in log) … … 135 135 site = FakeSite() 136 136 site.__name__ = 'my_site' 137 plugin = Applica tionsPlugin()137 plugin = ApplicantsPlugin() 138 138 plugin.update(site, 'blah', self.logger) 139 139 log = self.get_log() … … 144 144 suite = unittest.TestSuite() 145 145 for testcase in [ 146 Applica tionsRootTestCase,147 Applica tionsRootPluginTestCase,146 ApplicantsRootTestCase, 147 ApplicantsRootPluginTestCase, 148 148 ]: 149 149 suite.addTests(unittest.TestLoader().loadTestsFromTestCase(testcase))
Note: See TracChangeset for help on using the changeset viewer.