##
## test_util.py
## Login : <uli@pu.smp.net>
## Started on  Sun Aug 22 19:56:52 2010 Uli Fouquet
## $Id$
## 
## Copyright (C) 2010 Uli Fouquet
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
## 
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
## 
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
"""Tests for jambtables and applicants helper tools.
"""
import unittest
from zope.component.hooks import setSite
from zope.site import LocalSiteManager
from zope.site.folder import Folder
from zope.site.testing import siteSetUp, siteTearDown
from waeup.sirp.jambtables.tests.test_authentication import (
    FakeSite)
from waeup.sirp.jambtables.util import application_exists, get_applicant_data

class HelperToolsTest(unittest.TestCase):

    def setUp(self):
        self.root = Folder()
        siteSetUp(self.root)
        self.app = FakeSite() #grok.Application()
        self.root['app'] = self.app
        self.app.setSiteManager(LocalSiteManager(self.app))
        setSite(self.app)
        return

    def tearDown(self):
        siteTearDown()
        return

    def test_application_exists(self):
        result = application_exists('APP-99999')
        assert result is False

        result = application_exists('APP-44444')
        assert result is True
        
        return

def test_suite():
    suite = unittest.TestSuite()
    for testcase in [
        HelperToolsTest,
        ]:
        suite.addTest(unittest.TestLoader().loadTestsFromTestCase(
                testcase
                )
        )
    return suite
