GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

TestExceptions   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 29
rs 10
wmc 12

6 Methods

Rating   Name   Duplication   Size   Complexity  
A test_unauthorized_access() 0 4 2
A test_connection() 0 3 2
A test_redirect() 0 3 2
A test_missing_param() 0 3 2
A test_not_found() 0 4 2
A test_missing_config() 0 3 2
1
from collections import namedtuple
2
3
import pytest
4
5
from besepa.exceptions import ConnectionError, MissingParam, Redirection, ResourceNotFound, UnauthorizedAccess
6
7
8
@pytest.fixture
9
def response_fixture():
10
    return namedtuple('Response', 'status_code reason')
11
12
13
class TestExceptions(object):
14
15
    def test_connection(self):
16
        error = ConnectionError({}, 'Test')
17
        assert str(error) == "Failed. Error message: Test"
18
19
    def test_redirect(self):
20
        error = Redirection({"Location": "http://example.com"})
21
        assert str(error) == "Failed. => http://example.com"
22
23
    def test_not_found(self, response_fixture):
24
        response = response_fixture(status_code="404", reason="Not Found")
25
        error = ResourceNotFound(response)
26
        assert str(error) == "Failed. Response status: %s. Response message: %s." % (
27
            response.status_code, response.reason)
28
29
    def test_unauthorized_access(self, response_fixture):
30
        response = response_fixture(status_code="401", reason="Unauthorized")
31
        error = UnauthorizedAccess(response)
32
        assert str(error) == "Failed. Response status: %s. Response message: %s." % (
33
            response.status_code, response.reason)
34
35
    def test_missing_param(self):
36
        error = MissingParam("Missing Payment Id")
37
        assert str(error) == "Missing Payment Id"
38
39
    def test_missing_config(self):
40
        error = MissingParam("Missing api_key")
41
        assert str(error) == "Missing api_key"
42