Beispiel #1
0
    def test_match_route_returns_controller(self):
        self.app.make('Route').url = '/view'
        self.app.bind('WebRoutes', [
            Match(['GET', 'POST']).route('/view',
                                         ControllerTest.returns_a_view)
        ])

        self.provider.boot(self.app.make('Route'), self.app.make('Request'),
                           self.app.make(Response))

        assert self.app.make('Response') == 'hey'
Beispiel #2
0
def match(method_type, url, controller):
    """Shortcut for Match HTTP class.

    Arguments:
        method_type {list} -- A list of the method types you want to accept
        url {string} -- The url you want to use for the route
        controller {string|object} -- This can be a string controller or a normal object controller

    Returns:
        masonite.routes.Get -- The Masonite Get class.
    """
    from masonite.routes import Match

    return Match(method_type).route(url, controller)
Beispiel #3
0
 def test_route_can_have_multiple_routes(self):
     assert Match(['GET', 'POST']).route(
         'test/url', 'TestController@show').method_type == ['GET', 'POST']
Beispiel #4
0
 def test_match_routes_raises_exception_with_non_list_method_types(self):
     with pytest.raises(RouteException):
         assert Match('get').route(
             'test/url',
             'TestController@show').method_type == ['GET', 'POST']
Beispiel #5
0
 def test_match_routes_convert_lowercase_to_uppercase(self):
     assert Match(['Get', 'Post']).route(
         'test/url', 'TestController@show').method_type == ['GET', 'POST']
Beispiel #6
0
 def test_match_routes_raises_exception_with_non_list_method_types(self):
     with self.assertRaises(RouteException):
         self.assertEqual(
             Match('get').route('test/url',
                                'TestController@show').method_type,
             ['GET', 'POST'])
Beispiel #7
0
    def test_match_route_returns_controller(self):
        self.routes(only=[Match(['GET', 'POST']).route('/view', ControllerTest.returns_a_view)])

        self.assertTrue(self.get('/view').contains('hey'))
Beispiel #8
0
def ComponentRoute(component, controller):
    return Match(['Get', 'POST'], f'/livewire/props/{component}',
                 f'{controller}@show')