Skip to content
Snippets Groups Projects
Commit cc0e5f59 authored by ptangu01's avatar ptangu01
Browse files

Add first unit tests on device

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/trunk@1375 b32b6428-25c9-4566-ad07-03861ab6144f
parent 3c1a81af
No related branches found
No related tags found
No related merge requests found
......@@ -11,20 +11,17 @@ with open(path.join(here, 'DESCRIPTION.rst'), encoding='utf-8') as f:
setup(
name='xaal-lib',
version='0.5',
description='xaal-lib is the Python stack of xAAL protocol dedicated to home automation systems',
long_description = long_description,
description=('xaal-lib is the Python stack of xAAL protocol '
'dedicated to home automation systems'),
long_description=long_description,
url='http://recherche.telecom-bretagne.eu/xaal/',
author="Telecom Bretagne, IHSEV team",
author_email="",
license='GNU General Public License',
install_requires=["ujson>=1.33"],
keywords='Home Automation, Ambient Assisting Living',
package_dir = {'':'src'},
packages=find_packages('src'), #include all packages under src
package_dir={'': 'src'},
packages=find_packages('src'),
classifiers=[
"Development Status :: 3 - Alpha",
"Environment :: Console",
......
import unittest
import pep8
FILES = [
'../src/xAAL/core.py',
'../src/xAAL/devices.py',
'../src/xAAL/messages.py',
'../src/xAAL/network.py',
'../src/xAAL/tools.py',
]
class TestCodeFormat(unittest.TestCase):
def test_pep8_conformance(self):
"""Test that we conform to PEP8."""
pep8style = pep8.StyleGuide(quiet=True)
result = pep8style.check_files(FILES)
self.assertEqual(result.total_errors, 0,
"Found code style errors (and warnings).")
if __name__ == "__main__":
unittest.main()
import xAAL
import unittest
class DeviceTest(unittest.TestCase):
"""Test case to test xAAL Device"""
def test_devtype(self):
addr = 'df99881e-1911-11e6-afc5-f01faf41ecb3'
devtype = 'thermometer.basic'
dev = xAAL.devices.Device(devtype, addr)
self.assertEqual(devtype, dev.get_type())
def test_bad_address(self):
addr = 'df99881e-1911-11e6-afc5-f01faf41ecb3'
devtype = 'thermometer'
self.assertRaises(xAAL.devices.DeviceError, xAAL.devices.Device, devtype, addr)
def test_address(self):
addr = 'df99881e-1911-11e6-afc5-f01faf41ecb3'
devtype = 'thermometer.basic'
dev = xAAL.devices.Device(devtype, addr)
self.assertEqual(addr, dev.get_address())
def test_bad_address(self):
addr = 'df99881e-xxx-11e6-afc5-f01faf41ecb3'
devtype = 'thermometer.basic'
self.assertRaises(xAAL.devices.DeviceError, xAAL.devices.Device, devtype, addr)
if __name__ == "__main__":
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment