-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
conftest.py
60 lines (43 loc) · 1.47 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import json
import os
import shutil
from datetime import datetime
from typing import Any
from typing import Dict
import pytest
import responses as responses_
from protect_archiver.client import ProtectClient
from protect_archiver.dataclasses import Camera
@pytest.fixture
def sample_bootstrap_json() -> Dict[str, Any]:
with open("fixtures/bootstrap.json") as fp:
return json.load(fp)
@pytest.fixture
def sample_token_json() -> Dict[str, Any]:
with open("fixtures/token.json") as fp:
return json.load(fp)
@pytest.fixture
def sample_access_key_json() -> Dict[str, Any]:
with open("fixtures/access-key.json") as fp:
return json.load(fp)
@pytest.fixture
def sample_camera() -> Camera:
return Camera(
id="exteriorCameraId",
name="Exterior",
recording_start=datetime(2020, 1, 8, 23, 26, 9, 586000),
)
@pytest.fixture
def test_output_dest() -> Any:
test_output_dest = os.path.join(os.path.dirname(__file__), "test_output")
os.makedirs(test_output_dest)
yield test_output_dest
shutil.rmtree(test_output_dest, ignore_errors=False, onerror=None)
@pytest.fixture
def client(test_output_dest: str) -> Any:
return ProtectClient(destination_path=test_output_dest, password="test", download_timeout=0.01)
@pytest.fixture
def responses() -> Any:
# XXX(dcramer): pytest-responses doesnt let you change this behavior yet
with responses_.RequestsMock(assert_all_requests_are_fired=False) as rsps:
yield rsps