vendor/Five/1.2b-r20590

view browser/tests/resource_ftest.txt @ 0:3673ed425f80

Vendor import of Five 1.2b+ (r20590)
author fguillaume
date Fri, 02 Dec 2005 20:25:42 +0000
parents
children
line source
1 Functional Resource Test
2 ========================
4 Set up the test fixtures:
6 >>> import Products.Five.browser.tests
7 >>> from Products.Five import zcml
8 >>> zcml.load_config("configure.zcml", Products.Five)
9 >>> zcml.load_config('resource.zcml', package=Products.Five.browser.tests)
11 >>> from Products.Five.tests.testing import manage_addFiveTraversableFolder
12 >>> manage_addFiveTraversableFolder(self.folder, 'testoid', 'Testoid')
14 >>> import os, glob
15 >>> _prefix = os.path.dirname(Products.Five.browser.tests.__file__)
16 >>> dir_resource_names = [os.path.basename(r) for r in (
17 ... glob.glob('%s/*.png' % _prefix) +
18 ... glob.glob('%s/*.pt' % _prefix) +
19 ... glob.glob('%s/[a-z]*.py' % _prefix) +
20 ... glob.glob('%s/*.css' % _prefix))]
22 >>> uf = self.folder.acl_users
23 >>> uf._doAddUser('manager', 'r00t', ['Manager'], [])
26 Image resource
27 ~~~~~~~~~~~~~~
29 >>> print http(r'''
30 ... GET /test_folder_1_/testoid/++resource++pattern.png HTTP/1.1
31 ... Authorization: Basic manager:r00t
32 ... ''')
33 HTTP/1.1 200 OK
34 ...
36 File resource
37 ~~~~~~~~~~~~~
39 >>> print http(r'''
40 ... GET /test_folder_1_/testoid/++resource++style.css HTTP/1.1
41 ... Authorization: Basic manager:r00t
42 ... ''')
43 HTTP/1.1 200 OK
44 ...
46 Template resource
47 ~~~~~~~~~~~~~~~~~
49 >>> print http(r'''
50 ... GET /test_folder_1_/testoid/++resource++cockatiel.html HTTP/1.1
51 ... Authorization: Basic manager:r00t
52 ... ''')
53 HTTP/1.1 200 OK
54 ...
56 Resource directory
57 ~~~~~~~~~~~~~~~~~~
59 Page templates aren't guaranteed to render, so exclude them from the test:
61 >>> base_url = '/test_folder_1_/testoid/++resource++fivetest_resources/%s'
62 >>> for r in dir_resource_names:
63 ... if r.endswith('.pt'):
64 ... continue
65 ... response = self.publish(base_url % r, basic='manager:r00t')
66 ... self.assertEquals(200, response.getStatus())
69 Clean up
70 --------
72 >>> from zope.app.tests.placelesssetup import tearDown
73 >>> tearDown()