source: products/quintagroup.transmogrifier.simpleblog2quills/trunk/quintagroup/transmogrifier/simpleblog2quills/tests/test_import.py @ 1489

Last change on this file since 1489 was 1488, checked in by koval, 14 years ago

fixed error in tests concerned with Products.fatsyndication

File size: 3.1 KB
Line 
1import unittest
2import os.path
3
4import transaction
5
6from Products.Five import zcml
7from Products.Five import fiveconfigure
8from Testing import ZopeTestCase as ztc
9
10from Products.PloneTestCase import PloneTestCase as ptc
11from Products.PloneTestCase.layer import onsetup
12
13from collective.transmogrifier.interfaces import ITransmogrifier
14
15ztc.installProduct('Quills')
16ztc.installProduct('fatsyndication')
17
18@onsetup
19def setup_product():
20    fiveconfigure.debug_mode = True
21    import Products.Five
22    zcml.load_config('configure.zcml', Products.Five)
23    import quintagroup.transmogrifier.simpleblog2quills
24    zcml.load_config('configure.zcml', quintagroup.transmogrifier.simpleblog2quills)
25    import quintagroup.transmogrifier.simpleblog2quills.tests
26    zcml.load_config('test_import.zcml', quintagroup.transmogrifier.simpleblog2quills.tests)
27    # this is needed because 'importStep' unknown directive error is raised somewhere
28    import Products.GenericSetup
29    zcml.load_config('meta.zcml', Products.GenericSetup)
30    import Products.Quills
31    zcml.load_config('configure.zcml', Products.Quills)
32    fiveconfigure.debug_mode = False
33
34setup_product()
35ptc.setupPloneSite(products=['Quills'])
36
37class TestImport(ptc.PloneTestCase):
38    """ Test importing of PloneFormGen content.
39    """
40
41    def afterSetUp(self):
42        self.addProduct('Quills')
43        if 'blog' not in self.portal:
44            # run transmogrifier pipeline
45            transmogrifier = ITransmogrifier(self.portal)
46            transmogrifier('test_import')
47
48    def beforeTearDown(self):
49        transaction.commit()
50
51    def test_site_structure(self):
52        self.failIf('blog' not in self.portal)
53        self.failIf('root-entry' not in self.portal.blog)
54        self.failIf('folder' not in self.portal.blog)
55        self.failIf('folder-entry' not in self.portal.blog.folder)
56
57    def test_blog(self):
58        blog = self.portal['blog']
59
60        self.assertEqual(blog.getPortalTypeName(), 'Weblog')
61        self.assertEqual(blog['title'], 'Test Blog')
62        self.assertEqual(blog.Description(), 'This is test blog.')
63
64    def test_blog_entry(self):
65        entry = self.portal['blog']['root-entry']
66
67        self.assertEqual(entry.getPortalTypeName(), 'WeblogEntry')
68        self.assertEqual(entry['title'], 'Root entry')
69        self.assertEqual(entry.Description(), 'This entry was created in root of blog.')
70        self.assertEqual(entry.getText(), '<p>We are testing importing of blog entry.</p>')
71        self.assertEqual(entry.Subject(), ('Plone', 'Zope'))
72        self.assertEqual(entry.modified().HTML4(), '2007-11-14T10:32:11Z')
73        # now workflow of WeblogEntry is assumed to be 'plone_workflow'
74        # but it must be configured in type configuration
75        self.failIf('plone_workflow' not in entry.workflow_history)
76
77    def test_blog_folder(self):
78        folder = self.portal['blog']['folder']
79
80        self.assertEqual(folder.getPortalTypeName(), 'Folder')
81        self.assertEqual(folder['title'], 'Blog folder')
82        self.assertEqual(folder.Description(), 'Folder in blog.')
83
84def test_suite():
85    suite = unittest.TestSuite()
86    suite.addTest(unittest.makeSuite(TestImport))
87    return suite
Note: See TracBrowser for help on using the repository browser.