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

Last change on this file since 359 was 359, checked in by chervol, 13 years ago

updated the adapter to save data in correct PersistentMapping? structure

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