예제 #1
0
파일: test_url.py 프로젝트: kudrom/lupulo
    def test_gaps_url(self):
        self.create_urls_file('gaps_urls.py')
        connect_user_urls(self.root_mock)

        resource = self.root_mock
        self.assertEqual(resource.next_resources.keys(), ['hello'])

        resource = resource.next_resources['hello']
        self.assertEqual(resource.__class__.__name__, 'LupuloResource')
        self.assertEqual(resource.next_resources.keys(), ['world'])

        resource = resource.next_resources['world']
        self.assertEqual(resource.__class__.__name__, 'LupuloResource')
        self.assertEqual(resource.next_resources.keys(), ['this'])

        resource = resource.next_resources['this']
        self.assertEqual(resource.__class__.__name__, 'CustomResource')
        self.assertEqual(resource.next_resources.keys(), ['is'])

        resource = resource.next_resources['is']
        self.assertEqual(resource.__class__.__name__, 'LupuloResource')
        self.assertEqual(resource.next_resources.keys(), ['kudrom'])

        resource = resource.next_resources['kudrom']
        self.assertEqual(resource.__class__.__name__, 'CustomResource')
        self.assertEqual(len(resource.next_resources), 0)
예제 #2
0
파일: test_url.py 프로젝트: kudrom/lupulo
    def test_url_siblings(self):
        self.create_urls_file('siblings_urls.py')
        connect_user_urls(self.root_mock)

        self.assertEqual(len(self.root_mock.next_resources), 2)
        self.assertEqual(set(self.root_mock.next_resources),
                         set(['hello', 'bye']))
        self.assertEqual(self.root_mock.putChild.call_count, 2)
        bye = self.root_mock.next_resources['bye']
        self.assertEqual(len(bye.next_resources), 0)
        self.assertEqual(bye.render_GET(None), 'Bye world')

        hello = self.root_mock.next_resources['hello']
        self.assertEqual(len(hello.next_resources), 2)
        self.assertEqual(set(hello.next_resources), set(['world', 'death']))
        self.assertEqual(hello.render_GET(None), 'Hello world')

        self.assertEqual(len(hello.next_resources['world'].next_resources), 0)
        self.assertEqual(hello.next_resources['world'].render_GET(None),
                         'The world is amazing')

        self.assertEqual(len(hello.next_resources['death'].next_resources), 0)
        self.assertEqual(hello.next_resources['death'].render_GET(None),
                         'The death is scary')

        self.assertEqual(self.root_mock.putChild.call_args_list,
                         [call('bye', bye), call('hello', hello)])
예제 #3
0
파일: test_url.py 프로젝트: kudrom/lupulo
    def test_repeated_url(self):
        self.create_urls_file('repeated_url.py')
        connect_user_urls(self.root_mock)

        self.assertEqual(self.root_mock.next_resources.keys(), ['death'])
        resource = self.root_mock.next_resources['death']
        self.assertEqual(resource.render_GET(None), 'The death is scary')
예제 #4
0
파일: test_url.py 프로젝트: kudrom/lupulo
    def test_simple_url_with_slash(self):
        self.create_urls_file('simple_url.py')
        connect_user_urls(self.root_mock)

        self.assertEqual(len(self.root_mock.next_resources), 1)
        self.assertEqual(set(self.root_mock.next_resources), set(['hello']))

        resource = self.root_mock.next_resources['hello']
        self.assertEqual(resource.render_GET(None), 'Hello world')

        self.root_mock.putChild.assert_called_once_with('hello', resource)