[1] | 1 | # Author: Melnychuk Taras |
---|
| 2 | # Contact: fenix@quintagroup.com |
---|
| 3 | # Date: $Date: 2006-08-11 |
---|
| 4 | # Copyright: quintagroup.com |
---|
| 5 | |
---|
| 6 | from __future__ import nested_scopes |
---|
| 7 | |
---|
| 8 | import os, sys |
---|
| 9 | if __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 | |
---|
| 15 | from Testing import ZopeTestCase |
---|
| 16 | from Products.Archetypes.tests.atsitetestcase import ATSiteTestCase |
---|
| 17 | |
---|
| 18 | from Products.qPloneResolveUID.transforms.ruid_to_url import ruid_to_url |
---|
| 19 | from Products.qPloneResolveUID.tests.test_data import * |
---|
| 20 | |
---|
| 21 | ZopeTestCase.installProduct('qPloneResolveUID') |
---|
| 22 | import time |
---|
| 23 | |
---|
| 24 | tests=[] |
---|
| 25 | PRODUCTS=('qPloneResolveUID',) |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | |
---|
| 29 | class 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 | |
---|
| 71 | tests.append(TransformTest) |
---|
| 72 | |
---|
| 73 | def test_suite(): |
---|
| 74 | from unittest import TestSuite, makeSuite |
---|
| 75 | suite = TestSuite() |
---|
| 76 | suite.addTest(makeSuite(TransformTest)) |
---|
| 77 | return suite |
---|
| 78 | |
---|
| 79 | if __name__ == '__main__': |
---|
| 80 | framework() |
---|