Back to index

plone3  3.1.7
test_exportimport.py
Go to the documentation of this file.
00001 ##############################################################################
00002 #
00003 # Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
00004 #
00005 # This software is subject to the provisions of the Zope Public License,
00006 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
00007 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
00008 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00009 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
00010 # FOR A PARTICULAR PURPOSE.
00011 #
00012 ##############################################################################
00013 """MailHost export / import support unit tests.
00014 
00015 $Id: test_exportimport.py 71212 2006-11-20 19:27:48Z yuppie $
00016 """
00017 
00018 import unittest
00019 import Testing
00020 
00021 from Products.GenericSetup.testing import BodyAdapterTestCase
00022 from Products.GenericSetup.testing import ExportImportZCMLLayer
00023 
00024 _MAILHOST_BODY = """\
00025 <?xml version="1.0"?>
00026 <object name="foo_mailhost" meta_type="Mail Host" smtp_host="localhost"
00027    smtp_port="25" smtp_pwd="" smtp_uid=""/>
00028 """
00029 
00030 
00031 class MailHostXMLAdapterTests(BodyAdapterTestCase):
00032 
00033     layer = ExportImportZCMLLayer
00034 
00035     def _getTargetClass(self):
00036         from Products.GenericSetup.MailHost.exportimport \
00037                 import MailHostXMLAdapter
00038 
00039         return MailHostXMLAdapter
00040 
00041     def _verifyImport(self, obj):
00042         self.assertEqual(type(obj.smtp_host), str)
00043         self.assertEqual(obj.smtp_host, 'localhost')
00044         self.assertEqual(type(obj.smtp_port), int)
00045         self.assertEqual(obj.smtp_port, 25)
00046         self.assertEqual(type(obj.smtp_pwd), str)
00047         self.assertEqual(obj.smtp_pwd, '')
00048         self.assertEqual(type(obj.smtp_uid), str)
00049         self.assertEqual(obj.smtp_uid, '')
00050 
00051     def setUp(self):
00052         from Products.MailHost.MailHost import MailHost
00053 
00054         BodyAdapterTestCase.setUp(self)
00055         self._obj = MailHost('foo_mailhost')
00056         self._BODY = _MAILHOST_BODY
00057 
00058 
00059 def test_suite():
00060     return unittest.TestSuite((
00061         unittest.makeSuite(MailHostXMLAdapterTests),
00062         ))
00063 
00064 if __name__ == '__main__':
00065     from Products.GenericSetup.testing import run
00066     run(test_suite())