Skip to content

Commit 00835e3

Browse files
author
Bobrock
committed
Add changes from original examples file, apply find_packages to setup, add tests
1 parent 91c92b0 commit 00835e3

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
secrets.cfg
12
# Byte-compiled / optimized / DLL files
23
__pycache__/
34
*.py[cod]

examples/streaming_video.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import cv2
2-
3-
from Camera import Camera
2+
from reolink_api.Camera import Camera
43

54

65
def non_blocking():

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33
import re
44
import codecs
5-
from setuptools import setup
5+
from setuptools import setup, find_packages
66

77

88
def read(*parts):
@@ -52,5 +52,6 @@ def find_version(*file_paths):
5252
author_email=AUTHOR_EMAIL,
5353
url=URL,
5454
license=LICENSE,
55-
install_requires=INSTALL_REQUIRES
55+
install_requires=INSTALL_REQUIRES,
56+
packages=find_packages(exclude=['examples', 'tests'])
5657
)

tests/test_camera.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import os
2+
from configparser import RawConfigParser
3+
import unittest
4+
from reolink_api import Camera
5+
6+
7+
def read_config(props_path: str) -> dict:
8+
"""Reads in a properties file into variables.
9+
10+
NB! this config file is kept out of commits with .gitignore. The structure of this file is such:
11+
# secrets.cfg
12+
[camera]
13+
ip={ip_address}
14+
username={username}
15+
password={password}
16+
"""
17+
config = RawConfigParser()
18+
assert os.path.exists(props_path), f"Path does not exist: {props_path}"
19+
config.read(props_path)
20+
return config
21+
22+
23+
class TestCamera(unittest.TestCase):
24+
25+
@classmethod
26+
def setUpClass(cls) -> None:
27+
cls.config = read_config('../secrets.cfg')
28+
29+
def setUp(self) -> None:
30+
self.cam = Camera(self.config.get('camera', 'ip'), self.config.get('camera', 'username'),
31+
self.config.get('camera', 'password'))
32+
33+
def test_camera(self):
34+
"""Test that camera connects and gets a token"""
35+
self.assertTrue(self.cam.ip == self.config.get('camera', 'ip'))
36+
self.assertTrue(self.cam.token != '')
37+
38+
39+
if __name__ == '__main__':
40+
unittest.main()

0 commit comments

Comments
 (0)