Completed
Push — master ( 3c3df8...1248a1 )
by Piotr
01:12
created

test_router_routes_contains_routes()   A

Complexity

Conditions 2

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
c 0
b 0
f 0
dl 0
loc 2
rs 10
1
import pytest
2
3
from mountapi.core import exceptions
4
from mountapi.routing import AbstractRouter
5
from tests.common import router, routes
6
7
8
def test_router_valid_get_dispatch_for_valid_path():
9
    assert router.dispatch(
10
        path=routes[0].rule, method='GET'
11
    ).__func__ == routes[0].endpoint.get
12
13
14
def test_router_valid_post_dispatch_for_valid_path():
15
    assert router.dispatch(
16
        path=routes[0].rule, method='POST'
17
    ).__func__ == routes[0].endpoint.post
18
19
20
def test_router_raises_not_found_for_invalid_path():
21
    with pytest.raises(exceptions.NotFound):
22
        router.dispatch(path='/foo', method='GET')
23
24
25
def test_router_raises_not_found_for_invalid_method():
26
    with pytest.raises(exceptions.MethodNotAllowed):
27
        router.dispatch(path=routes[0].rule, method='DELETE')
28
29
30
def test_abstract_router_routes_raises_not_implemented():
31
    with pytest.raises(NotImplementedError):
32
        AbstractRouter.routes.fget(router)
33
34
35
def test_abstract_router_dispatch_raises_not_implemented():
36
    with pytest.raises(NotImplementedError):
37
        AbstractRouter.dispatch(router, path=routes[0].rule, method='GET')
38
39
40
def test_router_routes_contains_routes():
41
    assert router.routes == routes
42