Add changes from original examples file, apply find_packages to setup, add tests
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
secrets.cfg
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import cv2
|
import cv2
|
||||||
|
from reolink_api.Camera import Camera
|
||||||
from Camera import Camera
|
|
||||||
|
|
||||||
|
|
||||||
def non_blocking():
|
def non_blocking():
|
||||||
|
|||||||
5
setup.py
5
setup.py
@@ -2,7 +2,7 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import codecs
|
import codecs
|
||||||
from setuptools import setup
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
|
||||||
def read(*parts):
|
def read(*parts):
|
||||||
@@ -52,5 +52,6 @@ setup(
|
|||||||
author_email=AUTHOR_EMAIL,
|
author_email=AUTHOR_EMAIL,
|
||||||
url=URL,
|
url=URL,
|
||||||
license=LICENSE,
|
license=LICENSE,
|
||||||
install_requires=INSTALL_REQUIRES
|
install_requires=INSTALL_REQUIRES,
|
||||||
|
packages=find_packages(exclude=['examples', 'tests'])
|
||||||
)
|
)
|
||||||
|
|||||||
40
tests/test_camera.py
Normal file
40
tests/test_camera.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import os
|
||||||
|
from configparser import RawConfigParser
|
||||||
|
import unittest
|
||||||
|
from reolink_api import Camera
|
||||||
|
|
||||||
|
|
||||||
|
def read_config(props_path: str) -> dict:
|
||||||
|
"""Reads in a properties file into variables.
|
||||||
|
|
||||||
|
NB! this config file is kept out of commits with .gitignore. The structure of this file is such:
|
||||||
|
# secrets.cfg
|
||||||
|
[camera]
|
||||||
|
ip={ip_address}
|
||||||
|
username={username}
|
||||||
|
password={password}
|
||||||
|
"""
|
||||||
|
config = RawConfigParser()
|
||||||
|
assert os.path.exists(props_path), f"Path does not exist: {props_path}"
|
||||||
|
config.read(props_path)
|
||||||
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
class TestCamera(unittest.TestCase):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setUpClass(cls) -> None:
|
||||||
|
cls.config = read_config('../secrets.cfg')
|
||||||
|
|
||||||
|
def setUp(self) -> None:
|
||||||
|
self.cam = Camera(self.config.get('camera', 'ip'), self.config.get('camera', 'username'),
|
||||||
|
self.config.get('camera', 'password'))
|
||||||
|
|
||||||
|
def test_camera(self):
|
||||||
|
"""Test that camera connects and gets a token"""
|
||||||
|
self.assertTrue(self.cam.ip == self.config.get('camera', 'ip'))
|
||||||
|
self.assertTrue(self.cam.token != '')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
Reference in New Issue
Block a user