File: testURLTool.py

package info (click to toggle)
zope-cmfplone 2.5.1-4etch3
  • links: PTS
  • area: main
  • in suites: etch
  • size: 7,752 kB
  • ctags: 5,237
  • sloc: python: 28,264; xml: 3,723; php: 129; makefile: 99; sh: 2
file content (47 lines) | stat: -rw-r--r-- 1,556 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#
# Tests the workflow tool
#

import os, sys
if __name__ == '__main__':
    execfile(os.path.join(sys.path[0], 'framework.py'))

from Products.CMFPlone.tests import PloneTestCase

portal_name = PloneTestCase.portal_name


class TestURLTool(PloneTestCase.PloneTestCase):

    def afterSetUp(self):
        self.url = self.portal.portal_url

    def test_isURLInPortal(self):
        url_tool = self.url
        self.failUnless(url_tool.isURLInPortal(
                                        'http://nohost/%s/foo' % portal_name))
        self.failUnless(url_tool.isURLInPortal(
                                        'http://nohost/%s' % portal_name))
        self.failIf(url_tool.isURLInPortal(
                                        'http://nohost2/%s/foo' % portal_name))
        self.failUnless(url_tool.isURLInPortal(
                                        'https://nohost/%s/bar' % portal_name))
        self.failIf(url_tool.isURLInPortal(
                                   'http://nohost:8080/%s/baz' % portal_name))
        self.failIf(url_tool.isURLInPortal(
                                   'http://nohost/'))
        # Relative urls always succeed
        self.failUnless(url_tool.isURLInPortal(
                                   '/images'))
        self.failUnless(url_tool.isURLInPortal(
                                   'images/img1.jpg'))


def test_suite():
    from unittest import TestSuite, makeSuite
    suite = TestSuite()
    suite.addTest(makeSuite(TestURLTool))
    return suite

if __name__ == '__main__':
    framework()