Exemplo n.º 1
0
    def test_add_route(self):
        '''
        ルーティングのテスト
        nameが指定された場合
        :return:
        '''
        plugin = WSGI_Bottle()  # テスト用にプラグインを生成
        plugins['test'] = plugin
        app_mock = self.mocker.CreateMock(Bottle)

        def test_method():
            pass

        app_mock.route(path='/test',
                       method='GET',
                       callback=test_method,
                       name='test')  # routeが呼び出された際の振る舞いを設定
        plugin.app = app_mock  # プラグインのappを差し替え
        params = {
            'rule': '/test',
            'method': 'GET',
            'target': test_method,
            'name': 'test'
        }
        self.mocker.ReplayAll()
        add_route('test', params)
        self.mocker.VerifyAll()
Exemplo n.º 2
0
 def test_add_route_noname(self):
     '''
     ルーティングのテスト
     nameが指定されない場合
     :return:
     '''
     plugin = WSGI_Bottle()
     plugins['test'] = plugin
     app_mock = self.mocker.CreateMock(Bottle)
     def test_method():
         pass
     app_mock.route(path='/test', method='GET', callback=test_method, name=None)
     plugin.app = app_mock
     params = {'rule':'/test', 'method':'GET', 'target':test_method}
     self.mocker.ReplayAll()
     add_route('test', params)
     self.mocker.VerifyAll()
Exemplo n.º 3
0
 def test_add_route(self):
     '''
     ルーティングのテスト
     nameが指定された場合
     :return:
     '''
     plugin = WSGI_Bottle() # テスト用にプラグインを生成
     plugins['test'] = plugin
     app_mock = self.mocker.CreateMock(Bottle)
     def test_method():
         pass
     app_mock.route(path='/test', method='GET', callback=test_method, name='test') # routeが呼び出された際の振る舞いを設定
     plugin.app = app_mock # プラグインのappを差し替え
     params = {'rule':'/test', 'method':'GET', 'target':test_method, 'name':'test'}
     self.mocker.ReplayAll()
     add_route('test', params)
     self.mocker.VerifyAll()
Exemplo n.º 4
0
    def test_add_route_noname(self):
        '''
        ルーティングのテスト
        nameが指定されない場合
        :return:
        '''
        plugin = WSGI_Bottle()
        plugins['test'] = plugin
        app_mock = self.mocker.CreateMock(Bottle)

        def test_method():
            pass

        app_mock.route(path='/test',
                       method='GET',
                       callback=test_method,
                       name=None)
        plugin.app = app_mock
        params = {'rule': '/test', 'method': 'GET', 'target': test_method}
        self.mocker.ReplayAll()
        add_route('test', params)
        self.mocker.VerifyAll()