source: products/qPloneResolveUID/tags/0.2.4/tests/test_transforms.py @ 2111

Last change on this file since 2111 was 1, checked in by myroslav, 18 years ago

Building directory structure

File size: 2.6 KB
Line 
1# Author: Melnychuk Taras
2# Contact: fenix@quintagroup.com
3# Date: $Date: 2006-08-11
4# Copyright: quintagroup.com
5
6from __future__ import nested_scopes
7
8import os, sys
9if __name__ == '__main__':
10    execfile(os.path.join(sys.path[0], 'framework.py'))
11
12
13"""This module contains class that tests ruid_to_url transformation """
14
15from Testing import ZopeTestCase
16from Products.Archetypes.tests.atsitetestcase import ATSiteTestCase
17
18from Products.qPloneResolveUID.transforms.ruid_to_url import ruid_to_url
19from Products.qPloneResolveUID.tests.test_data import *
20
21ZopeTestCase.installProduct('qPloneResolveUID')
22import time
23
24tests=[]
25PRODUCTS=('qPloneResolveUID',)
26
27
28
29class TransformTest(ATSiteTestCase):
30   
31    def afterSetUp(self):
32        ATSiteTestCase.afterSetUp(self)
33        self.loginAsPortalOwner()
34        for product in PRODUCTS:
35            self.addProduct(product)
36        self.pt = self.portal.portal_transforms   
37   
38    def test_qPloneResolveUIDInstallation(self):
39        qi = self.portal.portal_quickinstaller
40        self.assert_('qPloneResolveUID' in [prod['id']for prod in qi.listInstalledProducts()], 
41                     "qPloneResolveUID doesn't installed"   
42                    )
43   
44    def test_ruid_to_url_registration(self):
45        self.assert_('ruid_to_url' in self.pt.objectIds(), 
46                     "ruid_to_url transformation not registered"
47                    )
48    def test_polisy_registration(self):
49        self.assert_(('text/x-html-safe', ('ruid_to_url',)) in self.pt.listPolicies(),
50                     'Policy for text/x-html-safe mimetype is not installed'
51                    )
52   
53    def test_ruid_to_url(self):
54        if not 'test1' in self.portal.objectIds():
55            self.portal.invokeFactory('Folder', 'test1')
56        test1 = getattr(self.portal, 'test1', None)
57        if test1:
58            test1_uid = test1.UID()
59            test1.invokeFactory('Document', 'test2')
60            test2 = getattr(test1, 'test2', None)
61            if test2:
62                test2_uid = test2.UID()
63        self.assertEqual(self.pt.convert('ruid_to_url',
64                                         orig_text %(test1_uid, test2_uid, test2_uid+'/image_mini'),
65                                         context = self.portal
66                                        ).getData(),
67                         result
68                        )
69                     
70   
71tests.append(TransformTest)
72
73def test_suite():
74    from unittest import TestSuite, makeSuite
75    suite = TestSuite()
76    suite.addTest(makeSuite(TransformTest))
77    return suite
78
79if __name__ == '__main__':
80    framework()
Note: See TracBrowser for help on using the repository browser.