Completed
Push — main ( 254773...79af2c )
by Jochen
03:19
created

test_healthcheck_fail()   A

Complexity

Conditions 1

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 12
nop 2
dl 0
loc 15
rs 9.8
c 0
b 0
f 0
1
"""
2
:Copyright: 2006-2020 Jochen Kupperschmidt
3
:License: Modified BSD, see LICENSE for details.
4
"""
5
6
from unittest.mock import patch
7
8
9
# Test against an admin app because that doesn't require setup of brand
10
# party. After all, both admin and party apps should react the same.
11
12
13
@patch('byceps.blueprints.monitoring.healthcheck.views._is_rdbms_ok')
14
def test_healthcheck_fail(is_rdbms_ok_mock, admin_client):
15
    expected_media_type = 'application/health+json'
16
17
    is_rdbms_ok_mock.return_value = False
18
19
    response = admin_client.get('/health')
20
21
    assert response.status_code == 503
22
    assert response.content_type == expected_media_type
23
    assert response.mimetype == expected_media_type
24
    assert response.get_json() == {
25
        'status': 'ok',
26
        'details': {
27
            'rdbms': [{'status': 'fail'}],
28
        },
29
    }
30