Completed
Push — main ( 7d4592...e74a90 )
by Jochen
03:11
created

tests.integration.announce.discord.helpers.now()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 0
dl 0
loc 2
rs 10
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 contextlib import contextmanager
7
from datetime import datetime
8
9
from requests_mock import Mocker
10
11
12
def now() -> datetime:
13
    return datetime.utcnow()
14
15
16
@contextmanager
17
def mocked_webhook_receiver(url: str):
18
    with Mocker() as mock:
19
        mock.post(url)
20
        yield mock
21
22
23
def assert_request(mock, expected_content: str) -> None:
24
    assert mock.called
25
26
    history = mock.request_history
27
    assert len(history) == 1
28
29
    actual = mock.last_request.json()
30
31
    assert actual == {'content': expected_content}
32