~ubuntu-branches/ubuntu/gutsy/routes/gutsy

« back to all changes in this revision

Viewing changes to tests/test_functional/test_recognition.py

  • Committer: Bazaar Package Importer
  • Author(s): Piotr Ożarowski
  • Date: 2007-06-09 15:37:20 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070609153720-9epnibq0xpmnikle
Tags: 1.7-1
* New upstream release
* Added python-paste to Suggests (for Routes WSGI Middleware)

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
        m.connect(':hoge')
42
42
        self.assertEqual({'controller': 'content', 'action': 'index', 'hoge': hoge},
43
43
                         m.match('/' + hoge_enc))
 
44
    
 
45
    def test_disabling_unicode(self):
 
46
        hoge = u'\u30c6\u30b9\u30c8' # the word test in Japanese
 
47
        hoge_enc = urllib.quote_plus(hoge.encode('utf-8'))
 
48
        m = Mapper()
 
49
        m.encoding = None
 
50
        m.connect(':hoge')
 
51
        self.assertEqual({'controller': 'content', 'action': 'index', 'hoge': hoge_enc},
 
52
                         m.match('/' + hoge_enc))
44
53
            
45
54
    def test_basic_dynamic(self):
46
55
        for path in ['hi/:name', 'hi/:(name)']:
448
457
        self.assertEqual({'controller':'content','action':'index', 'id': 'None'}, m.match('/content/index/None.py'))
449
458
        self.assertEqual({'controller':'content','action':'list', 'id':'None'}, m.match('/content/list/None.py'))
450
459
        self.assertEqual({'controller':'content','action':'show','id':'10'}, m.match('/content/show/10.py'))
 
460
 
 
461
    def test_standard_route_with_gaps_and_domains(self):
 
462
        m = Mapper()
 
463
        m.connect('manage/:domain.:ext', controller='admin/user', action='view', ext='html')
 
464
        m.connect(':controller/:action/:id')
 
465
        m.create_regs(['content','admin/user'])
 
466
        
 
467
        self.assertEqual({'controller':'content','action':'index', 'id': 'None.py'}, m.match('/content/index/None.py'))
 
468
        self.assertEqual({'controller':'content','action':'list', 'id':'None.py'}, m.match('/content/list/None.py'))
 
469
        self.assertEqual({'controller':'content','action':'show','id':'10.py'}, m.match('/content/show/10.py'))
 
470
        self.assertEqual({'controller':'content','action':'show.all','id':'10.py'}, m.match('/content/show.all/10.py'))
 
471
        self.assertEqual({'controller':'content','action':'show','id':'www.groovie.org'}, m.match('/content/show/www.groovie.org'))
 
472
        
 
473
        self.assertEqual({'controller':'admin/user','action':'view', 'ext': 'html', 'domain': 'groovie'}, m.match('/manage/groovie'))
 
474
        self.assertEqual({'controller':'admin/user','action':'view', 'ext': 'xml', 'domain': 'groovie'}, m.match('/manage/groovie.xml'))
 
475
    
 
476
    def test_standard_with_domains(self):
 
477
        m = Mapper()
 
478
        m.connect('manage/:domain', controller='domains', action='view')
 
479
        m.create_regs(['domains'])
 
480
        
 
481
        self.assertEqual({'controller':'domains','action':'view','domain':'www.groovie.org'}, m.match('/manage/www.groovie.org'))
451
482
    
452
483
    def test_default_route(self):
453
484
        m = Mapper()