forked from danielfernau/unifi-protect-video-downloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
58 lines (42 loc) · 1.32 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
import json
import os
import pytest
import responses as responses_
import shutil
from datetime import datetime
from protect_archiver.client import Camera, ProtectClient
@pytest.fixture
def sample_bootstrap_json():
with open("fixtures/bootstrap.json") as fp:
return json.load(fp)
@pytest.fixture
def sample_token_json():
with open("fixtures/token.json") as fp:
return json.load(fp)
@pytest.fixture
def sample_access_key_json():
with open("fixtures/access-key.json") as fp:
return json.load(fp)
@pytest.fixture
def sample_camera():
return Camera(
id="exteriorCameraId",
name="Exterior",
recording_start=datetime(2020, 1, 8, 23, 26, 9, 586000),
)
@pytest.fixture
def test_output_dest():
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):
return ProtectClient(
destination_path=test_output_dest, password="test", download_timeout=0.01
)
@pytest.yield_fixture
def responses():
# XXX(dcramer): pytest-responses doesnt let you change this behavior yet
with responses_.RequestsMock(assert_all_requests_are_fired=False) as rsps:
yield rsps