id
int64 0
843k
| repository_name
stringlengths 7
55
| file_path
stringlengths 9
332
| class_name
stringlengths 3
290
| human_written_code
stringlengths 12
4.36M
| class_skeleton
stringlengths 19
2.2M
| total_program_units
int64 1
9.57k
| total_doc_str
int64 0
4.2k
| AvgCountLine
float64 0
7.89k
| AvgCountLineBlank
float64 0
300
| AvgCountLineCode
float64 0
7.89k
| AvgCountLineComment
float64 0
7.89k
| AvgCyclomatic
float64 0
130
| CommentToCodeRatio
float64 0
176
| CountClassBase
float64 0
48
| CountClassCoupled
float64 0
589
| CountClassCoupledModified
float64 0
581
| CountClassDerived
float64 0
5.37k
| CountDeclInstanceMethod
float64 0
4.2k
| CountDeclInstanceVariable
float64 0
299
| CountDeclMethod
float64 0
4.2k
| CountDeclMethodAll
float64 0
4.2k
| CountLine
float64 1
115k
| CountLineBlank
float64 0
9.01k
| CountLineCode
float64 0
94.4k
| CountLineCodeDecl
float64 0
46.1k
| CountLineCodeExe
float64 0
91.3k
| CountLineComment
float64 0
27k
| CountStmt
float64 1
93.2k
| CountStmtDecl
float64 0
46.1k
| CountStmtExe
float64 0
90.2k
| MaxCyclomatic
float64 0
759
| MaxInheritanceTree
float64 0
16
| MaxNesting
float64 0
34
| SumCyclomatic
float64 0
6k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
140,248 |
Julian/jsonschema
|
Julian_jsonschema/jsonschema/exceptions.py
|
jsonschema.exceptions._RefResolutionError
|
class _RefResolutionError(Exception):
"""
A ref could not be resolved.
"""
_DEPRECATION_MESSAGE = (
"jsonschema.exceptions.RefResolutionError is deprecated as of version "
"4.18.0. If you wish to catch potential reference resolution errors, "
"directly catch referencing.exceptions.Unresolvable."
)
_cause: Exception
def __eq__(self, other):
if self.__class__ is not other.__class__:
return NotImplemented # pragma: no cover -- uncovered but deprecated # noqa: E501
return self._cause == other._cause
def __str__(self) -> str:
return str(self._cause)
|
class _RefResolutionError(Exception):
'''
A ref could not be resolved.
'''
def __eq__(self, other):
pass
def __str__(self) -> str:
pass
| 3 | 1 | 3 | 0 | 3 | 1 | 2 | 0.31 | 1 | 1 | 0 | 1 | 2 | 0 | 2 | 12 | 20 | 4 | 13 | 4 | 10 | 4 | 9 | 4 | 6 | 2 | 3 | 1 | 3 |
140,249 |
Julian/jsonschema
|
Julian_jsonschema/jsonschema/exceptions.py
|
jsonschema.exceptions._Error
|
class _Error(Exception):
_word_for_schema_in_error_message: ClassVar[str]
_word_for_instance_in_error_message: ClassVar[str]
def __init__(
self,
message: str,
validator: str = _unset, # type: ignore[assignment]
path: Iterable[str | int] = (),
cause: Exception | None = None,
context=(),
validator_value: Any = _unset,
instance: Any = _unset,
schema: Mapping[str, Any] | bool = _unset, # type: ignore[assignment]
schema_path: Iterable[str | int] = (),
parent: _Error | None = None,
type_checker: _types.TypeChecker = _unset, # type: ignore[assignment]
) -> None:
super().__init__(
message,
validator,
path,
cause,
context,
validator_value,
instance,
schema,
schema_path,
parent,
)
self.message = message
self.path = self.relative_path = deque(path)
self.schema_path = self.relative_schema_path = deque(schema_path)
self.context = list(context)
self.cause = self.__cause__ = cause
self.validator = validator
self.validator_value = validator_value
self.instance = instance
self.schema = schema
self.parent = parent
self._type_checker = type_checker
for error in context:
error.parent = self
def __repr__(self) -> str:
return f"<{self.__class__.__name__}: {self.message!r}>"
def __str__(self) -> str:
essential_for_verbose = (
self.validator, self.validator_value, self.instance, self.schema,
)
if any(m is _unset for m in essential_for_verbose):
return self.message
schema_path = _utils.format_as_index(
container=self._word_for_schema_in_error_message,
indices=list(self.relative_schema_path)[:-1],
)
instance_path = _utils.format_as_index(
container=self._word_for_instance_in_error_message,
indices=self.relative_path,
)
prefix = 16 * " "
return dedent(
f"""\
{self.message}
Failed validating {self.validator!r} in {schema_path}:
{_pretty(self.schema, prefix=prefix)}
On {instance_path}:
{_pretty(self.instance, prefix=prefix)}
""".rstrip(),
)
@classmethod
def create_from(cls, other: _Error):
return cls(**other._contents())
@property
def absolute_path(self) -> Sequence[str | int]:
parent = self.parent
if parent is None:
return self.relative_path
path = deque(self.relative_path)
path.extendleft(reversed(parent.absolute_path))
return path
@property
def absolute_schema_path(self) -> Sequence[str | int]:
parent = self.parent
if parent is None:
return self.relative_schema_path
path = deque(self.relative_schema_path)
path.extendleft(reversed(parent.absolute_schema_path))
return path
@property
def json_path(self) -> str:
path = "$"
for elem in self.absolute_path:
if isinstance(elem, int):
path += "[" + str(elem) + "]"
else:
path += "." + elem
return path
def _set(
self,
type_checker: _types.TypeChecker | None = None,
**kwargs: Any,
) -> None:
if type_checker is not None and self._type_checker is _unset:
self._type_checker = type_checker
for k, v in kwargs.items():
if getattr(self, k) is _unset:
setattr(self, k, v)
def _contents(self):
attrs = (
"message", "cause", "context", "validator", "validator_value",
"path", "schema_path", "instance", "schema", "parent",
)
return {attr: getattr(self, attr) for attr in attrs}
def _matches_type(self) -> bool:
try:
# We ignore this as we want to simply crash if this happens
expected = self.schema["type"] # type: ignore[index]
except (KeyError, TypeError):
return False
if isinstance(expected, str):
return self._type_checker.is_type(self.instance, expected)
return any(
self._type_checker.is_type(self.instance, expected_type)
for expected_type in expected
)
|
class _Error(Exception):
def __init__(
self,
message: str,
validator: str = _unset, # type: ignore[assignment]
path: Iterable[str | int] = (),
cause:
pass
def __repr__(self) -> str:
pass
def __str__(self) -> str:
pass
@classmethod
def create_from(cls, other: _Error):
pass
@property
def absolute_path(self) -> Sequence[str | int]:
pass
@property
def absolute_schema_path(self) -> Sequence[str | int]:
pass
@property
def json_path(self) -> str:
pass
def _set(
self,
type_checker: _types.TypeChecker | None = None,
**kwargs: Any,
) -> None:
pass
def _contents(self):
pass
def _matches_type(self) -> bool:
pass
| 15 | 0 | 13 | 1 | 12 | 1 | 2 | 0.04 | 1 | 13 | 0 | 2 | 9 | 14 | 10 | 20 | 145 | 21 | 123 | 57 | 91 | 5 | 68 | 36 | 57 | 4 | 3 | 2 | 21 |
140,250 |
Julian/libopenzwave-cffi
|
Julian_libopenzwave-cffi/libopenzwave/manager.py
|
libopenzwave.manager.PyManager
|
class PyManager(object):
COMMAND_CLASS_DESC = COMMAND_CLASS_DESC
@classmethod
def getOzwLibraryVersion(cls):
return ffi.string(lib.CManagerGetVersionAsString())
def create(self):
self.manager = ffi.gc(lib.newCManager(), lib.destroyCManager)
def addWatcher(self, callback):
context = ffi.new_handle(callback)
self._watcherCallbackSavedReference = context
if not lib.CManagerAddWatcher(
self.manager,
lib.do_manager_watcher_callback,
context,
):
assert False
def removeWatcher(self, _):
# NOTE: not sure why the arg here is unused, but it is in the original
# code too. Probably at very least it should be used to check
# that the handle we saved was to that pythonFunc
try:
assert lib.CManagerRemoveWatcher(
self.manager,
lib.do_manager_watcher_callback,
self._watcherCallbackSavedReference,
)
finally:
self._watcherCallbackSavedReference = None
def getDriverStatistics(self, homeId):
data = ffi.new("DriverData *")
statistics = lib.CManagerGetDriverStatistics(
self.manager, homeId, data,
)
return statistics
def getPythonLibraryVersion(self):
version = self.getPythonLibraryVersionNumber()
return "python-openzwave+cffi v%s" % (version,)
def getPythonLibraryVersionNumber(self):
return __version__
def getNodeClassInformation(self, homeId, nodeId, commandClassId):
className, classVersion = ffi.new("char **"), ffi.new("uint8_t *")
return lib.CManagerGetNodeClassInformation(
self.manager,
homeId,
nodeId,
commandClassId,
className,
classVersion,
)
def getNodeNeighbors(self, homeId, nodeId):
neighbors = ffi.new("uint8_t*[29]")
count = lib.CManagerGetNodeNeighbors(
self.manager, homeId, nodeId, neighbors,
)
return list(neighbors[0][0:count])
|
class PyManager(object):
@classmethod
def getOzwLibraryVersion(cls):
pass
def create(self):
pass
def addWatcher(self, callback):
pass
def removeWatcher(self, _):
pass
def getDriverStatistics(self, homeId):
pass
def getPythonLibraryVersion(self):
pass
def getPythonLibraryVersionNumber(self):
pass
def getNodeClassInformation(self, homeId, nodeId, commandClassId):
pass
def getNodeNeighbors(self, homeId, nodeId):
pass
| 11 | 0 | 6 | 0 | 5 | 0 | 1 | 0.06 | 1 | 1 | 0 | 0 | 8 | 2 | 9 | 9 | 65 | 10 | 52 | 21 | 41 | 3 | 31 | 20 | 21 | 2 | 1 | 1 | 10 |
140,251 |
Julian/libopenzwave-cffi
|
Julian_libopenzwave-cffi/libopenzwave/_global.py
|
libopenzwave._global.PyOptions
|
class PyOptions(object):
"""
Manage options manager
"""
def __init__(self, config_path=None, user_path=".", cmd_line=""):
"""
Create an option object and check that parameters are valid.
:param device: The device to use
:type device: str
:param config_path: The openzwave config directory. If None, try to configure automatically.
:type config_path: str
:param user_path: The user directory
:type user_path: str
:param cmd_line: The "command line" options of the openzwave library
:type cmd_line: str
"""
if config_path is None:
config_path = self.getConfigPath()
if config_path is None:
raise LibZWaveException("Can't autoconfigure path to config")
self._config_path = config_path
if user_path is None:
user_path = "."
self._user_path = user_path
if cmd_line is None:
cmd_line=""
self._cmd_line = cmd_line
self.create(self._config_path, self._user_path, self._cmd_line)
def create(self, a, b, c):
"""
.. _createoptions:
Create an option object used to start the manager
:param a: The path of the config directory
:type a: str
:param b: The path of the user directory
:type b: str
:param c: The "command line" options of the openzwave library
:type c: str
:see: destroyoptions_
"""
self.options = CreateOptions(
str_to_cppstr(a), str_to_cppstr(b), str_to_cppstr(c))
return True
def destroy(self):
"""
.. _destroyoptions:
Deletes the Options and cleans up any associated objects.
The application is responsible for destroying the Options object,
but this must not be done until after the Manager object has been
destroyed.
:return: The result of the operation.
:rtype: bool
:see: createoptions_
"""
return self.options.Destroy()
def lock(self):
"""
.. _lock:
Lock the options. Needed to start the manager
:return: The result of the operation.
:rtype: bool
:see: areLocked_
"""
return self.options.Lock()
def areLocked(self):
'''
.. _areLocked:
Test whether the options have been locked.
:return: true if the options have been locked.
:rtype: boolean
:see: lock_
'''
return self.options.AreLocked()
def addOptionBool(self, name, value):
"""
.. _addOptionBool:
Add a boolean option.
:param name: The name of the option.
:type name: str
:param value: The value of the option.
:type value: boolean
:return: The result of the operation.
:rtype: bool
:see: addOption_, addOptionInt_, addOptionString_
"""
return self.options.AddOptionBool(str_to_cppstr(name), value)
def addOptionInt(self, name, value):
"""
.. _addOptionInt:
Add an integer option.
:param name: The name of the option.
:type name: str
:param value: The value of the option.
:type value: boolean
:return: The result of the operation.
:rtype: bool
:see: addOption_, addOptionBool_, addOptionString_
"""
return self.options.AddOptionInt(str_to_cppstr(name), value)
def addOptionString(self, name, value, append=False):
"""
.. _addOptionString:
Add a string option.
:param name: The name of the option. Option names are case insensitive and must be unique.
:type name: str
:param value: The value of the option.
:type value: str
:param append: Setting append to true will cause values read from the command line
or XML file to be concatenated into a comma delimited set. If _append is false,
newer values will overwrite older ones.
:type append: boolean
:return: The result of the operation.
:rtype: bool
:see: addOption_, addOptionBool_, addOptionInt_
"""
return self.options.AddOptionString(
str_to_cppstr(name), str_to_cppstr(value), append)
def addOption(self, name, value):
"""
.. _addOption:
Add an option.
:param name: The name of the option.
:type name: string
:param value: The value of the option.
:type value: boolean, integer, string
:return: The result of the operation.
:rtype: bool
:see: addOptionBool_, addOptionInt_, addOptionString_
"""
if name not in PyOptionList:
return False
if PyOptionList[name]['type'] == "String":
return self.addOptionString(name, value)
elif PyOptionList[name]['type'] == "Bool":
return self.addOptionBool(name, value)
elif PyOptionList[name]['type'] == "Int":
return self.addOptionInt(name, value)
return False
def getOption(self, name):
"""
.. _getOption:
Retrieve option of a value.
:param name: The name of the option.
:type name: string
:return: The value
:rtype: boolean, integer, string or None
:see: getOptionAsBool_, getOptionAsInt_, getOptionAsString_
"""
if name not in PyOptionList:
return None
if PyOptionList[name]['type'] == "String":
return self.getOptionAsString(name)
elif PyOptionList[name]['type'] == "Bool":
return self.getOptionAsBool(name)
elif PyOptionList[name]['type'] == "Int":
return self.getOptionAsInt(name)
return False
# def getOptionAsBool(self, name):
# """
# .. _getOptionAsBool:
#
# Retrieve boolean value of an option.
#
# :param name: The name of the option.
# :type name: string
# :return: The value or None
# :rtype: boolean or None
#
# :see: getOption_, getOptionAsInt_, getOptionAsString_
#
# """
# cdef bool type_bool
# cret = self.options.GetOptionAsBool(str_to_cppstr(name), &type_bool)
# ret = type_bool if cret==True else None
# return ret
#
# def getOptionAsInt(self, name):
# """
# .. _getOptionAsInt:
#
# Retrieve integer value of an option.
#
# :param name: The name of the option.
# :type name: string
# :return: The value or None
# :rtype: Integer or None
#
# :see: getOption_, getOptionAsBool_, getOptionAsString_
#
# """
# cdef int32_t type_int
# cret = self.options.GetOptionAsInt(str_to_cppstr(name), &type_int)
# ret = type_int if cret==True else None
# return ret
#
# def getOptionAsString(self, name):
# """
# .. _getOptionAsString:
#
# Retrieve string value of an option.
#
# :param name: The name of the option.
# :type name: string
# :return: The value or None
# :rtype: String or None
#
# :see: getOption_, getOptionAsBool_, getOptionAsInt_
#
# """
# cdef string type_string
# cret = self.options.GetOptionAsString(str_to_cppstr(name), &type_string)
# ret = cstr_to_str(type_string.c_str()) if cret==True else None
# return ret
def getConfigPath(self):
'''
.. _getConfigPath:
Retrieve the config path. This directory hold the xml files.
:return: A string containing the library config path or None.
:rtype: str
'''
return configPath()
|
class PyOptions(object):
'''
Manage options manager
'''
def __init__(self, config_path=None, user_path=".", cmd_line=""):
'''
Create an option object and check that parameters are valid.
:param device: The device to use
:type device: str
:param config_path: The openzwave config directory. If None, try to configure automatically.
:type config_path: str
:param user_path: The user directory
:type user_path: str
:param cmd_line: The "command line" options of the openzwave library
:type cmd_line: str
'''
pass
def create(self, a, b, c):
'''
.. _createoptions:
Create an option object used to start the manager
:param a: The path of the config directory
:type a: str
:param b: The path of the user directory
:type b: str
:param c: The "command line" options of the openzwave library
:type c: str
:see: destroyoptions_
'''
pass
def destroy(self):
'''
.. _destroyoptions:
Deletes the Options and cleans up any associated objects.
The application is responsible for destroying the Options object,
but this must not be done until after the Manager object has been
destroyed.
:return: The result of the operation.
:rtype: bool
:see: createoptions_
'''
pass
def lock(self):
'''
.. _lock:
Lock the options. Needed to start the manager
:return: The result of the operation.
:rtype: bool
:see: areLocked_
'''
pass
def areLocked(self):
'''
.. _areLocked:
Test whether the options have been locked.
:return: true if the options have been locked.
:rtype: boolean
:see: lock_
'''
pass
def addOptionBool(self, name, value):
'''
.. _addOptionBool:
Add a boolean option.
:param name: The name of the option.
:type name: str
:param value: The value of the option.
:type value: boolean
:return: The result of the operation.
:rtype: bool
:see: addOption_, addOptionInt_, addOptionString_
'''
pass
def addOptionInt(self, name, value):
'''
.. _addOptionInt:
Add an integer option.
:param name: The name of the option.
:type name: str
:param value: The value of the option.
:type value: boolean
:return: The result of the operation.
:rtype: bool
:see: addOption_, addOptionBool_, addOptionString_
'''
pass
def addOptionString(self, name, value, append=False):
'''
.. _addOptionString:
Add a string option.
:param name: The name of the option. Option names are case insensitive and must be unique.
:type name: str
:param value: The value of the option.
:type value: str
:param append: Setting append to true will cause values read from the command line
or XML file to be concatenated into a comma delimited set. If _append is false,
newer values will overwrite older ones.
:type append: boolean
:return: The result of the operation.
:rtype: bool
:see: addOption_, addOptionBool_, addOptionInt_
'''
pass
def addOptionBool(self, name, value):
'''
.. _addOption:
Add an option.
:param name: The name of the option.
:type name: string
:param value: The value of the option.
:type value: boolean, integer, string
:return: The result of the operation.
:rtype: bool
:see: addOptionBool_, addOptionInt_, addOptionString_
'''
pass
def getOption(self, name):
'''
.. _getOption:
Retrieve option of a value.
:param name: The name of the option.
:type name: string
:return: The value
:rtype: boolean, integer, string or None
:see: getOptionAsBool_, getOptionAsInt_, getOptionAsString_
'''
pass
def getConfigPath(self):
'''
.. _getConfigPath:
Retrieve the config path. This directory hold the xml files.
:return: A string containing the library config path or None.
:rtype: str
'''
pass
| 12 | 12 | 18 | 4 | 5 | 10 | 2 | 3.17 | 1 | 0 | 0 | 0 | 11 | 4 | 11 | 11 | 275 | 54 | 53 | 16 | 41 | 168 | 47 | 16 | 35 | 5 | 1 | 1 | 23 |
140,252 |
Julian/libopenzwave-cffi
|
Julian_libopenzwave-cffi/libopenzwave/options.py
|
libopenzwave.options.PyOptions
|
class PyOptions(object):
def __init__(self, config_path, user_path=".", cmd_line=""):
self._config_path = config_path
self._user_path = user_path
self._cmd_line = cmd_line
self.create()
def create(self):
cOptions = lib.newCOptions(
self._config_path, self._user_path, self._cmd_line,
)
assert cOptions
self.options = ffi.gc(cOptions, lib.destroyCOptions)
return True
def addOptionBool(self, name, value):
return lib.COptionsAddBool(self.options, name, value)
def addOptionInt(self, name, value):
return lib.COptionsAddInt(self.options, name, value)
def addOptionString(self, name, value, append=False):
return lib.COptionsAddString(self.options, name, value, append)
def lock(self):
return lib.COptionsLock(self.options)
def areLocked(self):
return lib.COptionsAreLocked(self.options)
|
class PyOptions(object):
def __init__(self, config_path, user_path=".", cmd_line=""):
pass
def create(self):
pass
def addOptionBool(self, name, value):
pass
def addOptionInt(self, name, value):
pass
def addOptionString(self, name, value, append=False):
pass
def lock(self):
pass
def areLocked(self):
pass
| 8 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 7 | 4 | 7 | 7 | 29 | 6 | 23 | 13 | 15 | 0 | 21 | 13 | 13 | 1 | 1 | 0 | 7 |
140,253 |
Julian/libopenzwave-cffi
|
Julian_libopenzwave-cffi/libopenzwave/_global.py
|
libopenzwave._global.EnumWithDoc
|
class EnumWithDoc(str):
"""Enum helper"""
def setDoc(self, doc):
self.doc = doc
return self
|
class EnumWithDoc(str):
'''Enum helper'''
def setDoc(self, doc):
pass
| 2 | 1 | 3 | 0 | 3 | 0 | 1 | 0.25 | 1 | 0 | 0 | 0 | 1 | 1 | 1 | 67 | 5 | 0 | 4 | 3 | 2 | 1 | 4 | 3 | 2 | 1 | 2 | 0 | 1 |
140,254 |
Julian/txmusicbrainz
|
Julian_txmusicbrainz/txmusicbrainz/tests/test_client.py
|
txmusicbrainz.tests.test_client.TestMusicBrainzInit
|
class TestMusicBrainzInit(TestCase):
def test_user_agent(self):
client = MusicBrainz(
app_name="test",
app_version="0.1.0",
contact_info="me@example.com",
)
self.assertEqual(client.user_agent, "test/0.1.0 (me@example.com)")
|
class TestMusicBrainzInit(TestCase):
def test_user_agent(self):
pass
| 2 | 0 | 7 | 0 | 7 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 73 | 8 | 0 | 8 | 3 | 6 | 0 | 4 | 3 | 2 | 1 | 2 | 0 | 1 |
140,255 |
Julian/txmusicbrainz
|
Julian_txmusicbrainz/txmusicbrainz/client.py
|
txmusicbrainz.client.MusicBrainz
|
class MusicBrainz(object):
"""
A MusicBrainz client.
Typical usage:
>>> import my_cool_app
>>> MusicBrainz(
... app_name=my_cool_app.__name__,
... app_version=my_cool_app.__version__,
... contact_info="https://github.com/Julian/MyCoolApp",
... )
The first arguments taken by this client are required in order
to comply with MusicBrainz's request to be able to reach out to
application developers whose applications exceed `rate limiting
requirements <https://musicbrainz.org/doc/XML_Web_Service/Rate_Limiting>`
\ .
:argument str app_name: the name of the application which will
communicate with MusicBrainz
:argument str app_version: the version of the application which
will communicate with MusicBrainz
:argument str contact_info: an email or URL suitable for contact
purposes by MusicBrainz
Additional arguments:
:argument IReactor reactor: a Twisted reactor to use
:argument str root_url: the root API URL
"""
artists = entity_retriever(
path="/artist",
available_includes=frozenset(
["recordings", "releases", "release-groups", "works"],
),
)
labels = entity_retriever(
path="/label", available_includes=frozenset(["releases"]),
)
recordings = entity_retriever(
path="/recording",
available_includes=frozenset(["artists", "releases"]),
)
releases = entity_retriever(
path="/release",
available_includes=frozenset(
["artists", "labels", "recordings", "release-groups"],
),
)
release_groups = entity_retriever(
path="/release-group", available_includes=["artists", "releases"],
)
works = entity_retriever(path="/work")
areas = entity_retriever(path="/area")
urls = entity_retriever(path="/url")
def __init__(
self,
app_name,
app_version,
contact_info,
reactor=None,
root_url="http://musicbrainz.org/ws/2",
):
if reactor is None:
from twisted.internet import reactor
self.reactor = reactor
self.root_url = root_url
self.user_agent = "{0}/{1} ({2})".format(
app_name, app_version, contact_info,
)
def request(self, path, method="GET", headers=None, **kwargs):
if headers is None:
headers = Headers()
headers.addRawHeader("User-Agent", self.user_agent)
return request(
method,
headers=headers,
url=self.root_url + path,
params=[("fmt", "json")],
reactor=self.reactor,
**kwargs
).addCallback(json_content).addCallback(_check_for_errors)
|
class MusicBrainz(object):
'''
A MusicBrainz client.
Typical usage:
>>> import my_cool_app
>>> MusicBrainz(
... app_name=my_cool_app.__name__,
... app_version=my_cool_app.__version__,
... contact_info="https://github.com/Julian/MyCoolApp",
... )
The first arguments taken by this client are required in order
to comply with MusicBrainz's request to be able to reach out to
application developers whose applications exceed `rate limiting
requirements <https://musicbrainz.org/doc/XML_Web_Service/Rate_Limiting>`
\ .
:argument str app_name: the name of the application which will
communicate with MusicBrainz
:argument str app_version: the version of the application which
will communicate with MusicBrainz
:argument str contact_info: an email or URL suitable for contact
purposes by MusicBrainz
Additional arguments:
:argument IReactor reactor: a Twisted reactor to use
:argument str root_url: the root API URL
'''
def __init__(
self,
app_name,
app_version,
contact_info,
reactor=None,
root_url="http://musicbrainz.org/ws/2",
):
pass
def request(self, path, method="GET", headers=None, **kwargs):
pass
| 3 | 1 | 15 | 1 | 14 | 0 | 2 | 0.45 | 1 | 0 | 0 | 0 | 2 | 3 | 2 | 2 | 89 | 12 | 53 | 22 | 42 | 24 | 20 | 15 | 16 | 2 | 1 | 1 | 4 |
140,256 |
Julian/txmusicbrainz
|
Julian_txmusicbrainz/txmusicbrainz/client.py
|
txmusicbrainz.client.APIError
|
class APIError(Exception):
"""
A request to the API resulted in an error.
"""
|
class APIError(Exception):
'''
A request to the API resulted in an error.
'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 10 | 5 | 1 | 1 | 1 | 0 | 3 | 1 | 1 | 0 | 0 | 3 | 0 | 0 |
140,257 |
Julian/txmusicbrainz
|
Julian_txmusicbrainz/txmusicbrainz/_entities.py
|
txmusicbrainz._entities.BoundEntityRetriever
|
class BoundEntityRetriever(object):
def __init__(self, client, path, available_includes):
self.available_includes = available_includes
self.client = client
self.path = path
def lookup(self, mbid, include=()):
"""
Lookup an entity directly from a specified :term:`MBID`\ .
"""
if include:
for included in include:
if included not in self.available_includes:
raise ValueError(
"{0!r} is not an includable entity for {1}".format(
included, self.path,
),
)
query_string = "?" + urlencode([("inc", " ".join(include))])
else:
query_string = ""
path = "{0}/{1}{2}".format(self.path, mbid, query_string)
return self.client.request(path)
def search(self, query):
"""
Perform a (Lucene) search of the entity.
:argument str query: a properly escaped Lucene query
"""
return self.client.request(
self.path + "?" + urlencode([("query", query)]),
)
|
class BoundEntityRetriever(object):
def __init__(self, client, path, available_includes):
pass
def lookup(self, mbid, include=()):
'''
Lookup an entity directly from a specified :term:`MBID`\ .
'''
pass
def search(self, query):
'''
Perform a (Lucene) search of the entity.
:argument str query: a properly escaped Lucene query
'''
pass
| 4 | 2 | 12 | 2 | 7 | 2 | 2 | 0.3 | 1 | 1 | 0 | 0 | 3 | 3 | 3 | 3 | 38 | 8 | 23 | 10 | 19 | 7 | 16 | 10 | 12 | 4 | 1 | 3 | 6 |
140,258 |
JulianKahnert/geizhals
|
JulianKahnert_geizhals/tests/domains.py
|
domains.TestStringMethods
|
class TestStringMethods(unittest.TestCase):
# test with ID
@except_httperror
def test_ID_AT(self):
gh = Geizhals(1688629, "AT")
device = gh.parse()
# avoid banning from website
sleep(uniform(1, 10))
self.assertEqual(device.name, "Apple iPhone X 64GB grau")
@except_httperror
def test_ID_EU(self):
gh = Geizhals(1688629, "EU")
device = gh.parse()
# avoid banning from website
sleep(uniform(1, 10))
self.assertEqual(device.name, "Apple iPhone X 64GB grau")
@except_httperror
def test_ID_DE(self):
gh = Geizhals(1688629, "DE")
device = gh.parse()
# avoid banning from website
sleep(uniform(1, 10))
self.assertEqual(device.name, "Apple iPhone X 64GB grau")
@except_httperror
def test_ID_UK(self):
gh = Geizhals(1688629, "UK")
device = gh.parse()
# avoid banning from website
sleep(uniform(1, 10))
self.assertEqual(device.name, "Apple iPhone X 64GB grey")
@except_httperror
def test_ID_PL(self):
gh = Geizhals(1688629, "PL")
device = gh.parse()
# avoid banning from website
sleep(uniform(1, 10))
self.assertEqual(device.name, "Apple iPhone X 64GB szary")
# test with URL
@except_httperror
def test_URL_AT(self):
gh = Geizhals("https://geizhals.at/apple-iphone-x-64gb-grau-a1688629.html", "AT")
device = gh.parse()
# avoid banning from website
sleep(uniform(1, 10))
self.assertEqual(device.name, "Apple iPhone X 64GB grau")
@except_httperror
def test_URL_EU(self):
gh = Geizhals("https://geizhals.eu/apple-iphone-x-64gb-grau-a1688629.html", "EU")
device = gh.parse()
# avoid banning from website
sleep(uniform(1, 10))
self.assertEqual(device.name, "Apple iPhone X 64GB grau")
@except_httperror
def test_URL_DE(self):
gh = Geizhals("https://geizhals.de/apple-iphone-x-64gb-grau-a1688629.html", "DE")
device = gh.parse()
# avoid banning from website
sleep(uniform(1, 10))
self.assertEqual(device.name, "Apple iPhone X 64GB grau")
@except_httperror
def test_URL_UK(self):
gh = Geizhals("https://cenowarka.pl/apple-iphone-x-64gb-szary-a1688629.html", "UK")
device = gh.parse()
# avoid banning from website
sleep(uniform(1, 10))
self.assertEqual(device.name, "Apple iPhone X 64GB grey")
@except_httperror
def test_URL_PL(self):
gh = Geizhals("https://cenowarka.pl/apple-iphone-x-64gb-szary-a1688629.html", "PL")
device = gh.parse()
# avoid banning from website
sleep(uniform(1, 10))
self.assertEqual(device.name, "Apple iPhone X 64GB szary")
|
class TestStringMethods(unittest.TestCase):
@except_httperror
def test_ID_AT(self):
pass
@except_httperror
def test_ID_EU(self):
pass
@except_httperror
def test_ID_DE(self):
pass
@except_httperror
def test_ID_UK(self):
pass
@except_httperror
def test_ID_PL(self):
pass
@except_httperror
def test_URL_AT(self):
pass
@except_httperror
def test_URL_EU(self):
pass
@except_httperror
def test_URL_DE(self):
pass
@except_httperror
def test_URL_UK(self):
pass
@except_httperror
def test_URL_PL(self):
pass
| 21 | 0 | 8 | 2 | 5 | 1 | 1 | 0.2 | 1 | 1 | 1 | 0 | 10 | 0 | 10 | 82 | 103 | 30 | 61 | 41 | 40 | 12 | 51 | 31 | 40 | 1 | 2 | 0 | 10 |
140,259 |
JulianKahnert/geizhals
|
JulianKahnert_geizhals/geizhals/geizhals.py
|
geizhals.geizhals.Device
|
class Device():
"""Device data which gets parsed by Geizhals."""
def __init__(self):
"""Initialize device data."""
self.name = ''
self.prices = []
self.price_currency = ''
def __repr__(self):
"""Call pretty print to get all informaiton."""
return self.__str__()
def __str__(self):
"""Pretty-Print all the device data."""
return """
Name: {}
Prices: {}
Currency: {}
""".format(self.name,
self.prices,
self.price_currency)
|
class Device():
'''Device data which gets parsed by Geizhals.'''
def __init__(self):
'''Initialize device data.'''
pass
def __repr__(self):
'''Call pretty print to get all informaiton.'''
pass
def __str__(self):
'''Pretty-Print all the device data.'''
pass
| 4 | 4 | 6 | 0 | 5 | 1 | 1 | 0.27 | 0 | 0 | 0 | 0 | 3 | 3 | 3 | 3 | 22 | 3 | 15 | 7 | 11 | 4 | 9 | 7 | 5 | 1 | 0 | 0 | 3 |
140,260 |
JulianKahnert/geizhals
|
JulianKahnert_geizhals/geizhals/geizhals.py
|
geizhals.geizhals.Domain
|
class Domain(Enum):
"""Possible localisations."""
AT = 'geizhals.at'
EU = 'geizhals.eu'
DE = 'geizhals.de'
UK = 'skinflint.co.uk'
PL = 'cenowarka.pl'
|
class Domain(Enum):
'''Possible localisations.'''
pass
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.17 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 49 | 8 | 1 | 6 | 6 | 5 | 1 | 6 | 6 | 5 | 0 | 4 | 0 | 0 |
140,261 |
JulianKahnert/geizhals
|
JulianKahnert_geizhals/geizhals/geizhals.py
|
geizhals.geizhals.Geizhals
|
class Geizhals():
"""Implementation of Geizhals."""
def __init__(self, id_or_url, locale='DE'):
"""Initialize the sensor."""
self.locale = Domain[locale].value
# get the id from a URL
self.product_id = _url2id(id_or_url)
# save parsed data
self.device = Device()
def parse(self):
"""Get new data, parses it and returns a device."""
# fetch data
sess = requests.session()
request = sess.get('https://{}/{}'.format(self.locale,
self.product_id),
allow_redirects=True,
timeout=2)
sess.close()
# raise exception, e.g. if we are blocked because of too many requests
request.raise_for_status()
soup = BeautifulSoup(request.text, 'html.parser')
# parse name
raw = soup.find('h1', attrs={'class': 'gh-headline'})
self.device.name = raw.string.replace('\n', '')
# parse prices
self.device.prices = []
for tmp in soup.select('div.offer__price .gh_price'):
matches = re.search(_REGEX, tmp.string)
raw = '{}.{}'.format(matches.group(1),
matches.group(2))
self.device.prices += [float(raw)]
# parse unit
price_match = soup.find('span', attrs={'class': 'gh_price'})
matches = re.search(r'€|£|PLN', price_match.string)
self.device.price_currency = matches.group()
return self.device
|
class Geizhals():
'''Implementation of Geizhals.'''
def __init__(self, id_or_url, locale='DE'):
'''Initialize the sensor.'''
pass
def parse(self):
'''Get new data, parses it and returns a device.'''
pass
| 3 | 3 | 21 | 4 | 13 | 5 | 2 | 0.38 | 0 | 4 | 2 | 0 | 2 | 3 | 2 | 2 | 46 | 10 | 26 | 13 | 23 | 10 | 22 | 13 | 19 | 2 | 0 | 1 | 3 |
140,262 |
JulianKahnert/geizhals
|
JulianKahnert_geizhals/tests/id2url.py
|
id2url.TestStringMethods
|
class TestStringMethods(unittest.TestCase):
@except_httperror
def test_URL_AT(self):
id = geizhals._url2id("https://geizhals.at/bose-quietcomfort-35-ii-schwarz-a1696985.html")
# avoid banning from website
sleep(uniform(1, 10))
self.assertEqual(id, "1696985")
@except_httperror
def test_URL_EU(self):
id = geizhals._url2id("https://geizhals.eu/bose-quietcomfort-35-ii-schwarz-a1696985.html")
# avoid banning from website
sleep(uniform(1, 10))
self.assertEqual(id, "1696985")
@except_httperror
def test_URL_DE(self):
id = geizhals._url2id("https://geizhals.de/bose-quietcomfort-35-ii-schwarz-a1696985.html")
# avoid banning from website
sleep(uniform(1, 10))
self.assertEqual(id, "1696985")
@except_httperror
def test_URL_UK(self):
id = geizhals._url2id("https://skinflint.co.uk/bose-quietcomfort-35-ii-black-a1696985.html")
# avoid banning from website
sleep(uniform(1, 10))
self.assertEqual(id, "1696985")
@except_httperror
def test_URL_PL(self):
id = geizhals._url2id("https://cenowarka.pl/bose-quietcomfort-35-ii-czarny-a1696985.html")
# avoid banning from website
sleep(uniform(1, 10))
self.assertEqual(id, "1696985")
|
class TestStringMethods(unittest.TestCase):
@except_httperror
def test_URL_AT(self):
pass
@except_httperror
def test_URL_EU(self):
pass
@except_httperror
def test_URL_DE(self):
pass
@except_httperror
def test_URL_UK(self):
pass
@except_httperror
def test_URL_PL(self):
pass
| 11 | 0 | 7 | 2 | 4 | 1 | 1 | 0.19 | 1 | 0 | 0 | 0 | 5 | 0 | 5 | 77 | 47 | 16 | 26 | 11 | 15 | 5 | 21 | 6 | 15 | 1 | 2 | 0 | 5 |
140,263 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_local_time_req_test.py
|
test.frame_get_local_time_req_test.TestFrameGetLocalTimeRequest
|
class TestFrameGetLocalTimeRequest(unittest.TestCase):
"""Test class for FrameGetLocalTimeRequest."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FrameGetLocalTimeRequest with NO_TYPE."""
frame = FrameGetLocalTimeRequest()
self.assertEqual(bytes(frame), b"\x00\x03\x20\x04\x27")
def test_frame_from_raw(self):
"""Test parse FrameGetLocalTimeRequest from raw."""
frame = frame_from_raw(b"\x00\x03\x20\x04\x27")
self.assertTrue(isinstance(frame, FrameGetLocalTimeRequest))
def test_str(self):
"""Test string representation of FrameGetLocalTimeRequest."""
frame = FrameGetLocalTimeRequest()
self.assertEqual(str(frame), "<FrameGetLocalTimeRequest/>")
|
class TestFrameGetLocalTimeRequest(unittest.TestCase):
'''Test class for FrameGetLocalTimeRequest.'''
def test_bytes(self):
'''Test FrameGetLocalTimeRequest with NO_TYPE.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetLocalTimeRequest from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetLocalTimeRequest.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.5 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 19 | 4 | 10 | 7 | 6 | 5 | 10 | 7 | 6 | 1 | 2 | 0 | 3 |
140,264 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_all_nodes_information_req_test.py
|
test.frame_get_all_nodes_information_req_test.TestFrameGetAllNodesInformationRequest
|
class TestFrameGetAllNodesInformationRequest(unittest.TestCase):
"""Test class for FrameGetAllNodesInformationRequest."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FrameGetAllNodesInformationRequest with NO_TYPE."""
frame = FrameGetAllNodesInformationRequest()
self.assertEqual(bytes(frame), b"\x00\x03\x02\x02\x03")
def test_frame_from_raw(self):
"""Test parse FrameGetAllNodesInformationRequest from raw."""
frame = frame_from_raw(b"\x00\x03\x02\x02\x03")
self.assertTrue(isinstance(frame, FrameGetAllNodesInformationRequest))
def test_str(self):
"""Test string representation of FrameGetAllNodesInformationRequest."""
frame = FrameGetAllNodesInformationRequest()
self.assertEqual(str(frame), "<FrameGetAllNodesInformationRequest/>")
|
class TestFrameGetAllNodesInformationRequest(unittest.TestCase):
'''Test class for FrameGetAllNodesInformationRequest.'''
def test_bytes(self):
'''Test FrameGetAllNodesInformationRequest with NO_TYPE.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetAllNodesInformationRequest from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetAllNodesInformationRequest.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.5 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 19 | 4 | 10 | 7 | 6 | 5 | 10 | 7 | 6 | 1 | 2 | 0 | 3 |
140,265 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_all_nodes_information_ntf_test.py
|
test.frame_get_all_nodes_information_ntf_test.TestFrameGetAllNodesInformationNotification
|
class TestFrameGetAllNodesInformationNotification(unittest.TestCase):
"""Test class for FrameGetAllNodesInformationNotification."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = (
b"\x00\x7f\x02\x04\x17\x04\xd2\x02Fnord23\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x01\x00@\x17\r\x01\x01\x07\x01\x02"
+ b"\x03\x04\x05\x06\x06\x08\x01\x00\x0c\x00{\x04\xd2\t)\r\x80\x11"
+ b"\xd7\x00\x01\x03\x03\x02\x03\x0501234567890123456789\x71"
)
def test_bytes(self) -> None:
"""Test FrameGetAllNodesInformationNotification."""
frame = FrameGetAllNodesInformationNotification()
frame.node_id = 23
frame.order = 1234
frame.placement = 2
frame.name = "Fnord23"
frame.velocity = Velocity.SILENT
frame.node_type = NodeTypeWithSubtype.INTERIOR_VENETIAN_BLIND
frame.product_group = 23
frame.product_type = 13
frame.node_variation = NodeVariation.TOPHUNG
frame.power_mode = 1
frame.build_number = 7
frame.serial_number = "01:02:03:04:05:06:06:08"
frame.state = OperatingState.ERROR_EXECUTING
frame.current_position = Position(position=12)
frame.target = Position(position=123)
frame.current_position_fp1 = Position(position=1234)
frame.current_position_fp2 = Position(position=2345)
frame.current_position_fp3 = Position(position=3456)
frame.current_position_fp4 = Position(position=4567)
frame.remaining_time = 1
frame.timestamp = 50528771
frame.alias_array = AliasArray(raw=b"\x0501234567890123456789")
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self) -> None:
"""Test parse FrameGetAllNodesInformationNotification from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameGetAllNodesInformationNotification))
self.assertEqual(frame.node_id, 23)
self.assertEqual(frame.order, 1234)
self.assertEqual(frame.placement, 2)
self.assertEqual(frame.name, "Fnord23")
self.assertEqual(frame.velocity, Velocity.SILENT)
self.assertEqual(frame.node_type, NodeTypeWithSubtype.INTERIOR_VENETIAN_BLIND)
self.assertEqual(frame.product_group, 23)
self.assertEqual(frame.product_type, 13)
self.assertEqual(frame.node_variation, NodeVariation.TOPHUNG)
self.assertEqual(frame.power_mode, 1)
self.assertEqual(frame.build_number, 7)
self.assertEqual(frame.serial_number, "01:02:03:04:05:06:06:08")
self.assertEqual(frame.state, OperatingState.ERROR_EXECUTING)
self.assertEqual(Position(frame.current_position).position, 12)
self.assertEqual(Position(frame.target).position, 123)
self.assertEqual(Position(frame.current_position_fp1).position, 1234)
self.assertEqual(Position(frame.current_position_fp2).position, 2345)
self.assertEqual(Position(frame.current_position_fp3).position, 3456)
self.assertEqual(Position(frame.current_position_fp4).position, 4567)
self.assertEqual(frame.remaining_time, 1)
self.assertEqual(frame.timestamp, 50528771)
self.assertEqual(
str(frame.alias_array),
"3031=3233, 3435=3637, 3839=3031, 3233=3435, 3637=3839",
)
def test_str(self) -> None:
"""Test string representation of FrameGetAllNodesInformationNotification."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
test_ts = datetime.fromtimestamp(50528771).strftime("%Y-%m-%d %H:%M:%S")
self.assertEqual(
str(frame),
'<FrameGetAllNodesInformationNotification node_id="23" order="1234" placement="2" '
'name="Fnord23" velocity="Velocity.SILENT" node_type="NodeTypeWithSubtype.INTERIOR_VENETIAN_BLIND" '
'product_group="23" product_type="13" node_variation="NodeVariation.TOPHUNG" '
'power_mode="1" build_number="7" serial_number="01:02:03:04:05:06:06:08" state="ERROR_EXECUTING" '
'current_position="0 %" target="0 %" current_position_fp1="2 %" '
'current_position_fp2="5 %" current_position_fp3="7 %" current_position_fp4="9 %" '
'remaining_time="1" time="{}" '
'alias_array="3031=3233, 3435=3637, 3839=3031, 3233=3435, 3637=3839"/>'.format(
test_ts
),
)
def test_serial_number(self) -> None:
"""Test serial number property."""
frame = FrameGetAllNodesInformationNotification()
frame.serial_number = "01:02:03:04:05:06:06:08"
self.assertEqual(frame.serial_number, "01:02:03:04:05:06:06:08")
def test_serial_number_none(self) -> None:
"""Test serial number property with no value set."""
frame = FrameGetAllNodesInformationNotification()
frame.serial_number = None
self.assertEqual(frame.serial_number, None)
def test_serial_number_not_set(self) -> None:
"""Test serial number property with not set."""
frame = FrameGetAllNodesInformationNotification()
self.assertEqual(frame.serial_number, None)
def test_wrong_serial_number(self) -> None:
"""Test setting a wrong serial number."""
frame = FrameGetAllNodesInformationNotification()
with self.assertRaises(PyVLXException):
frame.serial_number = "01:02:03:04:05:06:06"
|
class TestFrameGetAllNodesInformationNotification(unittest.TestCase):
'''Test class for FrameGetAllNodesInformationNotification.'''
def test_bytes(self) -> None:
'''Test FrameGetAllNodesInformationNotification.'''
pass
def test_frame_from_raw(self) -> None:
'''Test parse FrameGetAllNodesInformationNotification from raw.'''
pass
def test_str(self) -> None:
'''Test string representation of FrameGetAllNodesInformationNotification.'''
pass
def test_serial_number(self) -> None:
'''Test serial number property.'''
pass
def test_serial_number_none(self) -> None:
'''Test serial number property with no value set.'''
pass
def test_serial_number_not_set(self) -> None:
'''Test serial number property with not set.'''
pass
def test_wrong_serial_number(self) -> None:
'''Test setting a wrong serial number.'''
pass
| 8 | 8 | 13 | 0 | 12 | 1 | 1 | 0.1 | 1 | 11 | 8 | 0 | 7 | 0 | 7 | 79 | 113 | 10 | 94 | 17 | 86 | 9 | 71 | 17 | 63 | 1 | 2 | 1 | 7 |
140,266 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_command_send_req_test.py
|
test.frame_command_send_req_test.TestFrameCommandSendRequest
|
class TestFrameCommandSendRequest(unittest.TestCase):
"""Test class FrameCommandSendRequest."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = (
b"\x00E\x03\x00\x03\xe8\x02\x03\x00\x00\x00\x96\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x01\x02"
+ b"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x009"
)
def test_bytes(self) -> None:
"""Test FrameCommandSendRequest with NO_TYPE."""
frame = FrameCommandSendRequest(
node_ids=[1, 2, 3],
parameter=Position(position_percent=75),
session_id=1000,
originator=Originator.RAIN,
)
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self) -> None:
"""Test parse FrameCommandSendRequest from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameCommandSendRequest))
self.assertEqual(frame.node_ids, [1, 2, 3])
self.assertEqual(Position(frame.parameter).position_percent, 75)
self.assertEqual(frame.session_id, 1000)
self.assertEqual(frame.originator, Originator.RAIN)
def test_str(self) -> None:
"""Test string representation of FrameCommandSendRequest."""
functional_para = {"fp3": Position(position=12345)}
functional_parameter = {}
for i in range(1, 17):
key = "fp%s" % (i)
if key in functional_para:
functional_parameter[key] = functional_para[key]
else:
functional_parameter[key] = bytes(2)
frame = FrameCommandSendRequest(
node_ids=[1, 2, 3],
parameter=Position(position=12345),
**functional_parameter,
session_id=1000,
originator=Originator.RAIN
)
self.assertEqual(
str(frame),
'<FrameCommandSendRequest node_ids="[1, 2, 3]" active_parameter="0" parameter="24 %" '
'functional_parameter="fp1: 0 %, fp2: 0 %, fp3: 24 %, fp4: 0 %, fp5: 0 %, fp6: 0 %, fp7: 0 %, '
'fp8: 0 %, fp9: 0 %, fp10: 0 %, fp11: 0 %, fp12: 0 %, fp13: 0 %, fp14: 0 %, fp15: 0 %, fp16: 0 %, " '
'session_id="1000" originator="Originator.RAIN"/>',
)
def test_wrong_payload(self) -> None:
"""Test wrong payload length, 2 scenes in len, only one provided."""
frame = FrameCommandSendRequest()
with self.assertRaises(PyVLXException) as ctx:
frame.from_payload(
b"\x03\xe8\x01\x03\x00\x00\x0009\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x15\x01\x02\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00"
)
self.assertEqual(
ctx.exception.description, "command_send_request_wrong_node_length"
)
|
class TestFrameCommandSendRequest(unittest.TestCase):
'''Test class FrameCommandSendRequest.'''
def test_bytes(self) -> None:
'''Test FrameCommandSendRequest with NO_TYPE.'''
pass
def test_frame_from_raw(self) -> None:
'''Test parse FrameCommandSendRequest from raw.'''
pass
def test_str(self) -> None:
'''Test string representation of FrameCommandSendRequest.'''
pass
def test_wrong_payload(self) -> None:
'''Test wrong payload length, 2 scenes in len, only one provided.'''
pass
| 5 | 5 | 14 | 0 | 13 | 1 | 2 | 0.1 | 1 | 5 | 2 | 0 | 4 | 0 | 4 | 76 | 70 | 6 | 58 | 15 | 53 | 6 | 27 | 14 | 22 | 3 | 2 | 2 | 6 |
140,267 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_discover_nodes_cfm_test.py
|
test.frame_discover_nodes_cfm_test.TestFrameNodeDiscoverConfirmation
|
class TestFrameNodeDiscoverConfirmation(unittest.TestCase):
"""Test class for FrameDiscoverNodesConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FrameDiscoverNodesConfirmation."""
frame = FrameDiscoverNodesConfirmation()
self.assertEqual(bytes(frame), b"\x00\x03\x01\x04\x06")
def test_frame_from_raw(self):
"""Test parse FrameDiscoverNodesConfirmation from raw."""
frame = frame_from_raw(b"\x00\x03\x01\x04\x06")
self.assertTrue(isinstance(frame, FrameDiscoverNodesConfirmation))
def test_str(self):
"""Test string representation of FrameDiscoverNodesConfirmation."""
frame = FrameDiscoverNodesConfirmation()
self.assertEqual(str(frame), "<FrameDiscoverNodesConfirmation/>")
|
class TestFrameNodeDiscoverConfirmation(unittest.TestCase):
'''Test class for FrameDiscoverNodesConfirmation.'''
def test_bytes(self):
'''Test FrameDiscoverNodesConfirmation.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameDiscoverNodesConfirmation from raw.'''
pass
def test_str(self):
'''Test string representation of FrameDiscoverNodesConfirmation.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.5 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 19 | 4 | 10 | 7 | 6 | 5 | 10 | 7 | 6 | 1 | 2 | 0 | 3 |
140,268 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_error_test.py
|
test.frame_error_test.TestErrorNotification
|
class TestErrorNotification(unittest.TestCase):
"""Test class for FrameErrorNotification."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FrameErrorNotification with Light."""
frame = FrameErrorNotification(error_type=ErrorType.ErrorOnFrameStructure)
self.assertEqual(bytes(frame), b"\x00\x04\x00\x00\x02\x06")
def test_frame_from_raw(self):
"""Test parse FrameErrorNotification from raw."""
frame = frame_from_raw(b"\x00\x04\x00\x00\x02\x06")
self.assertTrue(isinstance(frame, FrameErrorNotification))
self.assertEqual(frame.error_type, ErrorType.ErrorOnFrameStructure)
def test_str(self):
"""Test string representation of FrameErrorNotification."""
frame = FrameErrorNotification(error_type=ErrorType.ErrorOnFrameStructure)
self.assertEqual(
str(frame),
'<FrameErrorNotification error_type="ErrorType.ErrorOnFrameStructure"/>',
)
|
class TestErrorNotification(unittest.TestCase):
'''Test class for FrameErrorNotification.'''
def test_bytes(self):
'''Test FrameErrorNotification with Light.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameErrorNotification from raw.'''
pass
def test_str(self):
'''Test string representation of FrameErrorNotification.'''
pass
| 4 | 4 | 5 | 0 | 4 | 1 | 1 | 0.36 | 1 | 4 | 2 | 0 | 3 | 0 | 3 | 75 | 23 | 4 | 14 | 7 | 10 | 5 | 11 | 7 | 7 | 1 | 2 | 0 | 3 |
140,269 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_all_nodes_information_finished_ntf_test.py
|
test.frame_get_all_nodes_information_finished_ntf_test.TestFrameGetAllNodesInformationFinishedNotification
|
class TestFrameGetAllNodesInformationFinishedNotification(unittest.TestCase):
"""Test class for FrameGetAllNodesInformationFinishedNotification."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FrameGetAllNodesInformationFinishedNotification."""
frame = FrameGetAllNodesInformationFinishedNotification()
self.assertEqual(bytes(frame), b"\x00\x03\x02\x05\x04")
def test_frame_from_raw(self):
"""Test parse FrameGetAllNodesInformationFinishedNotification from raw."""
frame = frame_from_raw(b"\x00\x03\x02\x05\x04")
self.assertTrue(
isinstance(frame, FrameGetAllNodesInformationFinishedNotification)
)
def test_str(self):
"""Test string representation of FrameGetAllNodesInformationFinishedNotification."""
frame = FrameGetAllNodesInformationFinishedNotification()
self.assertEqual(
str(frame), "<FrameGetAllNodesInformationFinishedNotification/>"
)
|
class TestFrameGetAllNodesInformationFinishedNotification(unittest.TestCase):
'''Test class for FrameGetAllNodesInformationFinishedNotification.'''
def test_bytes(self):
'''Test FrameGetAllNodesInformationFinishedNotification.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetAllNodesInformationFinishedNotification from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetAllNodesInformationFinishedNotification.'''
pass
| 4 | 4 | 5 | 0 | 4 | 1 | 1 | 0.36 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 23 | 4 | 14 | 7 | 10 | 5 | 10 | 7 | 6 | 1 | 2 | 0 | 3 |
140,270 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_discover_nodes_req_test.py
|
test.frame_discover_nodes_req_test.TestFrameNodeDiscover
|
class TestFrameNodeDiscover(unittest.TestCase):
"""Test class for FrameDiscoverNodesRequest."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FrameDiscoverNodesRequest with NO_TYPE."""
frame = FrameDiscoverNodesRequest()
self.assertEqual(bytes(frame), b"\x00\x04\x01\x03\x00\x06")
def test_bytes_light(self):
"""Test FrameDiscoverNodesRequest with Light."""
frame = FrameDiscoverNodesRequest(NodeType.LIGHT)
self.assertEqual(bytes(frame), b"\x00\x04\x01\x03\x06\x00")
def test_frame_from_raw(self):
"""Test parse FrameDiscoverNodesRequest from raw."""
frame = frame_from_raw(b"\x00\x04\x01\x03\x06\x00")
self.assertTrue(isinstance(frame, FrameDiscoverNodesRequest))
self.assertEqual(frame.node_type, NodeType.LIGHT)
def test_str(self):
"""Test string representation of FrameDiscoverNodesRequest."""
frame = FrameDiscoverNodesRequest(NodeType.LIGHT)
self.assertEqual(
str(frame), '<FrameDiscoverNodesRequest node_type="NodeType.LIGHT"/>'
)
|
class TestFrameNodeDiscover(unittest.TestCase):
'''Test class for FrameDiscoverNodesRequest.'''
def test_bytes(self):
'''Test FrameDiscoverNodesRequest with NO_TYPE.'''
pass
def test_bytes_light(self):
'''Test FrameDiscoverNodesRequest with Light.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameDiscoverNodesRequest from raw.'''
pass
def test_str(self):
'''Test string representation of FrameDiscoverNodesRequest.'''
pass
| 5 | 5 | 5 | 0 | 4 | 1 | 1 | 0.38 | 1 | 4 | 2 | 0 | 4 | 0 | 4 | 76 | 27 | 5 | 16 | 9 | 11 | 6 | 14 | 9 | 9 | 1 | 2 | 0 | 4 |
140,271 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_helper_test.py
|
test.frame_helper_test.TestFrameHelper
|
class TestFrameHelper(unittest.TestCase):
"""Test class for frame_creation module."""
# pylint: disable=too-many-public-methods,invalid-name
def test_crc(self):
"""Test crc calculation."""
self.assertEqual(calc_crc(b""), 0)
self.assertEqual(calc_crc(b"\x01"), 1)
self.assertEqual(calc_crc(b"\x01\x02"), 3)
self.assertEqual(calc_crc(b"\x01\x02\x03"), 0)
self.assertEqual(calc_crc(b"\x01\x02\x03\xff"), 255)
def test_extract_from_frame(self):
"""Test extract_from_frame method."""
with self.assertRaises(PyVLXException):
extract_from_frame(bytes(4))
with self.assertRaises(PyVLXException):
extract_from_frame(
bytes(b"\x01\x04\x00\x00\x02\x06")
) # invalid length (first 2 bytes)
with self.assertRaises(PyVLXException):
extract_from_frame(bytes(b"\x00\x04\x00\x00\x02\x07")) # invalid crc
with self.assertRaises(PyVLXException):
extract_from_frame(bytes(b"\x00\x04\xFF\xFF\x02\x06"))
|
class TestFrameHelper(unittest.TestCase):
'''Test class for frame_creation module.'''
def test_crc(self):
'''Test crc calculation.'''
pass
def test_extract_from_frame(self):
'''Test extract_from_frame method.'''
pass
| 3 | 3 | 10 | 0 | 9 | 3 | 1 | 0.39 | 1 | 2 | 1 | 0 | 2 | 0 | 2 | 74 | 25 | 3 | 18 | 3 | 15 | 7 | 16 | 3 | 13 | 1 | 2 | 1 | 2 |
140,272 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_factory_default_cfm_test.py
|
test.frame_factory_default_cfm_test.TestFrameGatewayFactoryDefaultConfirmation
|
class TestFrameGatewayFactoryDefaultConfirmation(unittest.TestCase):
"""Test class FrameGatewayFactoryDefaultConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x03\x00\x04\x07"
def test_bytes(self):
"""Test FrameGatewayFactoryDefaultConfirmation."""
frame = FrameGatewayFactoryDefaultConfirmation()
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameGatewayFactoryDefaultConfirmation from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameGatewayFactoryDefaultConfirmation))
def test_str(self):
"""Test string representation of FrameGatewayFactoryDefaultConfirmation."""
frame = FrameGatewayFactoryDefaultConfirmation()
self.assertEqual(str(frame), "<FrameGatewayFactoryDefaultConfirmation/>")
|
class TestFrameGatewayFactoryDefaultConfirmation(unittest.TestCase):
'''Test class FrameGatewayFactoryDefaultConfirmation.'''
def test_bytes(self):
'''Test FrameGatewayFactoryDefaultConfirmation.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGatewayFactoryDefaultConfirmation from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGatewayFactoryDefaultConfirmation.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.45 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 21 | 5 | 11 | 8 | 7 | 5 | 11 | 8 | 7 | 1 | 2 | 0 | 3 |
140,273 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_discover_nodes_ntf_test.py
|
test.frame_discover_nodes_ntf_test.TestFrameDiscoverNodesNotification
|
class TestFrameDiscoverNodesNotification(unittest.TestCase):
"""Test class for FrameDiscoverNodesNotification."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FrameDiscoverNodesNotification."""
frame = FrameDiscoverNodesNotification()
self.assertEqual(
bytes(frame),
b"\x00\x86\x01\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x82",
)
def test_frame_from_raw(self):
"""Test parse FrameDiscoverNodesNotification from raw."""
frame = frame_from_raw(
b"\x00\x86\x01\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x82"
)
self.assertTrue(isinstance(frame, FrameDiscoverNodesNotification))
def test_str(self):
"""Test string representation of FrameDiscoverNodesNotification."""
frame = FrameDiscoverNodesNotification()
self.assertEqual(
str(frame),
'<FrameDiscoverNodesNotification payload="00:00:00:00:00:00:00:00:'
+ '00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:'
+ '00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:'
+ '00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:'
+ '00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:'
+ '00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:'
+ '00:00:00:00:00:00:00:00:00:00:00:00:00"/>',
)
|
class TestFrameDiscoverNodesNotification(unittest.TestCase):
'''Test class for FrameDiscoverNodesNotification.'''
def test_bytes(self):
'''Test FrameDiscoverNodesNotification.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameDiscoverNodesNotification from raw.'''
pass
def test_str(self):
'''Test string representation of FrameDiscoverNodesNotification.'''
pass
| 4 | 4 | 14 | 0 | 13 | 1 | 1 | 0.13 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 49 | 4 | 40 | 7 | 36 | 5 | 10 | 7 | 6 | 1 | 2 | 0 | 3 |
140,274 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_gw_reboot_req_test.py
|
test.frame_gw_reboot_req_test.TestFrameRebootRequest
|
class TestFrameRebootRequest(unittest.TestCase):
"""Test class FrameGatewayRebootRequest."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x03\x00\x01\x02"
def test_bytes(self):
"""Test FrameGatewayRebootRequest."""
frame = FrameGatewayRebootRequest()
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameGatewayRebootRequest from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameGatewayRebootRequest))
def test_str(self):
"""Test string representation of FrameGatewayRebootRequest."""
frame = FrameGatewayRebootRequest()
self.assertEqual(str(frame), "<FrameGatewayRebootRequest/>")
|
class TestFrameRebootRequest(unittest.TestCase):
'''Test class FrameGatewayRebootRequest.'''
def test_bytes(self):
'''Test FrameGatewayRebootRequest.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGatewayRebootRequest from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGatewayRebootRequest.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.45 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 21 | 5 | 11 | 8 | 7 | 5 | 11 | 8 | 7 | 1 | 2 | 0 | 3 |
140,275 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_gw_reboot_cfm_test.py
|
test.frame_gw_reboot_cfm_test.TestFrameRebootConfirmation
|
class TestFrameRebootConfirmation(unittest.TestCase):
"""Test class FrameSetUTCConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x03\x00\x02\x01"
def test_bytes(self):
"""Test FrameGatewayRebootConfirmation."""
frame = FrameGatewayRebootConfirmation()
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameGatewayRebootConfirmation from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameGatewayRebootConfirmation))
def test_str(self):
"""Test string representation of FrameGatewayRebootConfirmation."""
frame = FrameGatewayRebootConfirmation()
self.assertEqual(str(frame), "<FrameGatewayRebootConfirmation/>")
|
class TestFrameRebootConfirmation(unittest.TestCase):
'''Test class FrameSetUTCConfirmation.'''
def test_bytes(self):
'''Test FrameGatewayRebootConfirmation.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGatewayRebootConfirmation from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGatewayRebootConfirmation.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.45 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 21 | 5 | 11 | 8 | 7 | 5 | 11 | 8 | 7 | 1 | 2 | 0 | 3 |
140,276 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_version_req_test.py
|
test.frame_get_version_req_test.TestFrameGetVersionRequest
|
class TestFrameGetVersionRequest(unittest.TestCase):
"""Test class FrameGetVersionRequest."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x03\x00\x08\x0b"
def test_bytes(self):
"""Test FrameGetVersionRequest with NO_TYPE."""
frame = FrameGetVersionRequest()
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameGetVersionRequest from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameGetVersionRequest))
def test_str(self):
"""Test string representation of FrameGetVersionRequest."""
frame = FrameGetVersionRequest()
self.assertEqual(str(frame), "<FrameGetVersionRequest/>")
|
class TestFrameGetVersionRequest(unittest.TestCase):
'''Test class FrameGetVersionRequest.'''
def test_bytes(self):
'''Test FrameGetVersionRequest with NO_TYPE.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetVersionRequest from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetVersionRequest.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.45 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 21 | 5 | 11 | 8 | 7 | 5 | 11 | 8 | 7 | 1 | 2 | 0 | 3 |
140,277 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_network_setup_cfm_test.py
|
test.frame_get_network_setup_cfm_test.TestFrameGetNetworkSetupConfirmation
|
class TestFrameGetNetworkSetupConfirmation(unittest.TestCase):
"""Test class for FrameGetNetworkSetupConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
TESTFRAME = bytes.fromhex('001000e1c0a80de3ffffff00c0a80d0100ec')
def test_bytes(self):
"""Test FrameGetNetworkSetupConfirmation."""
frame = FrameGetNetworkSetupConfirmation(
ipaddress=b'\xc0\xa8\r\xe3', netmask=b'\xff\xff\xff\x00',
gateway=b'\xc0\xa8\r\x01', dhcp=DHCPParameter.ENABLE)
self.assertEqual(bytes(frame),
b"\x00\x10\x00\xe1\xc0\xa8\r\xe3\xff\xff\xff\x00\xc0\xa8\r\x01\x00\xec")
def test_frame_from_raw(self):
"""Test parse FrameGetNetworkSetupConfirmation from raw."""
frame = frame_from_raw(self.TESTFRAME)
self.assertTrue(isinstance(frame, FrameGetNetworkSetupConfirmation))
self.assertEqual(frame.ipaddress, '192.168.13.227')
self.assertEqual(frame.netmask, '255.255.255.0')
self.assertEqual(frame.gateway, '192.168.13.1')
self.assertEqual(frame.dhcp, DHCPParameter.DISABLE)
def test_str(self):
"""Test string representation of FrameGetNetworkSetupConfirmation."""
frame = FrameGetNetworkSetupConfirmation(
ipaddress=b'\xc0\xa8\r\xe3', netmask=b'\xff\xff\xff\x00',
gateway=b'\xc0\xa8\r\x01', dhcp=DHCPParameter.DISABLE)
self.assertEqual(
str(frame),
'<FrameGetNetworkSetupConfirmation ipaddress="192.168.13.227" '
'netmask="255.255.255.0" gateway="192.168.13.1" dhcp="DHCPParameter.DISABLE"/>',
)
|
class TestFrameGetNetworkSetupConfirmation(unittest.TestCase):
'''Test class for FrameGetNetworkSetupConfirmation.'''
def test_bytes(self):
'''Test FrameGetNetworkSetupConfirmation.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetNetworkSetupConfirmation from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetNetworkSetupConfirmation.'''
pass
| 4 | 4 | 8 | 0 | 7 | 1 | 1 | 0.21 | 1 | 4 | 2 | 0 | 3 | 0 | 3 | 75 | 33 | 4 | 24 | 8 | 20 | 5 | 15 | 8 | 11 | 1 | 2 | 0 | 3 |
140,278 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_network_setup_req_test.py
|
test.frame_get_network_setup_req_test.TestFrameGetNetworkSetupRequest
|
class TestFrameGetNetworkSetupRequest(unittest.TestCase):
"""Test class for FrameGetNetworkSetupRequest."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FrameGetNetworkSetupRequest with NO_TYPE."""
frame = FrameGetNetworkSetupRequest()
self.assertEqual(bytes(frame), b"\x00\x03\x00\xe0\xe3")
def test_frame_from_raw(self):
"""Test parse FrameGetNetworkSetupRequest from raw."""
frame = frame_from_raw(b"\x00\x03\x00\xe0\xe3")
self.assertTrue(isinstance(frame, FrameGetNetworkSetupRequest))
def test_str(self):
"""Test string representation of FrameGetNetworkSetupRequest."""
frame = FrameGetNetworkSetupRequest()
self.assertEqual(str(frame), "<FrameGetNetworkSetupRequest/>")
|
class TestFrameGetNetworkSetupRequest(unittest.TestCase):
'''Test class for FrameGetNetworkSetupRequest.'''
def test_bytes(self):
'''Test FrameGetNetworkSetupRequest with NO_TYPE.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetNetworkSetupRequest from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetNetworkSetupRequest.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.5 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 19 | 4 | 10 | 7 | 6 | 5 | 10 | 7 | 6 | 1 | 2 | 0 | 3 |
140,279 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_node_information_cfm_test.py
|
test.frame_get_node_information_cfm_test.TestFrameGetNodeInformationConfirmation
|
class TestFrameGetNodeInformationConfirmation(unittest.TestCase):
"""Test class for FrameGetNodeInformationConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FrameGetNodeInformationConfirmation."""
frame = FrameGetNodeInformationConfirmation(node_id=23)
self.assertEqual(bytes(frame), b"\x00\x05\x02\x01\x00\x17\x11")
def test_frame_from_raw(self):
"""Test parse FrameGetNodeInformationConfirmation from raw."""
frame = frame_from_raw(b"\x00\x05\x02\x01\x00\x17\x11")
self.assertTrue(isinstance(frame, FrameGetNodeInformationConfirmation))
self.assertEqual(frame.node_id, 23)
def test_str(self):
"""Test string representation of FrameGetNodeInformationConfirmation."""
frame = FrameGetNodeInformationConfirmation(node_id=23)
self.assertEqual(
str(frame),
'<FrameGetNodeInformationConfirmation node_id="23" status="NodeInformationStatus.OK"/>',
)
|
class TestFrameGetNodeInformationConfirmation(unittest.TestCase):
'''Test class for FrameGetNodeInformationConfirmation.'''
def test_bytes(self):
'''Test FrameGetNodeInformationConfirmation.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetNodeInformationConfirmation from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetNodeInformationConfirmation.'''
pass
| 4 | 4 | 5 | 0 | 4 | 1 | 1 | 0.36 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 23 | 4 | 14 | 7 | 10 | 5 | 11 | 7 | 7 | 1 | 2 | 0 | 3 |
140,280 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_node_information_ntf_test.py
|
test.frame_get_node_information_ntf_test.TestFrameGetNodeInformationNotification
|
class TestFrameGetNodeInformationNotification(unittest.TestCase):
"""Test class for FrameGetNodeInformationNotification."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = (
b"\x00\x7f\x02\x10\x17\x04\xd2\x02Fnord23\x00\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00\x01\x00@\x17\r\x01\x01\x07\x01"
b"\x02\x03\x04\x05\x06\x06\x08\x01\x00\x0c\x00{\x04\xd2\t)\r\x80"
b"\x11\xd7\x00\x01\x03\x03\x02\x03\x0501234567890123456789\x65"
)
def test_bytes(self) -> None:
"""Test FrameGetNodeInformationNotification."""
frame = FrameGetNodeInformationNotification()
frame.node_id = 23
frame.order = 1234
frame.placement = 2
frame.name = "Fnord23"
frame.velocity = Velocity.SILENT
frame.node_type = NodeTypeWithSubtype.INTERIOR_VENETIAN_BLIND
frame.product_group = 23
frame.product_type = 13
frame.node_variation = NodeVariation.TOPHUNG
frame.power_mode = 1
frame.build_number = 7
frame.serial_number = "01:02:03:04:05:06:06:08"
frame.state = OperatingState.ERROR_EXECUTING
frame.current_position = Position(position=12)
frame.target = Position(position=123)
frame.current_position_fp1 = Position(position=1234)
frame.current_position_fp2 = Position(position=2345)
frame.current_position_fp3 = Position(position=3456)
frame.current_position_fp4 = Position(position=4567)
frame.remaining_time = 1
frame.timestamp = 50528771
frame.alias_array = AliasArray(raw=b"\x0501234567890123456789")
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self) -> None:
"""Test parse FrameGetNodeInformationNotification from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameGetNodeInformationNotification))
self.assertEqual(frame.node_id, 23)
self.assertEqual(frame.order, 1234)
self.assertEqual(frame.placement, 2)
self.assertEqual(frame.name, "Fnord23")
self.assertEqual(frame.velocity, Velocity.SILENT)
self.assertEqual(frame.node_type, NodeTypeWithSubtype.INTERIOR_VENETIAN_BLIND)
self.assertEqual(frame.product_group, 23)
self.assertEqual(frame.product_type, 13)
self.assertEqual(frame.node_variation, NodeVariation.TOPHUNG)
self.assertEqual(frame.power_mode, 1)
self.assertEqual(frame.build_number, 7)
self.assertEqual(frame.serial_number, "01:02:03:04:05:06:06:08")
self.assertEqual(frame.state, OperatingState.ERROR_EXECUTING)
self.assertEqual(Position(frame.current_position).position, 12)
self.assertEqual(Position(frame.target).position, 123)
self.assertEqual(Position(frame.current_position_fp1).position, 1234)
self.assertEqual(Position(frame.current_position_fp2).position, 2345)
self.assertEqual(Position(frame.current_position_fp3).position, 3456)
self.assertEqual(Position(frame.current_position_fp4).position, 4567)
self.assertEqual(frame.remaining_time, 1)
self.assertEqual(frame.timestamp, 50528771)
self.assertEqual(
str(frame.alias_array),
"3031=3233, 3435=3637, 3839=3031, 3233=3435, 3637=3839",
)
def test_str(self) -> None:
"""Test string representation of FrameGetNodeInformationNotification."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
test_ts = datetime.fromtimestamp(50528771).strftime("%Y-%m-%d %H:%M:%S")
self.assertEqual(
str(frame),
'<FrameGetNodeInformationNotification node_id="23" order="1234" placement="2" '
'name="Fnord23" velocity="Velocity.SILENT" node_type="NodeTypeWithSubtype.INTERIOR_VENETIAN_BLIND" '
'product_group="23" product_type="13" node_variation="NodeVariation.TOPHUNG" '
'power_mode="1" build_number="7" serial_number="01:02:03:04:05:06:06:08" state="ERROR_EXECUTING" '
'current_position="0 %" target="0 %" current_position_fp1="2 %" '
'current_position_fp2="5 %" current_position_fp3="7 %" current_position_fp4="9 %" '
'remaining_time="1" time="{}" '
'alias_array="3031=3233, 3435=3637, 3839=3031, 3233=3435, 3637=3839"/>'.format(
test_ts
),
)
def test_serial_number(self) -> None:
"""Test serial number property."""
frame = FrameGetNodeInformationNotification()
frame.serial_number = "01:02:03:04:05:06:06:08"
self.assertEqual(frame.serial_number, "01:02:03:04:05:06:06:08")
def test_serial_number_none(self) -> None:
"""Test serial number property with no value set."""
frame = FrameGetNodeInformationNotification()
frame.serial_number = None
self.assertEqual(frame.serial_number, None)
def test_serial_number_not_set(self) -> None:
"""Test serial number property with not set."""
frame = FrameGetNodeInformationNotification()
self.assertEqual(frame.serial_number, None)
def test_wrong_serial_number(self) -> None:
"""Test setting a wrong serial number."""
frame = FrameGetNodeInformationNotification()
with self.assertRaises(PyVLXException):
frame.serial_number = "01:02:03:04:05:06:06"
|
class TestFrameGetNodeInformationNotification(unittest.TestCase):
'''Test class for FrameGetNodeInformationNotification.'''
def test_bytes(self) -> None:
'''Test FrameGetNodeInformationNotification.'''
pass
def test_frame_from_raw(self) -> None:
'''Test parse FrameGetNodeInformationNotification from raw.'''
pass
def test_str(self) -> None:
'''Test string representation of FrameGetNodeInformationNotification.'''
pass
def test_serial_number(self) -> None:
'''Test serial number property.'''
pass
def test_serial_number_none(self) -> None:
'''Test serial number property with no value set.'''
pass
def test_serial_number_not_set(self) -> None:
'''Test serial number property with not set.'''
pass
def test_wrong_serial_number(self) -> None:
'''Test setting a wrong serial number.'''
pass
| 8 | 8 | 13 | 0 | 12 | 1 | 1 | 0.1 | 1 | 11 | 8 | 0 | 7 | 0 | 7 | 79 | 112 | 9 | 94 | 17 | 86 | 9 | 71 | 17 | 63 | 1 | 2 | 1 | 7 |
140,281 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_node_information_req_test.py
|
test.frame_get_node_information_req_test.TestFrameGetNodeInformationRequest
|
class TestFrameGetNodeInformationRequest(unittest.TestCase):
"""Test class for FrameGetNodeInformationRequest."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FrameGetNodeInformationRequest with NO_TYPE."""
frame = FrameGetNodeInformationRequest(node_id=23)
self.assertEqual(bytes(frame), b"\x00\x04\x02\x00\x17\x11")
def test_frame_from_raw(self):
"""Test parse FrameGetNodeInformationRequest from raw."""
frame = frame_from_raw(b"\x00\x04\x02\x00\x17\x11")
self.assertTrue(isinstance(frame, FrameGetNodeInformationRequest))
self.assertEqual(frame.node_id, 23)
def test_str(self):
"""Test string representation of FrameGetNodeInformationRequest."""
frame = FrameGetNodeInformationRequest(node_id=23)
self.assertEqual(str(frame), '<FrameGetNodeInformationRequest node_id="23"/>')
|
class TestFrameGetNodeInformationRequest(unittest.TestCase):
'''Test class for FrameGetNodeInformationRequest.'''
def test_bytes(self):
'''Test FrameGetNodeInformationRequest with NO_TYPE.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetNodeInformationRequest from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetNodeInformationRequest.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.45 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 20 | 4 | 11 | 7 | 7 | 5 | 11 | 7 | 7 | 1 | 2 | 0 | 3 |
140,282 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_protocol_version_cfm_test.py
|
test.frame_get_protocol_version_cfm_test.TestFrameGetProtocolVersionConfirmation
|
class TestFrameGetProtocolVersionConfirmation(unittest.TestCase):
"""Test class for FrameGetProtocolVersionConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x07\x00\x0b\x04\xd2\x10\xe1+"
def test_bytes(self):
"""Test FrameGetProtocolVersionConfirmation."""
frame = FrameGetProtocolVersionConfirmation(
major_version=1234, minor_version=4321
)
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameGetProtocolVersionConfirmation from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameGetProtocolVersionConfirmation))
self.assertEqual(frame.major_version, 1234)
self.assertEqual(frame.minor_version, 4321)
def test_str(self):
"""Test string representation of FrameGetProtocolVersionConfirmation."""
frame = FrameGetProtocolVersionConfirmation(
major_version=1234, minor_version=4321
)
self.assertEqual(
str(frame), '<FrameGetProtocolVersionConfirmation version="1234.4321"/>'
)
|
class TestFrameGetProtocolVersionConfirmation(unittest.TestCase):
'''Test class for FrameGetProtocolVersionConfirmation.'''
def test_bytes(self):
'''Test FrameGetProtocolVersionConfirmation.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetProtocolVersionConfirmation from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetProtocolVersionConfirmation.'''
pass
| 4 | 4 | 7 | 0 | 6 | 1 | 1 | 0.26 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 29 | 5 | 19 | 8 | 15 | 5 | 13 | 8 | 9 | 1 | 2 | 0 | 3 |
140,283 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_local_time_cfm_test.py
|
test.frame_get_local_time_cfm_test.TestFrameGetLocalTimeConfirmation
|
class TestFrameGetLocalTimeConfirmation(unittest.TestCase):
"""Test class for FrameGetLocalTimeConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self) -> None:
"""Test FrameGetLocalTimeConfirmation."""
frame = FrameGetLocalTimeConfirmation()
frame.time.localtime = datetime(2020, 12, 3, 18, 19, 19, 176900)
frame.time.utctime = datetime(
2020, 12, 3, 18, 19, 19, 176900, tzinfo=timezone.utc
)
self.assertEqual(
bytes(frame), b"\x00\x12 \x05_\xc9,'\x13\x13\x12\x03\x0c\x00x\x04\x01R\xffg"
)
def test_frame_from_raw(self) -> None:
"""Test parse FrameGetLocalTimeConfirmation from raw."""
frame = frame_from_raw(
b"\x00\x12 \x05_\xc9,'\x13\x13\x12\x03\x0c\x00x\x04\x01R\xffg"
)
self.assertTrue(isinstance(frame, FrameGetLocalTimeConfirmation))
def test_str(self) -> None:
"""Test string representation of FrameGetLocalTimeConfirmation."""
frame = FrameGetLocalTimeConfirmation()
frame.time.localtime = datetime.strptime(
"2020-12-03 18:19:19.176900", "%Y-%m-%d %H:%M:%S.%f"
)
frame.time.utctime = datetime.strptime(
"2020-12-03 18:19:19.176900", "%Y-%m-%d %H:%M:%S.%f"
)
self.assertEqual(
str(frame),
"<FrameGetLocalTimeConfirmation><DtoLocalTime "
'utctime="2020-12-03 18:19:19.176900" '
'localtime="2020-12-03 18:19:19.176900"/>'
"</FrameGetLocalTimeConfirmation>",
)
|
class TestFrameGetLocalTimeConfirmation(unittest.TestCase):
'''Test class for FrameGetLocalTimeConfirmation.'''
def test_bytes(self) -> None:
'''Test FrameGetLocalTimeConfirmation.'''
pass
def test_frame_from_raw(self) -> None:
'''Test parse FrameGetLocalTimeConfirmation from raw.'''
pass
def test_str(self) -> None:
'''Test string representation of FrameGetLocalTimeConfirmation.'''
pass
| 4 | 4 | 11 | 0 | 10 | 1 | 1 | 0.17 | 1 | 5 | 1 | 0 | 3 | 0 | 3 | 75 | 39 | 4 | 30 | 7 | 26 | 5 | 14 | 7 | 10 | 1 | 2 | 0 | 3 |
140,284 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_limitation_status_req_test.py
|
test.frame_get_limitation_status_req_test.TestFrameGetLimitationStatus
|
class TestFrameGetLimitationStatus(unittest.TestCase):
"""Test class for FrameGetLimitationStatus."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FrameGetLimitationStatus bytes."""
frame = FrameGetLimitationStatus(node_ids=[1], session_id=1, limitation_type=LimitationType.MIN_LIMITATION)
self.assertEqual(bytes(frame), b'\x00\x1c\x03\x12\x00\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
b'\x00\x00\x0c')
frame = FrameGetLimitationStatus(node_ids=[1, 2], session_id=2, limitation_type=LimitationType.MAX_LIMITATION)
self.assertEqual(bytes(frame), b'\x00\x1c\x03\x12\x00\x02\x02\x01\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
b'\x00\x01\x0f')
def test_frame_from_raw(self):
"""Test parse FrameGetLimitationStatus from raw."""
frame = frame_from_raw(b'\x00\x1c\x03\x12\x00\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
b'\x0c')
self.assertTrue(isinstance(frame, FrameGetLimitationStatus))
def test_str(self):
"""Test string representation of FrameGetLimitationStatus."""
frame = FrameGetLimitationStatus(node_ids=[1], session_id=1, limitation_type=LimitationType.MIN_LIMITATION)
self.assertEqual(str(frame), '<FrameGetLimitationStatus node_ids="[1]" session_id="1" originator="Originator.USER" />')
|
class TestFrameGetLimitationStatus(unittest.TestCase):
'''Test class for FrameGetLimitationStatus.'''
def test_bytes(self):
'''Test FrameGetLimitationStatus bytes.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetLimitationStatus from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetLimitationStatus.'''
pass
| 4 | 4 | 6 | 0 | 5 | 1 | 1 | 0.33 | 1 | 4 | 2 | 0 | 3 | 0 | 3 | 75 | 25 | 5 | 15 | 7 | 11 | 5 | 12 | 7 | 8 | 1 | 2 | 0 | 3 |
140,285 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_limitation_status_ntf_test.py
|
test.frame_get_limitation_status_ntf_test.TestFrameGetLimitationStatusNotification
|
class TestFrameGetLimitationStatusNotification(unittest.TestCase):
"""Test class for TestFrameGetLimitationStatusNotification."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FrameGetLimitationStatusNotification bytes."""
frame = FrameGetLimitationStatusNotification()
frame.session_id = 1
frame.node_id = 1
frame.parameter_id = 0
frame.min_value = int.to_bytes(47668, 2, byteorder='big')
frame.max_value = int.to_bytes(63487, 2, byteorder='big')
frame.limit_originator = Originator.USER
frame.limit_time = 0
self.assertEqual(bytes(frame), b'\x00\r\x03\x14\x00\x01\x01\x00\xba4\xf7\xff\x01\x00\x9d')
def test_frame_from_raw(self):
"""Test parse FrameGetLimitationStatusNotification from raw."""
frame = frame_from_raw(b'\x00\r\x03\x14\x00\x01\x01\x00\xba4\xf7\xff\x01\x00\x9d')
self.assertTrue(isinstance(frame, FrameGetLimitationStatusNotification))
self.assertEqual(frame.limit_originator, Originator.USER)
self.assertEqual(frame.node_id, 1)
self.assertEqual(frame.parameter_id, 0)
self.assertEqual(frame.session_id, 1)
self.assertEqual(frame.max_value, b'\xf7')
self.assertEqual(frame.min_value, b'\xba')
self.assertEqual(frame.limit_time, 0)
def test_str(self):
"""Test string representation of FrameGetLimitationStatusNotification."""
frame = FrameGetLimitationStatusNotification()
self.assertEqual(str(frame),
'<FrameGetLimitationStatusNotification node_id="0" '
'session_id="None" min_value="None" max_value="None" '
'originator="None" limit_time="None"/>')
|
class TestFrameGetLimitationStatusNotification(unittest.TestCase):
'''Test class for TestFrameGetLimitationStatusNotification.'''
def test_bytes(self):
'''Test FrameGetLimitationStatusNotification bytes.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetLimitationStatusNotification from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetLimitationStatusNotification.'''
pass
| 4 | 4 | 10 | 0 | 9 | 1 | 1 | 0.19 | 1 | 5 | 2 | 0 | 3 | 0 | 3 | 75 | 36 | 4 | 27 | 7 | 23 | 5 | 24 | 7 | 20 | 1 | 2 | 0 | 3 |
140,286 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_limitation_status_cfm_test.py
|
test.frame_get_limitation_status_cfm_test.TestFrameGetLimitationStatusConfirmation
|
class TestFrameGetLimitationStatusConfirmation(unittest.TestCase):
"""Test class for FrameGetLimitationStatusConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FrameGetLimitationStatusConfirmation bytes."""
frame = FrameGetLimitationStatusConfirmation(session_id=1, data=1)
self.assertEqual(bytes(frame), b'\x00\x06\x03\x13\x00\x01\x01\x16')
frame = FrameGetLimitationStatusConfirmation(session_id=2, data=0)
self.assertEqual(bytes(frame), b'\x00\x06\x03\x13\x00\x02\x00\x14')
def test_frame_from_raw(self):
"""Test parse FrameGetLimitationStatusConfirmation from raw."""
frame = frame_from_raw(b'\x00\x06\x03\x13\x00\x01\x01\x16')
self.assertTrue(isinstance(frame, FrameGetLimitationStatusConfirmation))
self.assertEqual(frame.session_id, 1)
self.assertEqual(frame.data, 1)
frame = frame_from_raw(b'\x00\x06\x03\x13\x00\x02\x00\x14')
self.assertTrue(isinstance(frame, FrameGetLimitationStatusConfirmation))
self.assertEqual(frame.session_id, 2)
self.assertEqual(frame.data, 0)
def test_str(self):
"""Test string representation of FrameGetLimitationStatusConfirmation."""
frame = FrameGetLimitationStatusConfirmation(session_id=1)
self.assertEqual(str(frame),
'<FrameGetLimitationStatusConfirmation session_id="1" status="None"/>')
|
class TestFrameGetLimitationStatusConfirmation(unittest.TestCase):
'''Test class for FrameGetLimitationStatusConfirmation.'''
def test_bytes(self):
'''Test FrameGetLimitationStatusConfirmation bytes.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetLimitationStatusConfirmation from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetLimitationStatusConfirmation.'''
pass
| 4 | 4 | 8 | 1 | 6 | 1 | 1 | 0.26 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 30 | 6 | 19 | 7 | 15 | 5 | 18 | 7 | 14 | 1 | 2 | 0 | 3 |
140,287 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_protocol_version_req_test.py
|
test.frame_get_protocol_version_req_test.TestFrameGetProtocolVersionRequest
|
class TestFrameGetProtocolVersionRequest(unittest.TestCase):
"""Test class FrameGetProtocolVersionRequest."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x03\x00\n\t"
def test_bytes(self):
"""Test FrameGetProtocolVersionRequest with NO_TYPE."""
frame = FrameGetProtocolVersionRequest()
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameGetProtocolVersionRequest from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameGetProtocolVersionRequest))
def test_str(self):
"""Test string representation of FrameGetProtocolVersionRequest."""
frame = FrameGetProtocolVersionRequest()
self.assertEqual(str(frame), "<FrameGetProtocolVersionRequest/>")
|
class TestFrameGetProtocolVersionRequest(unittest.TestCase):
'''Test class FrameGetProtocolVersionRequest.'''
def test_bytes(self):
'''Test FrameGetProtocolVersionRequest with NO_TYPE.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetProtocolVersionRequest from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetProtocolVersionRequest.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.45 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 21 | 5 | 11 | 8 | 7 | 5 | 11 | 8 | 7 | 1 | 2 | 0 | 3 |
140,288 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_scene_list_cfm_test.py
|
test.frame_get_scene_list_cfm_test.TestFrameGetSceneListConfirmation
|
class TestFrameGetSceneListConfirmation(unittest.TestCase):
"""Test class for FrameGetSceneListConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FrameGetSceneListConfirmation."""
frame = FrameGetSceneListConfirmation(count_scenes=12)
self.assertEqual(bytes(frame), b"\x00\x04\x04\r\x0c\x01")
def test_frame_from_raw(self):
"""Test parse FrameGetSceneListConfirmation from raw."""
frame = frame_from_raw(b"\x00\x04\x04\r\x0c\x01")
self.assertTrue(isinstance(frame, FrameGetSceneListConfirmation))
self.assertEqual(frame.count_scenes, 12)
def test_str(self):
"""Test string representation of FrameGetSceneListConfirmation."""
frame = FrameGetSceneListConfirmation(count_scenes=12)
self.assertEqual(str(frame), '<FrameGetSceneListConfirmation count_scenes="12"/>')
|
class TestFrameGetSceneListConfirmation(unittest.TestCase):
'''Test class for FrameGetSceneListConfirmation.'''
def test_bytes(self):
'''Test FrameGetSceneListConfirmation.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetSceneListConfirmation from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetSceneListConfirmation.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.45 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 20 | 4 | 11 | 7 | 7 | 5 | 11 | 7 | 7 | 1 | 2 | 0 | 3 |
140,289 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_scene_list_ntf_test.py
|
test.frame_get_scene_list_ntf_test.TestFrameGetSceneListNotification
|
class TestFrameGetSceneListNotification(unittest.TestCase):
"""Test class for FrameGetSceneListNotification."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME1 = (
b"\x00\xc8\x04\x0e\x03\x00All Window"
+ b"s Closed\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x01Sleeping "
+ b"Wide Open\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x02Bath Ope"
+ b"n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x03\xe2"
)
EXAMPLE_FRAME2 = (
b"\x00F\x04\x0e\x01\x00One Scene\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00w"
)
def test_bytes(self):
"""Test FrameGetSceneListNotification."""
frame = FrameGetSceneListNotification()
frame.scenes = [
(0, "All Windows Closed"),
(1, "Sleeping Wide Open"),
(2, "Bath Open"),
]
frame.remaining_scenes = 3
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME1)
def test_bytes_one_scene(self):
"""Test FrameGetSceneListNotification with one scene."""
frame = FrameGetSceneListNotification()
frame.scenes = [(0, "One Scene")]
frame.remaining_scenes = 0
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME2)
def test_frame_from_raw(self):
"""Test parse FrameGetSceneListNotification from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME1)
self.assertTrue(isinstance(frame, FrameGetSceneListNotification))
self.assertEqual(
frame.scenes,
[(0, "All Windows Closed"), (1, "Sleeping Wide Open"), (2, "Bath Open")],
)
self.assertEqual(frame.remaining_scenes, 3)
def test_frame_from_raw_one_scene(self):
"""Test parse FrameGetSceneListNotification from raw with one scene."""
frame = frame_from_raw(self.EXAMPLE_FRAME2)
self.assertTrue(isinstance(frame, FrameGetSceneListNotification))
self.assertEqual(frame.scenes, [(0, "One Scene")])
self.assertEqual(frame.remaining_scenes, 0)
def test_str(self):
"""Test string representation of FrameGetSceneListNotification."""
frame = FrameGetSceneListNotification()
frame.scenes = [
(0, "All Windows Closed"),
(1, "Sleeping Wide Open"),
(2, "Bath Open"),
]
frame.remaining_scenes = 3
self.assertEqual(
str(frame),
'<FrameGetSceneListNotification scenes="[(0, \'All Windows Closed\'), '
+ '(1, \'Sleeping Wide Open\'), (2, \'Bath Open\')]" remaining_scenes="3">',
)
def test_wrong_payload(self):
"""Test wrong payload length, 2 scenes in len, only one provided."""
frame = FrameGetSceneListNotification()
with self.assertRaises(PyVLXException) as ctx:
frame.from_payload(
b"\x02\x00XXX\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
)
self.assertEqual(
ctx.exception.description, "scene_list_notification_wrong_length"
)
|
class TestFrameGetSceneListNotification(unittest.TestCase):
'''Test class for FrameGetSceneListNotification.'''
def test_bytes(self):
'''Test FrameGetSceneListNotification.'''
pass
def test_bytes_one_scene(self):
'''Test FrameGetSceneListNotification with one scene.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetSceneListNotification from raw.'''
pass
def test_frame_from_raw_one_scene(self):
'''Test parse FrameGetSceneListNotification from raw with one scene.'''
pass
def test_str(self):
'''Test string representation of FrameGetSceneListNotification.'''
pass
def test_wrong_payload(self):
'''Test wrong payload length, 2 scenes in len, only one provided.'''
pass
| 7 | 7 | 10 | 0 | 9 | 1 | 1 | 0.11 | 1 | 3 | 1 | 0 | 6 | 0 | 6 | 78 | 91 | 9 | 74 | 16 | 67 | 8 | 33 | 15 | 26 | 1 | 2 | 1 | 6 |
140,290 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_scene_list_req_test.py
|
test.frame_get_scene_list_req_test.TestFrameGetSceneListRequest
|
class TestFrameGetSceneListRequest(unittest.TestCase):
"""Test class for FrameGetSceneListRequest."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FrameGetSceneListRequest with NO_TYPE."""
frame = FrameGetSceneListRequest()
self.assertEqual(bytes(frame), b"\x00\x03\x04\x0c\x0b")
def test_frame_from_raw(self):
"""Test parse FrameGetSceneListRequest from raw."""
frame = frame_from_raw(b"\x00\x03\x04\x0c\x0b")
self.assertTrue(isinstance(frame, FrameGetSceneListRequest))
def test_str(self):
"""Test string representation of FrameGetSceneListRequest."""
frame = FrameGetSceneListRequest()
self.assertEqual(str(frame), "<FrameGetSceneListRequest/>")
|
class TestFrameGetSceneListRequest(unittest.TestCase):
'''Test class for FrameGetSceneListRequest.'''
def test_bytes(self):
'''Test FrameGetSceneListRequest with NO_TYPE.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetSceneListRequest from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetSceneListRequest.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.5 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 19 | 4 | 10 | 7 | 6 | 5 | 10 | 7 | 6 | 1 | 2 | 0 | 3 |
140,291 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_state_cfm_test.py
|
test.frame_get_state_cfm_test.TestFrameGetStateConfirmation
|
class TestFrameGetStateConfirmation(unittest.TestCase):
"""Test class FrameGetStateConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\t\x00\r\x03\x80\x00\x00\x00\x00\x87"
def test_bytes(self):
"""Test FrameGetStateConfirmation with NO_TYPE."""
frame = FrameGetStateConfirmation()
frame.gateway_state = GatewayState.BEACON_MODE_NOT_CONFIGURED
frame.gateway_sub_state = GatewaySubState.PERFORMING_TASK_COMMAND
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameGetStateConfirmation from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameGetStateConfirmation))
self.assertEqual(frame.gateway_state, GatewayState.BEACON_MODE_NOT_CONFIGURED)
self.assertEqual(
frame.gateway_sub_state, GatewaySubState.PERFORMING_TASK_COMMAND
)
def test_str(self):
"""Test string representation of FrameGetStateConfirmation."""
frame = FrameGetStateConfirmation()
frame.gateway_state = GatewayState.BEACON_MODE_NOT_CONFIGURED
frame.gateway_sub_state = GatewaySubState.PERFORMING_TASK_COMMAND
self.assertEqual(
str(frame),
"<FrameGetStateConfirmation "
'gateway_state="GatewayState.BEACON_MODE_NOT_CONFIGURED" '
'gateway_sub_state="GatewaySubState.PERFORMING_TASK_COMMAND"/>',
)
|
class TestFrameGetStateConfirmation(unittest.TestCase):
'''Test class FrameGetStateConfirmation.'''
def test_bytes(self):
'''Test FrameGetStateConfirmation with NO_TYPE.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetStateConfirmation from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetStateConfirmation.'''
pass
| 4 | 4 | 8 | 0 | 7 | 1 | 1 | 0.21 | 1 | 5 | 3 | 0 | 3 | 0 | 3 | 75 | 34 | 5 | 24 | 8 | 20 | 5 | 17 | 8 | 13 | 1 | 2 | 0 | 3 |
140,292 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_state_req_test.py
|
test.frame_get_state_req_test.TestFrameGetStateRequest
|
class TestFrameGetStateRequest(unittest.TestCase):
"""Test class FrameGetStateRequest."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x03\x00\x0c\x0f"
def test_bytes(self):
"""Test FrameGetStateRequest with NO_TYPE."""
frame = FrameGetStateRequest()
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameGetStateRequest from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameGetStateRequest))
def test_str(self):
"""Test string representation of FrameGetStateRequest."""
frame = FrameGetStateRequest()
self.assertEqual(str(frame), "<FrameGetStateRequest/>")
|
class TestFrameGetStateRequest(unittest.TestCase):
'''Test class FrameGetStateRequest.'''
def test_bytes(self):
'''Test FrameGetStateRequest with NO_TYPE.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetStateRequest from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetStateRequest.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.45 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 21 | 5 | 11 | 8 | 7 | 5 | 11 | 8 | 7 | 1 | 2 | 0 | 3 |
140,293 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_get_version_cfm_test.py
|
test.frame_get_version_cfm_test.TestFrameGetVersionConfirmation
|
class TestFrameGetVersionConfirmation(unittest.TestCase):
"""Test class for FrameGetVersionConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x0c\x00\t\x01\x02\x03\x04\x05\x06\x17\x0e\x03\x18"
def test_bytes(self):
"""Test FrameGetVersionConfirmation."""
frame = FrameGetVersionConfirmation(
software_version="1.2.3.4.5.6", hardware_version=23
)
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameGetVersionConfirmation from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameGetVersionConfirmation))
self.assertEqual(frame.software_version, "1.2.3.4.5.6")
self.assertEqual(frame.hardware_version, 23)
self.assertEqual(frame.product, "KLF 200")
def test_str(self):
"""Test string representation of FrameGetVersionConfirmation."""
frame = FrameGetVersionConfirmation(
software_version="1.2.3.4.5.6", hardware_version=23
)
self.assertEqual(
str(frame),
'<FrameGetVersionConfirmation software_version="1.2.3.4.5.6" hardware_version="23" product="KLF 200"/>',
)
def test_version(self):
"""Test version string."""
frame = FrameGetVersionConfirmation(
software_version="1.2.3.4.5.6", hardware_version=23
)
self.assertEqual(
frame.version,
"KLF 200: Software version: 1.2.3.4.5.6, hardware version: 23",
)
def test_product(self):
"""Test formatting of product."""
frame = FrameGetVersionConfirmation()
self.assertEqual(frame.product, "KLF 200")
frame.product_type = 42
frame.product_group = 23
self.assertEqual(frame.product, "Unknown Product: 23:42")
|
class TestFrameGetVersionConfirmation(unittest.TestCase):
'''Test class for FrameGetVersionConfirmation.'''
def test_bytes(self):
'''Test FrameGetVersionConfirmation.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGetVersionConfirmation from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetVersionConfirmation.'''
pass
def test_version(self):
'''Test version string.'''
pass
def test_product(self):
'''Test formatting of product.'''
pass
| 6 | 6 | 8 | 0 | 7 | 1 | 1 | 0.2 | 1 | 3 | 1 | 0 | 5 | 0 | 5 | 77 | 49 | 7 | 35 | 12 | 29 | 7 | 23 | 12 | 17 | 1 | 2 | 0 | 5 |
140,294 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_house_status_monitor_disable_cfm_test.py
|
test.frame_house_status_monitor_disable_cfm_test.TestFrameHouseStatusMonitorDisableConfirmation
|
class TestFrameHouseStatusMonitorDisableConfirmation(unittest.TestCase):
"""Test class FrameHouseStatusMonitorDisableConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x03\x02CB"
def test_bytes(self):
"""Test FrameHouseStatusMonitorDisableConfirmation."""
frame = FrameHouseStatusMonitorDisableConfirmation()
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameHouseStatusMonitorDisableConfirmation from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameHouseStatusMonitorDisableConfirmation))
def test_str(self):
"""Test string representation of FrameHouseStatusMonitorDisableConfirmation."""
frame = FrameHouseStatusMonitorDisableConfirmation()
self.assertEqual(str(frame), "<FrameHouseStatusMonitorDisableConfirmation/>")
|
class TestFrameHouseStatusMonitorDisableConfirmation(unittest.TestCase):
'''Test class FrameHouseStatusMonitorDisableConfirmation.'''
def test_bytes(self):
'''Test FrameHouseStatusMonitorDisableConfirmation.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameHouseStatusMonitorDisableConfirmation from raw.'''
pass
def test_str(self):
'''Test string representation of FrameHouseStatusMonitorDisableConfirmation.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.45 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 21 | 5 | 11 | 8 | 7 | 5 | 11 | 8 | 7 | 1 | 2 | 0 | 3 |
140,295 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_house_status_monitor_disable_req_test.py
|
test.frame_house_status_monitor_disable_req_test.TestFrameHouseStatusMonitorDisableRequest
|
class TestFrameHouseStatusMonitorDisableRequest(unittest.TestCase):
"""Test class FrameHouseStatusMonitorDisableRequest."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x03\x02BC"
def test_bytes(self):
"""Test FrameHouseStatusMonitorDisableRequest."""
frame = FrameHouseStatusMonitorDisableRequest()
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameHouseStatusMonitorDisableRequest from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameHouseStatusMonitorDisableRequest))
def test_str(self):
"""Test string representation of FrameHouseStatusMonitorDisableRequest."""
frame = FrameHouseStatusMonitorDisableRequest()
self.assertEqual(str(frame), "<FrameHouseStatusMonitorDisableRequest/>")
|
class TestFrameHouseStatusMonitorDisableRequest(unittest.TestCase):
'''Test class FrameHouseStatusMonitorDisableRequest.'''
def test_bytes(self):
'''Test FrameHouseStatusMonitorDisableRequest.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameHouseStatusMonitorDisableRequest from raw.'''
pass
def test_str(self):
'''Test string representation of FrameHouseStatusMonitorDisableRequest.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.45 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 21 | 5 | 11 | 8 | 7 | 5 | 11 | 8 | 7 | 1 | 2 | 0 | 3 |
140,296 |
Julius2342/pyvlx
|
Julius2342_pyvlx/pyvlx/api/frames/frame_get_network_setup.py
|
pyvlx.api.frames.frame_get_network_setup.FrameGetNetworkSetupConfirmation
|
class FrameGetNetworkSetupConfirmation(FrameBase):
"""Frame for confirmation for get network setup requests."""
PAYLOAD_LEN = 13
def __init__(self, ipaddress: bytes = bytes(4), netmask: bytes = bytes(4), gateway: bytes = bytes(4),
dhcp: DHCPParameter = DHCPParameter.DISABLE):
"""Init Frame."""
super().__init__(Command.GW_GET_NETWORK_SETUP_CFM)
self._ipaddress = ipaddress
self._netmask = netmask
self._gateway = gateway
self.dhcp = dhcp
@property
def ipaddress(self) -> str:
"""Return ipaddress as human readable string."""
return ".".join(str(c) for c in self._ipaddress)
@property
def netmask(self) -> str:
"""Return ipaddress as human readable string."""
return ".".join(str(c) for c in self._netmask)
@property
def gateway(self) -> str:
"""Return ipaddress as human readable string."""
return ".".join(str(c) for c in self._gateway)
def get_payload(self) -> bytes:
"""Return Payload."""
payload = self._ipaddress
payload += self._netmask
payload += self._gateway
payload += bytes(self.dhcp.value)
return payload
def from_payload(self, payload: bytes) -> None:
"""Init frame from binary data."""
self._ipaddress = payload[0:4]
self._netmask = payload[4:8]
self._gateway = payload[8:12]
self.dhcp = DHCPParameter(payload[12])
def __str__(self) -> str:
"""Return human readable string."""
return '<{} ipaddress="{}" netmask="{}" gateway="{}" dhcp="{}"/>'.format(
type(self).__name__, self.ipaddress, self.netmask, self.gateway, self.dhcp)
|
class FrameGetNetworkSetupConfirmation(FrameBase):
'''Frame for confirmation for get network setup requests.'''
def __init__(self, ipaddress: bytes = bytes(4), netmask:
'''Init Frame.'''
pass
@property
def ipaddress(self) -> str:
'''Return ipaddress as human readable string.'''
pass
@property
def netmask(self) -> str:
'''Return ipaddress as human readable string.'''
pass
@property
def gateway(self) -> str:
'''Return ipaddress as human readable string.'''
pass
def get_payload(self) -> bytes:
'''Return Payload.'''
pass
def from_payload(self, payload: bytes) -> None:
'''Init frame from binary data.'''
pass
def __str__(self) -> str:
'''Return human readable string.'''
pass
| 11 | 8 | 5 | 0 | 4 | 1 | 1 | 0.25 | 1 | 6 | 2 | 0 | 7 | 4 | 7 | 14 | 48 | 8 | 32 | 18 | 20 | 8 | 27 | 14 | 19 | 1 | 1 | 0 | 7 |
140,297 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_house_status_monitor_enable_req_test.py
|
test.frame_house_status_monitor_enable_req_test.TestFrameHouseStatusMonitorEnableRequest
|
class TestFrameHouseStatusMonitorEnableRequest(unittest.TestCase):
"""Test class FrameHouseStatusMonitorEnableRequest."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x03\x02@A"
def test_bytes(self):
"""Test FrameHouseStatusMonitorEnableRequest."""
frame = FrameHouseStatusMonitorEnableRequest()
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameHouseStatusMonitorEnableRequest from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameHouseStatusMonitorEnableRequest))
def test_str(self):
"""Test string representation of FrameHouseStatusMonitorEnableRequest."""
frame = FrameHouseStatusMonitorEnableRequest()
self.assertEqual(str(frame), "<FrameHouseStatusMonitorEnableRequest/>")
|
class TestFrameHouseStatusMonitorEnableRequest(unittest.TestCase):
'''Test class FrameHouseStatusMonitorEnableRequest.'''
def test_bytes(self):
'''Test FrameHouseStatusMonitorEnableRequest.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameHouseStatusMonitorEnableRequest from raw.'''
pass
def test_str(self):
'''Test string representation of FrameHouseStatusMonitorEnableRequest.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.45 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 21 | 5 | 11 | 8 | 7 | 5 | 11 | 8 | 7 | 1 | 2 | 0 | 3 |
140,298 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_status_request_test.py
|
test.frame_status_request_test.TestFrameStatusRequestConfirmation
|
class TestFrameStatusRequestConfirmation(unittest.TestCase):
"""Test class FrameStatusRequestConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x06\x03\x06\x00\xab\x01\xa9"
def test_bytes(self) -> None:
"""Test FrameStatusRequestConfirmation with session_id 0xAB and status ACCEPTED."""
frame = FrameStatusRequestConfirmation(session_id=0xAB, status=StatusRequestStatus.ACCEPTED)
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self) -> None:
"""Test parse FrameStatusRequestConfirmation from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameStatusRequestConfirmation))
def test_str(self) -> None:
"""Test string representation of FrameStatusRequestConfirmation."""
frame = FrameStatusRequestConfirmation(session_id=0xAB, status=StatusRequestStatus.ACCEPTED)
self.assertEqual(str(frame),
"<FrameStatusRequestConfirmation session_id=\"171\" status=\"StatusRequestStatus.ACCEPTED\"/>")
|
class TestFrameStatusRequestConfirmation(unittest.TestCase):
'''Test class FrameStatusRequestConfirmation.'''
def test_bytes(self) -> None:
'''Test FrameStatusRequestConfirmation with session_id 0xAB and status ACCEPTED.'''
pass
def test_frame_from_raw(self) -> None:
'''Test parse FrameStatusRequestConfirmation from raw.'''
pass
def test_str(self) -> None:
'''Test string representation of FrameStatusRequestConfirmation.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.42 | 1 | 4 | 2 | 0 | 3 | 0 | 3 | 75 | 22 | 5 | 12 | 8 | 8 | 5 | 11 | 8 | 7 | 1 | 2 | 0 | 3 |
140,299 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_status_request_test.py
|
test.frame_status_request_test.TestFrameStatusRequestRequest
|
class TestFrameStatusRequestRequest(unittest.TestCase):
"""Test class FrameStatusRequestRequest."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x1d\x03\x05\x00\xab\x02\x01\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
b"\x00\x00\x00\x00\x01\xfe\x00N"
def test_bytes(self) -> None:
"""Test FrameStatusRequestRequest with nodes 1,2 and session_id 0xAB."""
frame = FrameStatusRequestRequest(node_ids=[1, 2], session_id=0xAB)
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self) -> None:
"""Test parse FrameStatusRequestRequest from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameStatusRequestRequest))
def test_str(self) -> None:
"""Test string representation of FrameStatusRequestRequest."""
frame = FrameStatusRequestRequest(node_ids=[1, 2], session_id=0xAB)
self.assertEqual(str(frame), "<FrameStatusRequestRequest session_id=\"171\" node_ids=\"[1, 2]\" "
"status_type=\"StatusType.REQUEST_CURRENT_POSITION\" fpi1=\"254\" fpi2=\"0\"/>")
|
class TestFrameStatusRequestRequest(unittest.TestCase):
'''Test class FrameStatusRequestRequest.'''
def test_bytes(self) -> None:
'''Test FrameStatusRequestRequest with nodes 1,2 and session_id 0xAB.'''
pass
def test_frame_from_raw(self) -> None:
'''Test parse FrameStatusRequestRequest from raw.'''
pass
def test_str(self) -> None:
'''Test string representation of FrameStatusRequestRequest.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.38 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 23 | 5 | 13 | 8 | 9 | 5 | 11 | 8 | 7 | 1 | 2 | 0 | 3 |
140,300 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_test.py
|
test.frame_test.TestFrame
|
class TestFrame(unittest.TestCase):
"""Test class FrameBase class."""
# pylint: disable=too-many-public-methods,invalid-name
def test_validate_payload_len_no_payload_len_defined(self):
"""Test validate_payload_len_function without any PAYLOAD_LEN defined."""
frame = FrameBase(command=Command.GW_GET_NODE_INFORMATION_REQ)
frame.validate_payload_len(bytes(23))
def test_validate_payload_len_payload_len_defined(self):
"""Test validate_payload_len_function with defined PAYLOAD_LEN."""
frame = FrameBase(command=Command.GW_GET_NODE_INFORMATION_REQ)
# pylint: disable=invalid-name
frame.PAYLOAD_LEN = 23
frame.validate_payload_len(bytes(23))
def test_validate_payload_len_payload_len_error(self):
"""Test validate_payload_len_function with wrong PAYLOAD_LEN."""
frame = FrameBase(command=Command.GW_GET_NODE_INFORMATION_REQ)
frame.PAYLOAD_LEN = 42
with self.assertRaises(PyVLXException):
frame.validate_payload_len(bytes(23))
|
class TestFrame(unittest.TestCase):
'''Test class FrameBase class.'''
def test_validate_payload_len_no_payload_len_defined(self):
'''Test validate_payload_len_function without any PAYLOAD_LEN defined.'''
pass
def test_validate_payload_len_payload_len_defined(self):
'''Test validate_payload_len_function with defined PAYLOAD_LEN.'''
pass
def test_validate_payload_len_payload_len_error(self):
'''Test validate_payload_len_function with wrong PAYLOAD_LEN.'''
pass
| 4 | 4 | 5 | 0 | 4 | 1 | 1 | 0.46 | 1 | 3 | 2 | 0 | 3 | 0 | 3 | 75 | 23 | 4 | 13 | 7 | 9 | 6 | 13 | 7 | 9 | 1 | 2 | 1 | 3 |
140,301 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/get_limitation_test.py
|
test.get_limitation_test.TestGetLimitation
|
class TestGetLimitation(unittest.TestCase):
"""Test class for Limitation."""
def setUp(self) -> None:
"""Set up TestGetLimitation."""
self.pyvlx = MagicMock(spec=PyVLX)
def test_get_name(self) -> None:
"""Test get_name()."""
limit = GetLimitation(self.pyvlx, 1)
self.assertEqual(limit.node_id, 1)
self.assertEqual(limit.limitation_type, LimitationType.MIN_LIMITATION)
limit = GetLimitation(self.pyvlx, 2, LimitationType.MAX_LIMITATION)
self.assertEqual(limit.node_id, 2)
self.assertEqual(limit.limitation_type, LimitationType.MAX_LIMITATION)
def test_max_value(self) -> None:
"""Test limit.max_value."""
limit = GetLimitation(self.pyvlx, 1)
limit.max_value_raw = b'\xf7'
self.assertEqual(limit.max_value, 124)
def test_min_value(self) -> None:
"""Test limit.min_value."""
limit = GetLimitation(self.pyvlx, 1)
limit.min_value_raw = b'\xba'
self.assertEqual(limit.min_value, 93)
def test_handle_frame(self) -> None:
"""Test handle frame."""
limit = GetLimitation(self.pyvlx, 1)
frame = FrameGetLimitationStatus()
self.assertFalse(self.event_loop.run_until_complete(limit.handle_frame(frame)))
self.assertFalse(limit.success)
frame = FrameGetLimitationStatusConfirmation()
self.assertFalse(self.event_loop.run_until_complete(limit.handle_frame(frame)))
self.assertFalse(limit.success)
frame = FrameGetLimitationStatusNotification()
frame.session_id = 1
frame.node_id = 1
frame.min_value = b'\xf7'
frame.max_value = b'\xba'
frame.limit_originator = Originator.USER
frame.limit_time = 1
limit.session_id = 0
self.assertFalse(self.event_loop.run_until_complete(limit.handle_frame(frame)))
self.assertFalse(limit.success) # Session id is wrong
limit.session_id = frame.session_id
self.assertTrue(self.event_loop.run_until_complete(limit.handle_frame(frame)))
self.assertTrue(limit.success)
self.assertEqual(limit.node_id, frame.node_id)
self.assertEqual(limit.session_id, frame.session_id)
self.assertEqual(limit.min_value, 124)
self.assertEqual(limit.max_value, 93)
self.assertEqual(limit.originator, frame.limit_originator)
self.assertEqual(limit.limit_time, frame.limit_time)
def test_request_frame(self) -> None:
"""Test initiating frame."""
limit = GetLimitation(self.pyvlx, 1)
req_frame = limit.request_frame()
self.assertIsInstance(req_frame, FrameGetLimitationStatus)
self.assertTrue(req_frame.session_id, 1)
self.assertTrue(req_frame.node_ids, [1])
self.assertTrue(req_frame.limitations_type, limit.limitation_type)
limit.limitation_type = LimitationType.MAX_LIMITATION
self.assertIsInstance(req_frame, FrameGetLimitationStatus)
self.assertTrue(req_frame.session_id, 1)
self.assertTrue(req_frame.limitations_type, limit.limitation_type)
|
class TestGetLimitation(unittest.TestCase):
'''Test class for Limitation.'''
def setUp(self) -> None:
'''Set up TestGetLimitation.'''
pass
def test_get_name(self) -> None:
'''Test get_name().'''
pass
def test_max_value(self) -> None:
'''Test limit.max_value.'''
pass
def test_min_value(self) -> None:
'''Test limit.min_value.'''
pass
def test_handle_frame(self) -> None:
'''Test handle frame.'''
pass
def test_request_frame(self) -> None:
'''Test initiating frame.'''
pass
| 7 | 7 | 11 | 1 | 9 | 1 | 1 | 0.14 | 1 | 8 | 7 | 0 | 6 | 1 | 6 | 78 | 75 | 12 | 56 | 15 | 49 | 8 | 56 | 15 | 49 | 1 | 2 | 0 | 6 |
140,302 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/lightening_device_test.py
|
test.lightening_device_test.TestLighteningDevice
|
class TestLighteningDevice(unittest.TestCase):
"""Test class for lights."""
def setUp(self) -> None:
"""Set up TestGetLimitation."""
self.pyvlx = MagicMock(spec=PyVLX)
connection = MagicMock(spec=Connection)
self.pyvlx.attach_mock(mock=connection, attribute="connection")
def test_light_str(self) -> None:
"""Test string representation of Light object."""
light = Light(
pyvlx=self.pyvlx,
node_id=23,
name="Test Light",
serial_number="aa:bb:aa:bb:aa:bb:aa:23",
)
self.assertEqual(
str(light),
'<Light name="Test Light" node_id="23" serial_number="aa:bb:aa:bb:aa:bb:aa:23"/>',
)
def test_eq(self) -> None:
"""Testing eq method with positive results."""
node1 = Light(
pyvlx=self.pyvlx, node_id=23, name="xxx", serial_number="aa:bb:aa:bb:aa:bb:aa:23"
)
node2 = Light(
pyvlx=self.pyvlx, node_id=23, name="xxx", serial_number="aa:bb:aa:bb:aa:bb:aa:23"
)
self.assertEqual(node1, node2)
def test_nq(self) -> None:
"""Testing eq method with negative results."""
node1 = Light(
pyvlx=self.pyvlx, node_id=23, name="xxx", serial_number="aa:bb:aa:bb:aa:bb:aa:23"
)
node2 = Light(
pyvlx=self.pyvlx, node_id=24, name="xxx", serial_number="aa:bb:aa:bb:aa:bb:aa:23"
)
self.assertNotEqual(node1, node2)
|
class TestLighteningDevice(unittest.TestCase):
'''Test class for lights.'''
def setUp(self) -> None:
'''Set up TestGetLimitation.'''
pass
def test_light_str(self) -> None:
'''Test string representation of Light object.'''
pass
def test_eq(self) -> None:
'''Testing eq method with positive results.'''
pass
def test_nq(self) -> None:
'''Testing eq method with negative results.'''
pass
| 5 | 5 | 9 | 0 | 8 | 1 | 1 | 0.16 | 1 | 4 | 2 | 0 | 4 | 1 | 4 | 76 | 41 | 4 | 32 | 12 | 27 | 5 | 16 | 12 | 11 | 1 | 2 | 0 | 4 |
140,303 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/node_helper_test.py
|
test.node_helper_test.TestNodeHelper
|
class TestNodeHelper(unittest.TestCase):
"""Test class for helper functions of node_helper."""
# pylint: disable=too-many-public-methods,invalid-name
def setUp(self) -> None:
"""Set up TestNodeHelper."""
self.pyvlx = MagicMock(spec=PyVLX)
connection = MagicMock(spec=Connection)
self.pyvlx.attach_mock(mock=connection, attribute="connection")
def test_window(self) -> None:
"""Test convert_frame_to_node with window."""
frame = FrameGetNodeInformationNotification()
frame.node_id = 23
frame.name = "Fnord23"
frame.node_type = NodeTypeWithSubtype.WINDOW_OPENER
frame.serial_number = "aa:bb:aa:bb:aa:bb:aa:23"
node = convert_frame_to_node(self.pyvlx, frame)
self.assertEqual(
node,
Window(
pyvlx=self.pyvlx,
name="Fnord23",
node_id=23,
serial_number="aa:bb:aa:bb:aa:bb:aa:23",
),
)
def test_window_with_rain_sensor(self) -> None:
"""Test convert_frame_to_node with window with rain sensor."""
frame = FrameGetNodeInformationNotification()
frame.node_id = 23
frame.name = "Fnord23"
frame.node_type = NodeTypeWithSubtype.WINDOW_OPENER_WITH_RAIN_SENSOR
frame.serial_number = "aa:bb:aa:bb:aa:bb:aa:23"
node = convert_frame_to_node(self.pyvlx, frame)
self.assertEqual(
node,
Window(
pyvlx=self.pyvlx,
name="Fnord23",
node_id=23,
rain_sensor=True,
serial_number="aa:bb:aa:bb:aa:bb:aa:23",
),
)
def test_blind(self) -> None:
"""Test convert_frame_to_node with blind."""
frame = FrameGetNodeInformationNotification()
frame.node_id = 23
frame.name = "Fnord23"
frame.node_type = NodeTypeWithSubtype.EXTERIOR_VENETIAN_BLIND
frame.serial_number = "aa:bb:aa:bb:aa:bb:aa:23"
node = convert_frame_to_node(self.pyvlx, frame)
self.assertEqual(
node,
Blind(
pyvlx=self.pyvlx,
name="Fnord23",
node_id=23,
serial_number="aa:bb:aa:bb:aa:bb:aa:23",
),
)
def test_roller_shutter(self) -> None:
"""Test convert_frame_to_node roller shutter."""
frame = FrameGetNodeInformationNotification()
frame.node_id = 23
frame.name = "Fnord23"
frame.node_type = NodeTypeWithSubtype.ROLLER_SHUTTER
frame.serial_number = "aa:bb:aa:bb:aa:bb:aa:23"
node = convert_frame_to_node(self.pyvlx, frame)
self.assertEqual(
node,
RollerShutter(
pyvlx=self.pyvlx,
name="Fnord23",
node_id=23,
serial_number="aa:bb:aa:bb:aa:bb:aa:23",
),
)
def test_garage_door(self) -> None:
"""Test convert_frame_to_node garage door."""
frame = FrameGetNodeInformationNotification()
frame.node_id = 23
frame.name = "Fnord23"
frame.node_type = NodeTypeWithSubtype.GARAGE_DOOR_OPENER
frame.serial_number = "aa:bb:aa:bb:aa:bb:aa:23"
node = convert_frame_to_node(self.pyvlx, frame)
self.assertEqual(
node,
GarageDoor(
pyvlx=self.pyvlx,
name="Fnord23",
node_id=23,
serial_number="aa:bb:aa:bb:aa:bb:aa:23",
),
)
def test_linar_angular_position_of_garage_door(self) -> None:
"""Test convert_frame_to_node linar angular position of garage door."""
frame = FrameGetNodeInformationNotification()
frame.node_id = 23
frame.name = "Fnord23"
frame.node_type = NodeTypeWithSubtype.LINAR_ANGULAR_POSITION_OF_GARAGE_DOOR
frame.serial_number = "aa:bb:aa:bb:aa:bb:aa:23"
node = convert_frame_to_node(self.pyvlx, frame)
self.assertEqual(
node,
GarageDoor(
pyvlx=self.pyvlx,
name="Fnord23",
node_id=23,
serial_number="aa:bb:aa:bb:aa:bb:aa:23",
),
)
def test_gate(self) -> None:
"""Test convert_frame_to_node gate."""
frame = FrameGetNodeInformationNotification()
frame.node_id = 23
frame.name = "Fnord23"
frame.node_type = NodeTypeWithSubtype.GATE_OPENER
frame.serial_number = "aa:bb:aa:bb:aa:bb:aa:23"
node = convert_frame_to_node(self.pyvlx, frame)
self.assertEqual(
node,
Gate(
pyvlx=self.pyvlx,
name="Fnord23",
node_id=23,
serial_number="aa:bb:aa:bb:aa:bb:aa:23",
),
)
def test_gate_with_angular_position(self) -> None:
"""Test convert_frame_to_node gate."""
frame = FrameGetNodeInformationNotification()
frame.node_id = 23
frame.name = "Fnord23"
frame.node_type = NodeTypeWithSubtype.GATE_OPENER_ANGULAR_POSITION
frame.serial_number = "aa:bb:aa:bb:aa:bb:aa:23"
node = convert_frame_to_node(self.pyvlx, frame)
self.assertEqual(
node,
Gate(
pyvlx=self.pyvlx,
name="Fnord23",
node_id=23,
serial_number="aa:bb:aa:bb:aa:bb:aa:23",
),
)
def test_blade(self) -> None:
"""Test convert_frame_to_node blade."""
frame = FrameGetNodeInformationNotification()
frame.node_id = 23
frame.name = "Fnord23"
frame.node_type = NodeTypeWithSubtype.BLADE_OPENER
frame.serial_number = "aa:bb:aa:bb:aa:bb:aa:23"
node = convert_frame_to_node(self.pyvlx, frame)
self.assertEqual(
node,
Blade(
pyvlx=self.pyvlx,
name="Fnord23",
node_id=23,
serial_number="aa:bb:aa:bb:aa:bb:aa:23",
),
)
def test_no_type(self) -> None:
"""Test convert_frame_to_node with no type (convert_frame_to_node should return None)."""
frame = FrameGetNodeInformationNotification()
frame.node_id = 23
frame.name = "Fnord23"
frame.node_type = NodeTypeWithSubtype.NO_TYPE
frame.serial_number = "aa:bb:aa:bb:aa:bb:aa:23"
self.assertEqual(convert_frame_to_node(self.pyvlx, frame), None)
def test_light(self) -> None:
"""Test convert_frame_to_node with light."""
frame = FrameGetNodeInformationNotification()
frame.node_id = 23
frame.name = "Fnord23"
frame.node_type = NodeTypeWithSubtype.LIGHT
frame.serial_number = "aa:bb:aa:bb:aa:bb:aa:23"
node = convert_frame_to_node(self.pyvlx, frame)
self.assertEqual(
node,
Light(
pyvlx=self.pyvlx,
name="Fnord23",
node_id=23,
serial_number="aa:bb:aa:bb:aa:bb:aa:23",
),
)
def test_light_on_off(self) -> None:
"""Test convert_frame_to_node with light_on_off."""
frame = FrameGetNodeInformationNotification()
frame.node_id = 23
frame.name = "Fnord23"
frame.node_type = NodeTypeWithSubtype.LIGHT_ON_OFF
frame.serial_number = "aa:bb:aa:bb:aa:bb:aa:23"
node = convert_frame_to_node(self.pyvlx, frame)
self.assertEqual(
node,
Light(
pyvlx=self.pyvlx,
name="Fnord23",
node_id=23,
serial_number="aa:bb:aa:bb:aa:bb:aa:23",
),
)
|
class TestNodeHelper(unittest.TestCase):
'''Test class for helper functions of node_helper.'''
def setUp(self) -> None:
'''Set up TestNodeHelper.'''
pass
def test_window(self) -> None:
'''Test convert_frame_to_node with window.'''
pass
def test_window_with_rain_sensor(self) -> None:
'''Test convert_frame_to_node with window with rain sensor.'''
pass
def test_blind(self) -> None:
'''Test convert_frame_to_node with blind.'''
pass
def test_roller_shutter(self) -> None:
'''Test convert_frame_to_node roller shutter.'''
pass
def test_garage_door(self) -> None:
'''Test convert_frame_to_node garage door.'''
pass
def test_linar_angular_position_of_garage_door(self) -> None:
'''Test convert_frame_to_node linar angular position of garage door.'''
pass
def test_gate(self) -> None:
'''Test convert_frame_to_node gate.'''
pass
def test_gate_with_angular_position(self) -> None:
'''Test convert_frame_to_node gate.'''
pass
def test_blade(self) -> None:
'''Test convert_frame_to_node blade.'''
pass
def test_no_type(self) -> None:
'''Test convert_frame_to_node with no type (convert_frame_to_node should return None).'''
pass
def test_light(self) -> None:
'''Test convert_frame_to_node with light.'''
pass
def test_light_on_off(self) -> None:
'''Test convert_frame_to_node with light_on_off.'''
pass
| 14 | 14 | 15 | 0 | 14 | 1 | 1 | 0.08 | 1 | 5 | 4 | 0 | 13 | 1 | 13 | 85 | 218 | 14 | 189 | 39 | 175 | 15 | 100 | 39 | 86 | 1 | 2 | 0 | 13 |
140,304 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_set_utc_req_test.py
|
test.frame_set_utc_req_test.TestFrameSetUTCRequest
|
class TestFrameSetUTCRequest(unittest.TestCase):
"""Test class FrameSetUTCRequest."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x07 \x00[\xfd\xaanE"
EXAMPLE_TS = 1543350894
def test_bytes(self):
"""Test FrameSetUTCRequest with NO_TYPE."""
frame = FrameSetUTCRequest(timestamp=self.EXAMPLE_TS)
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameSetUTCRequest from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameSetUTCRequest))
self.assertEqual(frame.timestamp, self.EXAMPLE_TS)
def test_str(self):
"""Test string representation of FrameSetUTCRequest."""
frame = FrameSetUTCRequest(timestamp=1543350894)
test_ts = datetime.fromtimestamp(1543350894).strftime("%Y-%m-%d %H:%M:%S")
self.assertEqual(str(frame), '<FrameSetUTCRequest time="{}"/>'.format(test_ts))
|
class TestFrameSetUTCRequest(unittest.TestCase):
'''Test class FrameSetUTCRequest.'''
def test_bytes(self):
'''Test FrameSetUTCRequest with NO_TYPE.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameSetUTCRequest from raw.'''
pass
def test_str(self):
'''Test string representation of FrameSetUTCRequest.'''
pass
| 4 | 4 | 5 | 0 | 4 | 1 | 1 | 0.36 | 1 | 4 | 1 | 0 | 3 | 0 | 3 | 75 | 24 | 5 | 14 | 10 | 10 | 5 | 14 | 10 | 10 | 1 | 2 | 0 | 3 |
140,305 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/nodes_test.py
|
test.nodes_test.TestNodes
|
class TestNodes(unittest.TestCase):
"""Test class for nodes object."""
def setUp(self) -> None:
"""Set up TestNodes."""
self.pyvlx = MagicMock(spec=PyVLX)
connection = MagicMock(spec=Connection)
self.pyvlx.attach_mock(mock=connection, attribute="connection")
def test_get_item(self) -> None:
"""Test get_item."""
nodes = Nodes(self.pyvlx)
window = Window(self.pyvlx, 0, "Window", "aa:bb:aa:bb:aa:bb:aa:00")
nodes.add(window)
blind = Blind(self.pyvlx, 1, "Blind", "aa:bb:aa:bb:aa:bb:aa:01")
nodes.add(blind)
roller_shutter = RollerShutter(
self.pyvlx, 4, "Roller Shutter", "aa:bb:aa:bb:aa:bb:aa:04"
)
nodes.add(roller_shutter)
self.assertEqual(nodes["Window"], window)
self.assertEqual(nodes["Blind"], blind)
self.assertEqual(nodes["Roller Shutter"], roller_shutter)
self.assertEqual(nodes[0], window)
self.assertEqual(nodes[1], blind)
self.assertEqual(nodes[4], roller_shutter)
def test_get_item_failed(self) -> None:
"""Test get_item with non existing object."""
nodes = Nodes(self.pyvlx)
window1 = Window(self.pyvlx, 0, "Window_1", "aa:bb:aa:bb:aa:bb:aa:00")
nodes.add(window1)
with self.assertRaises(KeyError):
nodes["Window_2"] # pylint: disable=pointless-statement
with self.assertRaises(KeyError):
nodes[1] # pylint: disable=pointless-statement
def test_contains_item(self) -> None:
"""Test contains operator."""
nodes = Nodes(self.pyvlx)
window1 = Window(self.pyvlx, 23, "Window_1", "aa:bb:aa:bb:aa:bb:aa:23")
nodes.add(window1)
window2 = Window(self.pyvlx, 42, "Window_2", "aa:bb:aa:bb:aa:bb:aa:42") # not added
self.assertTrue("Window_1" in nodes)
self.assertTrue(23 in nodes)
self.assertTrue(window1 in nodes)
self.assertFalse("Window_2" in nodes)
self.assertFalse(42 in nodes)
self.assertFalse(window2 in nodes)
def test_iter(self) -> None:
"""Test iterator."""
nodes = Nodes(self.pyvlx)
window1 = Window(self.pyvlx, 0, "Window_1", "aa:bb:aa:bb:aa:bb:aa:00")
nodes.add(window1)
window2 = Window(self.pyvlx, 1, "Window_2", "aa:bb:aa:bb:aa:bb:aa:01")
nodes.add(window2)
window3 = Window(self.pyvlx, 2, "Window_3", "aa:bb:aa:bb:aa:bb:aa:02")
nodes.add(window3)
self.assertEqual(tuple(nodes.__iter__()), (window1, window2, window3)) # pylint: disable=unnecessary-dunder-call
def test_len(self) -> None:
"""Test len."""
nodes = Nodes(self.pyvlx)
self.assertEqual(len(nodes), 0)
nodes.add(Window(self.pyvlx, 0, "Window_1", "aa:bb:aa:bb:aa:bb:aa:00"))
nodes.add(Window(self.pyvlx, 1, "Window_2", "aa:bb:aa:bb:aa:bb:aa:01"))
nodes.add(Window(self.pyvlx, 2, "Window_3", "aa:bb:aa:bb:aa:bb:aa:02"))
nodes.add(Window(self.pyvlx, 3, "Window_4", "aa:bb:aa:bb:aa:bb:aa:03"))
self.assertEqual(len(nodes), 4)
def test_add_same_object(self) -> None:
"""Test adding object with same node_id."""
nodes = Nodes(self.pyvlx)
self.assertEqual(len(nodes), 0)
nodes.add(Window(self.pyvlx, 0, "Window_1", "aa:bb:aa:bb:aa:bb:aa:00"))
nodes.add(Window(self.pyvlx, 1, "Window_2", "aa:bb:aa:bb:aa:bb:aa:01"))
nodes.add(Window(self.pyvlx, 2, "Window_3", "aa:bb:aa:bb:aa:bb:aa:02"))
nodes.add(Window(self.pyvlx, 1, "Window_2_same_id", "aa:bb:aa:bb:aa:bb:aa:01"))
self.assertEqual(len(nodes), 3)
self.assertEqual(nodes[1].name, "Window_2_same_id")
def test_add_item_failed(self) -> None:
"""Test add() with wrong type."""
nodes = Nodes(self.pyvlx)
with self.assertRaises(TypeError):
nodes.add(nodes) # type: ignore
with self.assertRaises(TypeError):
nodes.add("device") # type: ignore
def test_clear(self) -> None:
"""Test clear() method."""
nodes = Nodes(self.pyvlx)
self.assertEqual(len(nodes), 0)
nodes.add(Window(self.pyvlx, 0, "Window_1", "aa:bb:aa:bb:aa:bb:aa:00"))
nodes.add(Window(self.pyvlx, 1, "Window_2", "aa:bb:aa:bb:aa:bb:aa:01"))
nodes.clear()
self.assertEqual(len(nodes), 0)
def test_node_str(self) -> None:
"""Test string representation of node."""
node = Node(
pyvlx=self.pyvlx,
node_id=23,
name="Test Abstract Node",
serial_number="aa:bb:aa:bb:aa:bb:aa:23",
)
self.assertEqual(
str(node),
'<Node name="Test Abstract Node" node_id="23" serial_number="aa:bb:aa:bb:aa:bb:aa:23"/>',
)
|
class TestNodes(unittest.TestCase):
'''Test class for nodes object.'''
def setUp(self) -> None:
'''Set up TestNodes.'''
pass
def test_get_item(self) -> None:
'''Test get_item.'''
pass
def test_get_item_failed(self) -> None:
'''Test get_item with non existing object.'''
pass
def test_contains_item(self) -> None:
'''Test contains operator.'''
pass
def test_iter(self) -> None:
'''Test iterator.'''
pass
def test_len(self) -> None:
'''Test len.'''
pass
def test_add_same_object(self) -> None:
'''Test adding object with same node_id.'''
pass
def test_add_item_failed(self) -> None:
'''Test add() with wrong type.'''
pass
def test_clear(self) -> None:
'''Test clear() method.'''
pass
def test_node_str(self) -> None:
'''Test string representation of node.'''
pass
| 11 | 11 | 10 | 0 | 9 | 2 | 1 | 0.19 | 1 | 8 | 3 | 0 | 10 | 1 | 10 | 82 | 111 | 10 | 90 | 31 | 79 | 17 | 80 | 31 | 69 | 1 | 2 | 1 | 10 |
140,306 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/position_test.py
|
test.position_test.TestPosition
|
class TestPosition(unittest.TestCase):
"""Test class for Position class."""
# pylint: disable=invalid-name
def test_no_position(self) -> None:
"""Test empty Position object."""
self.assertEqual(Position().raw, b"\xF7\xFF")
def test_raw(self) -> None:
"""Test raw assignment."""
self.assertEqual(Position(Parameter(raw=b"\x00\x00")).raw, b"\x00\x00")
self.assertEqual(Position(Parameter(raw=b"\x0A\x05")).raw, b"\x0A\x05")
self.assertEqual(Position(Parameter(raw=b"\xC8\x00")).raw, b"\xC8\x00")
def test_position(self) -> None:
"""Test initialization with position value."""
self.assertEqual(Position(position=0).position, 0)
self.assertEqual(Position(position=10).position, 10)
self.assertEqual(Position(position=1234).position, 1234)
self.assertEqual(Position(position=12345).position, 12345)
self.assertEqual(Position(position=51200).position, 51200)
def test_percent(self) -> None:
"""Test initialization with percent value."""
self.assertEqual(Position(position_percent=0).position_percent, 0)
self.assertEqual(Position(position_percent=5).position_percent, 5)
self.assertEqual(Position(position_percent=50).position_percent, 50)
self.assertEqual(Position(position_percent=95).position_percent, 95)
self.assertEqual(Position(position_percent=100).position_percent, 100)
def test_conversion(self) -> None:
"""Test conversion from one form to other."""
self.assertEqual(Position(Parameter(raw=b"\x0A\x05")).position, 2565)
self.assertEqual(Position(position_percent=50).position, 25600)
self.assertEqual(Position(position=12345).position_percent, 24)
def test_fallback_to_unknown(self) -> None:
"""Test fallback to unknown."""
self.assertEqual(Parameter(raw=b"\xC8\x01"), Parameter(raw=Parameter.from_int(Parameter.UNKNOWN_VALUE)))
self.assertEqual(Parameter(raw=b"\xC9\x00"), Parameter(raw=Parameter.from_int(Parameter.UNKNOWN_VALUE)))
self.assertEqual(Parameter(raw=b"\xD8\x00"), Parameter(raw=Parameter.from_int(Parameter.UNKNOWN_VALUE)))
self.assertEqual(Parameter(raw=b"\xfe\x01"), Parameter(raw=Parameter.from_int(Parameter.UNKNOWN_VALUE)))
def test_exception(self) -> None:
"""Test wrong initialization of Position."""
with self.assertRaises(PyVLXException):
Position(position=2.5) # type: ignore
with self.assertRaises(PyVLXException):
Position(position=-1)
with self.assertRaises(PyVLXException):
Position(position=51201)
with self.assertRaises(PyVLXException):
Position(position_percent=2.5) # type: ignore
with self.assertRaises(PyVLXException):
Position(position_percent=-1)
with self.assertRaises(PyVLXException):
Position(position_percent=101)
with self.assertRaises(PyVLXException):
Parameter(raw=b"\x00\x00\x00")
with self.assertRaises(PyVLXException):
Parameter(raw="\x00\x00") # type: ignore
def test_known(self) -> None:
"""Test 'known' property."""
self.assertTrue(Position(Parameter(raw=b"\x12\x00")).known)
self.assertTrue(Position(Parameter(raw=b"\xC8\x00")).known)
self.assertFalse(Position(Parameter(raw=b"\xF7\xFF")).known)
# Well, not really know. But at least not unknown:
self.assertTrue(Position(Parameter(raw=b"\xD2\x00")).known)
def test_open_closed(self) -> None:
"""Test open and closed property."""
position_open = Position(position_percent=0)
self.assertFalse(position_open.closed)
self.assertTrue(position_open.open)
position_closed = Position(position_percent=100)
self.assertTrue(position_closed.closed)
self.assertFalse(position_closed.open)
position_half = Position(position_percent=50)
self.assertFalse(position_half.closed)
self.assertFalse(position_half.open)
def test_str(self) -> None:
"""Test string representation."""
self.assertEqual(str(Position(Parameter(raw=b"\xF7\xFF"))), "UNKNOWN")
self.assertEqual(str(Position(position_percent=50)), "50 %")
def test_unknown_position_class(self) -> None:
"""Test UnknownPosition class."""
self.assertEqual(UnknownPosition().raw, b"\xF7\xFF")
def test_current_position_class(self) -> None:
"""Test CurrentPosition class."""
self.assertEqual(CurrentPosition().raw, b"\xD2\x00")
def test_on_off(self) -> None:
"""Test SwitchParameter parameter."""
parameter = SwitchParameter()
self.assertFalse(parameter.is_on())
self.assertFalse(parameter.is_off())
parameter.set_on()
self.assertTrue(parameter.is_on())
self.assertFalse(parameter.is_off())
parameter.set_off()
self.assertFalse(parameter.is_on())
self.assertTrue(parameter.is_off())
def test_parsing_on_off(self) -> None:
"""Test parsing OnOFf from raw."""
parameter_on = SwitchParameter(Parameter(raw=b"\x00\x00"))
self.assertTrue(parameter_on.is_on())
self.assertFalse(parameter_on.is_off())
parameter_off = SwitchParameter(Parameter(raw=b"\xC8\x00"))
self.assertFalse(parameter_off.is_on())
self.assertTrue(parameter_off.is_off())
def test_switch_parameter_on_class(self) -> None:
"""Test SwitchParameterOn class."""
self.assertTrue(SwitchParameterOn().is_on())
self.assertFalse(SwitchParameterOn().is_off())
def test_switch_parameter_off_class(self) -> None:
"""Test SwitchParameterOff class."""
self.assertFalse(SwitchParameterOff().is_on())
self.assertTrue(SwitchParameterOff().is_off())
|
class TestPosition(unittest.TestCase):
'''Test class for Position class.'''
def test_no_position(self) -> None:
'''Test empty Position object.'''
pass
def test_raw(self) -> None:
'''Test raw assignment.'''
pass
def test_position(self) -> None:
'''Test initialization with position value.'''
pass
def test_percent(self) -> None:
'''Test initialization with percent value.'''
pass
def test_conversion(self) -> None:
'''Test conversion from one form to other.'''
pass
def test_fallback_to_unknown(self) -> None:
'''Test fallback to unknown.'''
pass
def test_exception(self) -> None:
'''Test wrong initialization of Position.'''
pass
def test_known(self) -> None:
'''Test 'known' property.'''
pass
def test_open_closed(self) -> None:
'''Test open and closed property.'''
pass
def test_str(self) -> None:
'''Test string representation.'''
pass
def test_unknown_position_class(self) -> None:
'''Test UnknownPosition class.'''
pass
def test_current_position_class(self) -> None:
'''Test CurrentPosition class.'''
pass
def test_on_off(self) -> None:
'''Test SwitchParameter parameter.'''
pass
def test_parsing_on_off(self) -> None:
'''Test parsing OnOFf from raw.'''
pass
def test_switch_parameter_on_class(self) -> None:
'''Test SwitchParameterOn class.'''
pass
def test_switch_parameter_off_class(self) -> None:
'''Test SwitchParameterOff class.'''
pass
| 17 | 17 | 7 | 0 | 6 | 1 | 1 | 0.24 | 1 | 2 | 1 | 0 | 16 | 0 | 16 | 88 | 127 | 18 | 90 | 23 | 73 | 22 | 90 | 23 | 73 | 1 | 2 | 1 | 16 |
140,307 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/scene_test.py
|
test.scene_test.TestScene
|
class TestScene(unittest.TestCase):
"""Test class for scene."""
def test_get_name(self) -> None:
"""Test get_name()."""
pyvlx = MagicMock()
scene = Scene(pyvlx, 2, "Scene 1")
self.assertEqual(scene.name, "Scene 1")
self.assertEqual(scene.scene_id, 2)
def test_str(self) -> None:
"""Test string representation of Scene object."""
pyvlx = MagicMock()
scene = Scene(pyvlx, 2, "Scene 1")
self.assertEqual(str(scene), '<Scene name="Scene 1" id="2"/>')
|
class TestScene(unittest.TestCase):
'''Test class for scene.'''
def test_get_name(self) -> None:
'''Test get_name().'''
pass
def test_str(self) -> None:
'''Test string representation of Scene object.'''
pass
| 3 | 3 | 6 | 0 | 5 | 1 | 1 | 0.3 | 1 | 2 | 0 | 0 | 2 | 0 | 2 | 74 | 15 | 2 | 10 | 7 | 7 | 3 | 10 | 7 | 7 | 1 | 2 | 0 | 2 |
140,308 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/scenes_test.py
|
test.scenes_test.TestScenes
|
class TestScenes(unittest.TestCase):
"""Test class for scenes object."""
def test_get_item(self) -> None:
"""Test get_item."""
pyvlx = MagicMock(spec=PyVLX)
scenes = Scenes(pyvlx)
scene1 = Scene(pyvlx, 0, "Scene_1")
scenes.add(scene1)
scene2 = Scene(pyvlx, 1, "Scene_2")
scenes.add(scene2)
scene3 = Scene(pyvlx, 4, "Scene_3")
scenes.add(scene3)
self.assertEqual(scenes["Scene_1"], scene1)
self.assertEqual(scenes["Scene_2"], scene2)
self.assertEqual(scenes["Scene_3"], scene3)
self.assertEqual(scenes[0], scene1)
self.assertEqual(scenes[1], scene2)
self.assertEqual(scenes[4], scene3)
def test_get_item_failed(self) -> None:
"""Test get_item with non existing object."""
pyvlx = MagicMock(spec=PyVLX)
scenes = Scenes(pyvlx)
scene1 = Scene(pyvlx, 0, "Scene_1")
scenes.add(scene1)
with self.assertRaises(KeyError):
scenes["Scene_2"] # pylint: disable=pointless-statement
with self.assertRaises(KeyError):
scenes[1] # pylint: disable=pointless-statement
def test_iter(self) -> None:
"""Test iterator."""
pyvlx = MagicMock(spec=PyVLX)
scenes = Scenes(pyvlx)
scene1 = Scene(pyvlx, 0, "Scene_1")
scenes.add(scene1)
scene2 = Scene(pyvlx, 1, "Scene_2")
scenes.add(scene2)
scene3 = Scene(pyvlx, 2, "Scene_3")
scenes.add(scene3)
self.assertEqual(tuple(scenes.__iter__()), (scene1, scene2, scene3)) # pylint: disable=unnecessary-dunder-call
def test_len(self) -> None:
"""Test len."""
pyvlx = MagicMock(spec=PyVLX)
scenes = Scenes(pyvlx)
self.assertEqual(len(scenes), 0)
scenes.add(Scene(pyvlx, 0, "Scene_1"))
scenes.add(Scene(pyvlx, 1, "Scene_2"))
scenes.add(Scene(pyvlx, 2, "Scene_3"))
scenes.add(Scene(pyvlx, 3, "Scene_4"))
self.assertEqual(len(scenes), 4)
def test_add_same_object(self) -> None:
"""Test adding object with same scene_id."""
pyvlx = MagicMock(spec=PyVLX)
scenes = Scenes(pyvlx)
self.assertEqual(len(scenes), 0)
scenes.add(Scene(pyvlx, 0, "Scene_1"))
scenes.add(Scene(pyvlx, 1, "Scene_2"))
scenes.add(Scene(pyvlx, 2, "Scene_3"))
scenes.add(Scene(pyvlx, 1, "Scene_2_same_id"))
self.assertEqual(len(scenes), 3)
self.assertEqual(scenes[1].name, "Scene_2_same_id")
def test_add_item_failed(self) -> None:
"""Test add() with wrong type."""
pyvlx = MagicMock()
scenes = Scenes(pyvlx)
with self.assertRaises(TypeError):
scenes.add(scenes) # type: ignore
with self.assertRaises(TypeError):
scenes.add("scene") # type: ignore
def test_clear(self) -> None:
"""Test clear() method."""
pyvlx = MagicMock(spec=PyVLX)
scenes = Scenes(pyvlx)
self.assertEqual(len(scenes), 0)
scenes.add(Scene(pyvlx, 0, "Scene_1"))
scenes.add(Scene(pyvlx, 1, "Scene_2"))
scenes.clear()
self.assertEqual(len(scenes), 0)
|
class TestScenes(unittest.TestCase):
'''Test class for scenes object.'''
def test_get_item(self) -> None:
'''Test get_item.'''
pass
def test_get_item_failed(self) -> None:
'''Test get_item with non existing object.'''
pass
def test_iter(self) -> None:
'''Test iterator.'''
pass
def test_len(self) -> None:
'''Test len.'''
pass
def test_add_same_object(self) -> None:
'''Test adding object with same scene_id.'''
pass
def test_add_item_failed(self) -> None:
'''Test add() with wrong type.'''
pass
def test_clear(self) -> None:
'''Test clear() method.'''
pass
| 8 | 8 | 11 | 0 | 10 | 2 | 1 | 0.19 | 1 | 6 | 2 | 0 | 7 | 0 | 7 | 79 | 84 | 7 | 69 | 29 | 61 | 13 | 69 | 29 | 61 | 1 | 2 | 1 | 7 |
140,309 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/session_id_test.py
|
test.session_id_test.SessionIdSlip
|
class SessionIdSlip(unittest.TestCase):
"""Test class for slip helper functions."""
# pylint: disable=invalid-name
def test_session_id(self):
"""Decode encoded, encode decoded and test results."""
set_session_id(0) # Reset session id
self.assertEqual(get_new_session_id(), 1)
self.assertEqual(get_new_session_id(), 2)
self.assertEqual(get_new_session_id(), 3)
set_session_id(65535 - 1)
self.assertEqual(get_new_session_id(), 65535)
self.assertEqual(get_new_session_id(), 1)
|
class SessionIdSlip(unittest.TestCase):
'''Test class for slip helper functions.'''
def test_session_id(self):
'''Decode encoded, encode decoded and test results.'''
pass
| 2 | 2 | 9 | 0 | 8 | 2 | 1 | 0.44 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 73 | 14 | 2 | 9 | 2 | 7 | 4 | 9 | 2 | 7 | 1 | 2 | 0 | 1 |
140,310 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/slip_test.py
|
test.slip_test.TestSlip
|
class TestSlip(unittest.TestCase):
"""Test class for slip helper functions."""
# pylint: disable=invalid-name
def encode_decode(self, decoded: Any, encoded: Any) -> None:
"""Decode encoded, encode decoded and test results."""
self.assertEqual(decode(encoded), decoded)
self.assertEqual(encode(decoded), encoded)
def test_simple(self) -> None:
"""Test decode and encode."""
self.encode_decode(
b"\xc0\xc0\xdb\xdb\xc0\xdb\xc0",
b"\xdb\xdc\xdb\xdc\xdb\xdd\xdb\xdd\xdb\xdc\xdb\xdd\xdb\xdc",
)
def test_empty(self) -> None:
"""Test decode and encode of empty string."""
self.encode_decode(b"", b"")
def test_real_live_example(self) -> None:
"""Test decode of real live example."""
self.encode_decode(
b"\x00\x10\x03\x02\x00\x01\x01\x00\x00\xc8\x00\x02\x1e\x06\x00\x03\x00\xc0",
b"\x00\x10\x03\x02\x00\x01\x01\x00\x00\xc8\x00\x02\x1e\x06\x00\x03\x00\xdb\xdc",
)
def test_slip(self) -> None:
"""Test is_slip function."""
self.assertTrue(is_slip(b"\xc0abc\xc0xx"))
self.assertFalse(is_slip(b"zz\xc0abc\xc0"))
self.assertFalse(is_slip(b"\xc0abc"))
self.assertFalse(is_slip(b"\xc0"))
def test_slip_pack(self) -> None:
"""Test slip_pack function."""
self.assertEqual(
slip_pack(b"\xc0\xc0\xdb\xdb\xc0\xdb\xc0"),
b"\xc0\xdb\xdc\xdb\xdc\xdb\xdd\xdb\xdd\xdb\xdc\xdb\xdd\xdb\xdc\xc0",
)
def test_get_next_slip(self) -> None:
"""Test get_next_slip function."""
self.assertEqual(
get_next_slip(
b"\xc0\xdb\xdc\xdb\xdc\xdb\xdd\xdb\xdd\xdb\xdc\xdb\xdd\xdb\xdc\xc0fnord"
),
(b"\xc0\xc0\xdb\xdb\xc0\xdb\xc0", b"fnord"),
)
def test_get_next_slip_no_complete_slip(self) -> None:
"""Test get_next_slip function with no complete slip frame beeing in queue."""
self.assertEqual(get_next_slip(b"zz\xc0abc\xc0"), (None, b"zz\xc0abc\xc0"))
def test_get_next_slip_empty_queue(self) -> None:
"""Test get_next_slip function with empty queue."""
self.assertEqual(get_next_slip(b""), (None, b""))
|
class TestSlip(unittest.TestCase):
'''Test class for slip helper functions.'''
def encode_decode(self, decoded: Any, encoded: Any) -> None:
'''Decode encoded, encode decoded and test results.'''
pass
def test_simple(self) -> None:
'''Test decode and encode.'''
pass
def test_empty(self) -> None:
'''Test decode and encode of empty string.'''
pass
def test_real_live_example(self) -> None:
'''Test decode of real live example.'''
pass
def test_slip(self) -> None:
'''Test is_slip function.'''
pass
def test_slip_pack(self) -> None:
'''Test slip_pack function.'''
pass
def test_get_next_slip(self) -> None:
'''Test get_next_slip function.'''
pass
def test_get_next_slip_no_complete_slip(self) -> None:
'''Test get_next_slip function with no complete slip frame beeing in queue.'''
pass
def test_get_next_slip_empty_queue(self) -> None:
'''Test get_next_slip function with empty queue.'''
pass
| 10 | 10 | 5 | 0 | 4 | 1 | 1 | 0.3 | 1 | 1 | 0 | 0 | 9 | 0 | 9 | 81 | 58 | 10 | 37 | 10 | 27 | 11 | 23 | 10 | 13 | 1 | 2 | 0 | 9 |
140,311 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/string_test.py
|
test.string_test.TestString
|
class TestString(unittest.TestCase):
"""Test class for String encoding/decoding."""
# pylint: disable=too-many-public-methods,invalid-name
def test_encoding(self) -> None:
"""Test simple encoding."""
self.assertEqual(string_to_bytes("fnord", 10), b"fnord" + bytes(5))
def test_encoding_without_padding(self) -> None:
"""Test encoding with exact match of size."""
self.assertEqual(string_to_bytes("fnord", 5), b"fnord")
def test_encoding_failure(self) -> None:
"""Test error while encoding."""
with self.assertRaises(PyVLXException):
string_to_bytes("fnord", 4)
def test_decoding(self) -> None:
"""Test decoding of string."""
self.assertEqual(bytes_to_string(b"fnord" + bytes(5)), "fnord")
def test_decoding_without_padding(self) -> None:
"""Test decoding of string without padding."""
self.assertEqual(bytes_to_string(b"fnord"), "fnord")
def test_encode_utf8(self) -> None:
"""Test encoding a string with special characters."""
self.assertEqual(
string_to_bytes("Fenster Büro", 16), b"Fenster B\xc3\xbcro\x00\x00\x00"
)
def test_decode_utf8(self) -> None:
"""Test decoding a string with special characters."""
self.assertEqual(
bytes_to_string(b"Fenster B\xc3\xbcro\x00\x00\x00"), "Fenster Büro"
)
|
class TestString(unittest.TestCase):
'''Test class for String encoding/decoding.'''
def test_encoding(self) -> None:
'''Test simple encoding.'''
pass
def test_encoding_without_padding(self) -> None:
'''Test encoding with exact match of size.'''
pass
def test_encoding_failure(self) -> None:
'''Test error while encoding.'''
pass
def test_decoding(self) -> None:
'''Test decoding of string.'''
pass
def test_decoding_without_padding(self) -> None:
'''Test decoding of string without padding.'''
pass
def test_encode_utf8(self) -> None:
'''Test encoding a string with special characters.'''
pass
def test_decode_utf8(self) -> None:
'''Test decoding a string with special characters.'''
pass
| 8 | 8 | 4 | 0 | 3 | 1 | 1 | 0.45 | 1 | 2 | 1 | 0 | 7 | 0 | 7 | 79 | 37 | 8 | 20 | 8 | 12 | 9 | 16 | 8 | 8 | 1 | 2 | 1 | 7 |
140,312 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/parameter_test.py
|
test.parameter_test.TestParameterPosition
|
class TestParameterPosition(unittest.TestCase):
"""Test class for Position class."""
def test_from_parameter(self) -> None:
"""Test from parameter from another parameter."""
param1 = Parameter(raw=b'\xC8\x00')
param2 = Parameter(raw=b'\x00\x00')
wrong_object = b'\x00\x00'
with self.assertRaises(PyVLXException):
Parameter.from_parameter(self=param1, parameter=wrong_object) # type: ignore
Parameter.from_parameter(self=param1, parameter=param2)
self.assertEqual(param1.raw, param2.raw)
def test_from_int(self) -> None:
"""Test from int output from parameter int input."""
wrong_object = b'\x00\x00'
with self.assertRaises(PyVLXException):
Parameter.from_int(wrong_object) # type: ignore
not_valid_int = 100.3
with self.assertRaises(PyVLXException):
Parameter.from_int(not_valid_int) # type: ignore
int_out_of_range = Parameter.MAX + 1
with self.assertRaises(PyVLXException):
Parameter.from_int(int_out_of_range) # type: ignore
self.assertEqual(Parameter.from_int(51200), b'\xc8\x00')
def test_to_int(self) -> None:
"""Test from int output from parameter int input."""
raw = b'\xc8\x00'
self.assertEqual(Parameter.to_int(raw=raw), 51200)
def test_is_valid_int(self) -> None:
"""Test if int is valid, between 0 and 51200."""
valid_int1 = 0
valid_int2 = 51200
out_of_range_int = 51201
self.assertTrue(Parameter.is_valid_int(valid_int1))
self.assertTrue(Parameter.is_valid_int(valid_int2))
self.assertFalse(Parameter.is_valid_int(out_of_range_int))
def test_from_raw(self) -> None:
"""Test raw output from byte input."""
with self.assertRaises(PyVLXException):
Parameter.from_raw(raw=0xC800) # type: ignore
with self.assertRaises(PyVLXException):
Parameter.from_raw(raw=b'\x00')
self.assertEqual(Parameter.from_raw(raw=b'\xd2\x01'), b'\xf7\xff')
self.assertEqual(Parameter.from_raw(raw=b'\xd2\x01'), b'\xf7\xff')
self.assertEqual(Parameter.from_raw(raw=b'\xd1\x01'), b'\xf7\xff')
self.assertEqual(Parameter.from_raw(raw=b'\xd4\x01'), b'\xf7\xff')
self.assertEqual(Parameter.from_raw(raw=b'\xd8\x01'), b'\xf7\xff')
self.assertNotEqual(Parameter.from_raw(raw=b'\xd2\x00'), b'\xf7\xff')
self.assertNotEqual(Parameter.from_raw(raw=b'\xd2\x00'), b'\xf7\xff')
self.assertNotEqual(Parameter.from_raw(raw=b'\xd1\x00'), b'\xf7\xff')
self.assertNotEqual(Parameter.from_raw(raw=b'\xd4\x00'), b'\xf7\xff')
self.assertEqual(Parameter.from_raw(raw=b'\x00\x00'), b'\x00\x00')
self.assertEqual(Parameter.from_raw(raw=b'\xc8\x00'), b'\xc8\x00')
self.assertEqual(Parameter.from_raw(raw=b'\xc8\x01'), b'\xf7\xff')
def test_from_to_percent(self) -> None:
"""Test position percent output from position percent input."""
self.assertEqual(Position.to_percent(Position.from_percent(0)), 0)
self.assertEqual(Position.to_percent(Position.from_percent(1)), 1)
self.assertEqual(Position.to_percent(Position.from_percent(25)), 25)
self.assertEqual(Position.to_percent(Position.from_percent(50)), 50)
self.assertEqual(Position.to_percent(Position.from_percent(75)), 75)
self.assertEqual(Position.to_percent(Position.from_percent(99)), 99)
self.assertEqual(Position.to_percent(Position.from_percent(100)), 100)
def test_to_percent(self) -> None:
"""Test position percent output from position int input."""
self.assertEqual(Position.to_percent(Parameter.from_int(0)), 0)
self.assertEqual(Position.to_percent(Parameter.from_int(1)), 0)
self.assertEqual(Position.to_percent(Parameter.from_int(3)), 0)
self.assertEqual(Position.to_percent(Parameter.from_int(256)), 1)
self.assertEqual(Position.to_percent(Parameter.from_int(512)), 1)
self.assertEqual(Position.to_percent(Parameter.from_int(5120)), 10)
self.assertEqual(Position.to_percent(Parameter.from_int(12800)), 25)
self.assertEqual(Position.to_percent(Parameter.from_int(25600)), 50)
self.assertEqual(Position.to_percent(Parameter.from_int(38400)), 75)
self.assertEqual(Position.to_percent(Parameter.from_int(50688)), 99)
self.assertEqual(Position.to_percent(Parameter.from_int(51050)), 100)
self.assertEqual(Position.to_percent(Parameter.from_int(51200)), 100)
def test_equal(self) -> None:
"""Test from parameter from another parameter."""
param1 = Parameter(raw=b'\xC8\x00')
param2 = Parameter(raw=b'\x00\x00')
param3 = Parameter(raw=b'\xC8\x00')
wrong_object = b'\x00\x00'
self.assertEqual(param1.__eq__(wrong_object), NotImplemented) # pylint: disable=C2801
self.assertFalse(param1 == param2)
self.assertTrue(param1 == param3)
|
class TestParameterPosition(unittest.TestCase):
'''Test class for Position class.'''
def test_from_parameter(self) -> None:
'''Test from parameter from another parameter.'''
pass
def test_from_int(self) -> None:
'''Test from int output from parameter int input.'''
pass
def test_to_int(self) -> None:
'''Test from int output from parameter int input.'''
pass
def test_is_valid_int(self) -> None:
'''Test if int is valid, between 0 and 51200.'''
pass
def test_from_raw(self) -> None:
'''Test raw output from byte input.'''
pass
def test_from_to_percent(self) -> None:
'''Test position percent output from position percent input.'''
pass
def test_to_percent(self) -> None:
'''Test position percent output from position int input.'''
pass
def test_equal(self) -> None:
'''Test from parameter from another parameter.'''
pass
| 9 | 9 | 10 | 0 | 9 | 2 | 1 | 0.2 | 1 | 1 | 1 | 0 | 8 | 0 | 8 | 80 | 93 | 8 | 76 | 23 | 67 | 15 | 76 | 23 | 67 | 1 | 2 | 1 | 8 |
140,313 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_house_status_monitor_enable_cfm_test.py
|
test.frame_house_status_monitor_enable_cfm_test.TestFrameHouseStatusMonitorEnableConfirmation
|
class TestFrameHouseStatusMonitorEnableConfirmation(unittest.TestCase):
"""Test class FrameHouseStatusMonitorEnableConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x03\x02A@"
def test_bytes(self):
"""Test FrameHouseStatusMonitorEnableConfirmation."""
frame = FrameHouseStatusMonitorEnableConfirmation()
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameHouseStatusMonitorEnableConfirmation from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameHouseStatusMonitorEnableConfirmation))
def test_str(self):
"""Test string representation of FrameHouseStatusMonitorEnableConfirmation."""
frame = FrameHouseStatusMonitorEnableConfirmation()
self.assertEqual(str(frame), "<FrameHouseStatusMonitorEnableConfirmation/>")
|
class TestFrameHouseStatusMonitorEnableConfirmation(unittest.TestCase):
'''Test class FrameHouseStatusMonitorEnableConfirmation.'''
def test_bytes(self):
'''Test FrameHouseStatusMonitorEnableConfirmation.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameHouseStatusMonitorEnableConfirmation from raw.'''
pass
def test_str(self):
'''Test string representation of FrameHouseStatusMonitorEnableConfirmation.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.45 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 21 | 5 | 11 | 8 | 7 | 5 | 11 | 8 | 7 | 1 | 2 | 0 | 3 |
140,314 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_set_utc_cfm_test.py
|
test.frame_set_utc_cfm_test.TestFrameSetUTCConfirmation
|
class TestFrameSetUTCConfirmation(unittest.TestCase):
"""Test class FrameSetUTCConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b'\x00\x03 \x01"'
def test_bytes(self):
"""Test FrameSetUTCConfirmation."""
frame = FrameSetUTCConfirmation()
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameSetUTCConfirmation from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameSetUTCConfirmation))
def test_str(self):
"""Test string representation of FrameSetUTCConfirmation."""
frame = FrameSetUTCConfirmation()
self.assertEqual(str(frame), "<FrameSetUTCConfirmation/>")
|
class TestFrameSetUTCConfirmation(unittest.TestCase):
'''Test class FrameSetUTCConfirmation.'''
def test_bytes(self):
'''Test FrameSetUTCConfirmation.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameSetUTCConfirmation from raw.'''
pass
def test_str(self):
'''Test string representation of FrameSetUTCConfirmation.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.45 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 21 | 5 | 11 | 8 | 7 | 5 | 11 | 8 | 7 | 1 | 2 | 0 | 3 |
140,315 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_set_node_name_cfm_test.py
|
test.frame_set_node_name_cfm_test.TestFrameSetNodeNameConfirmation
|
class TestFrameSetNodeNameConfirmation(unittest.TestCase):
"""Test class for FrameSetNodeNameConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x05\x02\t\x00\x17\x19"
EXAMPLE_FRAME_ERR = b"\x00\x05\x02\t\x01\x17\x18"
def test_bytes(self):
"""Test FrameSetNodeNameConfirmation."""
frame = FrameSetNodeNameConfirmation(node_id=23)
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_bytes_error(self):
"""Test failed FrameSetNodeNameConfirmation."""
frame = FrameSetNodeNameConfirmation(
node_id=23, status=SetNodeNameConfirmationStatus.ERROR_REQUEST_REJECTED
)
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME_ERR)
def test_frame_from_raw(self):
"""Test parse FrameSetNodeNameConfirmation from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameSetNodeNameConfirmation))
self.assertEqual(frame.status, SetNodeNameConfirmationStatus.OK)
self.assertEqual(frame.node_id, 23)
def test_str(self):
"""Test string representation of FrameSetNodeNameConfirmation."""
frame = FrameSetNodeNameConfirmation(node_id=23)
self.assertEqual(
str(frame),
'<FrameSetNodeNameConfirmation node_id="23" status="SetNodeNameConfirmationStatus.OK"/>',
)
|
class TestFrameSetNodeNameConfirmation(unittest.TestCase):
'''Test class for FrameSetNodeNameConfirmation.'''
def test_bytes(self):
'''Test FrameSetNodeNameConfirmation.'''
pass
def test_bytes_error(self):
'''Test failed FrameSetNodeNameConfirmation.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameSetNodeNameConfirmation from raw.'''
pass
def test_str(self):
'''Test string representation of FrameSetNodeNameConfirmation.'''
pass
| 5 | 5 | 6 | 0 | 5 | 1 | 1 | 0.27 | 1 | 4 | 2 | 0 | 4 | 0 | 4 | 76 | 34 | 6 | 22 | 11 | 17 | 6 | 17 | 11 | 12 | 1 | 2 | 0 | 4 |
140,316 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_leave_learn_state_cfm_test.py
|
test.frame_leave_learn_state_cfm_test.TestFrameLeaveLearnStateConfirmation
|
class TestFrameLeaveLearnStateConfirmation(unittest.TestCase):
"""Test class FrameLeaveLearnStateConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x04\x00\x0f\x00\x0b"
def test_bytes(self) -> None:
"""Test FrameLeaveLearnStateConfirmation."""
frame = FrameLeaveLearnStateConfirmation()
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self) -> None:
"""Test parse FrameLeaveLearnStateConfirmation from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameLeaveLearnStateConfirmation))
def test_str(self) -> None:
"""Test string representation of FrameLeaveLearnStateConfirmation."""
frame = FrameLeaveLearnStateConfirmation()
self.assertEqual(str(frame), '<FrameLeaveLearnStateConfirmation status="LeaveLearnStateConfirmationStatus.FAILED"/>')
|
class TestFrameLeaveLearnStateConfirmation(unittest.TestCase):
'''Test class FrameLeaveLearnStateConfirmation.'''
def test_bytes(self) -> None:
'''Test FrameLeaveLearnStateConfirmation.'''
pass
def test_frame_from_raw(self) -> None:
'''Test parse FrameLeaveLearnStateConfirmation from raw.'''
pass
def test_str(self) -> None:
'''Test string representation of FrameLeaveLearnStateConfirmation.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.45 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 21 | 5 | 11 | 8 | 7 | 5 | 11 | 8 | 7 | 1 | 2 | 0 | 3 |
140,317 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_leave_learn_state_req_test.py
|
test.frame_leave_learn_state_req_test.TestFrameLeaveLearnStateRequest
|
class TestFrameLeaveLearnStateRequest(unittest.TestCase):
"""Test class FrameLeaveLearnStateRequest."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x03\x00\x0e\r"
def test_bytes(self):
"""Test FrameLeaveLearnStateRequest with NO_TYPE."""
frame = FrameLeaveLearnStateRequest()
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameLeaveLearnStateRequest from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameLeaveLearnStateRequest))
def test_str(self):
"""Test string representation of FrameGetStateRequest."""
frame = FrameLeaveLearnStateRequest()
self.assertEqual(str(frame), "<FrameLeaveLearnStateRequest/>")
|
class TestFrameLeaveLearnStateRequest(unittest.TestCase):
'''Test class FrameLeaveLearnStateRequest.'''
def test_bytes(self):
'''Test FrameLeaveLearnStateRequest with NO_TYPE.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameLeaveLearnStateRequest from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGetStateRequest.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.45 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 21 | 5 | 11 | 8 | 7 | 5 | 11 | 8 | 7 | 1 | 2 | 0 | 3 |
140,318 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_node_information_changed_ntf_test.py
|
test.frame_node_information_changed_ntf_test.TestFrameNodeInformationChangedNotification
|
class TestFrameNodeInformationChangedNotification(unittest.TestCase):
"""Test class for FrameNodeInformationChangedNotification."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = (
b"\x00H\x02\x0c\x17Fnord23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04"
b"\xd2\x02\x01\xd4"
)
def test_bytes(self):
"""Test FrameNodeInformationChangedNotification."""
frame = FrameNodeInformationChangedNotification()
frame.node_id = 23
frame.order = 1234
frame.placement = 2
frame.name = "Fnord23"
frame.node_variation = NodeVariation.TOPHUNG
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameNodeInformationChangedNotification from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameNodeInformationChangedNotification))
self.assertEqual(frame.node_id, 23)
self.assertEqual(frame.order, 1234)
self.assertEqual(frame.placement, 2)
self.assertEqual(frame.node_variation, NodeVariation.TOPHUNG)
self.assertEqual(frame.name, "Fnord23")
def test_str(self):
"""Test string representation of FrameNodeInformationChangedNotification."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertEqual(
str(frame),
'<FrameNodeInformationChangedNotification node_id="23" name="Fnord23" '
'order="1234" placement="2" node_variation="NodeVariation.TOPHUNG"/>',
)
|
class TestFrameNodeInformationChangedNotification(unittest.TestCase):
'''Test class for FrameNodeInformationChangedNotification.'''
def test_bytes(self):
'''Test FrameNodeInformationChangedNotification.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameNodeInformationChangedNotification from raw.'''
pass
def test_str(self):
'''Test string representation of FrameNodeInformationChangedNotification.'''
pass
| 4 | 4 | 9 | 0 | 8 | 1 | 1 | 0.16 | 1 | 4 | 2 | 0 | 3 | 0 | 3 | 75 | 41 | 5 | 31 | 8 | 27 | 5 | 21 | 8 | 17 | 1 | 2 | 0 | 3 |
140,319 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_node_information_mischroe_test.py
|
test.frame_node_information_mischroe_test.TestFrameGetNodeInformationMiSchroe
|
class TestFrameGetNodeInformationMiSchroe(unittest.TestCase):
"""Test class data sample obtained from MiSchroe."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME1 = (
"c0:00:7f:02:04:04:00:04:04:46:65:6e:73:74:65:72:"
"20:42:c3:bc:72:6f:00:00:00:00:00:00:00:00:00:00:"
"00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:"
"00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:"
"00:00:00:00:00:00:00:00:00:00:01:01:d5:07:00:01:"
"1e:53:36:27:26:10:2f:00:81:05:c8:00:c8:00:00:00:"
"f7:ff:f7:ff:f7:ff:00:00:4f:0d:f9:a7:02:d8:02:64:"
"00:d8:03:ba:00:00:00:00:00:00:00:00:00:00:00:00:"
"00:fb:c0"
)
EXAMPLE_FRAME2 = (
"c0:00:7f:02:10:04:00:04:04:46:65:6e:73:74:65:72:"
"20:42:c3:bc:72:6f:00:00:00:00:00:00:00:00:00:00:"
"00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:"
"00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:"
"00:00:00:00:00:00:00:00:00:00:01:01:d5:07:00:01:"
"1e:53:36:27:26:10:2f:00:81:05:c8:00:c8:00:00:00:"
"f7:ff:f7:ff:f7:ff:00:00:4f:0d:f9:a8:02:d8:02:64:"
"00:d8:03:ba:00:00:00:00:00:00:00:00:00:00:00:00:"
"00:e0:c0"
)
def test_frame1_from_raw(self) -> None:
"""Test parse EXAMPLE_FRAME1 from raw."""
slip = bytearray.fromhex(self.EXAMPLE_FRAME1.replace(":", ""))
raw, _ = get_next_slip(slip)
frame = frame_from_raw(bytes(raw))
self.assertTrue(isinstance(frame, FrameGetAllNodesInformationNotification))
self.assertEqual(frame.node_id, 4)
self.assertEqual(frame.order, 4)
self.assertEqual(frame.placement, 4)
self.assertEqual(frame.name, "Fenster Büro")
self.assertEqual(frame.velocity, Velocity.DEFAULT)
self.assertEqual(
frame.node_type, NodeTypeWithSubtype.WINDOW_OPENER_WITH_RAIN_SENSOR
)
self.assertEqual(frame.product_group, 213)
self.assertEqual(frame.product_type, 7)
self.assertEqual(frame.node_variation, NodeVariation.NOT_SET)
self.assertEqual(frame.power_mode, 1)
self.assertEqual(frame.build_number, 30)
self.assertEqual(frame.serial_number, "53:36:27:26:10:2f:00:81")
self.assertEqual(frame.state, OperatingState.DONE)
self.assertEqual(str(Position(frame.current_position)), "100 %")
self.assertEqual(str(Position(frame.target)), "100 %")
self.assertEqual(str(Position(frame.current_position_fp1)), "0 %")
self.assertEqual(str(frame.current_position_fp2), "UNKNOWN")
self.assertEqual(str(frame.current_position_fp3), "UNKNOWN")
self.assertEqual(str(frame.current_position_fp4), "UNKNOWN")
self.assertEqual(frame.remaining_time, 0)
self.assertEqual(frame.timestamp, 1326315943)
test_ts = datetime.fromtimestamp(1326315943).strftime("%Y-%m-%d %H:%M:%S")
self.assertEqual(frame.timestamp_formatted, test_ts)
self.assertEqual(str(frame.alias_array), "d802=6400, d803=ba00")
# Crosscheck, Serializing:
self.assertEqual(bytes(frame), raw)
def test_frame2_from_raw(self) -> None:
"""Test parse EXAMPLE_FRAME2 from raw."""
slip = bytearray.fromhex(self.EXAMPLE_FRAME2.replace(":", ""))
raw, _ = get_next_slip(slip)
frame = frame_from_raw(bytes(raw))
self.assertTrue(isinstance(frame, FrameGetNodeInformationNotification))
self.assertEqual(frame.node_id, 4)
self.assertEqual(frame.order, 4)
self.assertEqual(frame.placement, 4)
self.assertEqual(frame.name, "Fenster Büro")
self.assertEqual(frame.velocity, Velocity.DEFAULT)
self.assertEqual(
frame.node_type, NodeTypeWithSubtype.WINDOW_OPENER_WITH_RAIN_SENSOR
)
self.assertEqual(frame.product_group, 213)
self.assertEqual(frame.product_type, 7)
self.assertEqual(frame.node_variation, NodeVariation.NOT_SET)
self.assertEqual(frame.power_mode, 1)
self.assertEqual(frame.build_number, 30)
self.assertEqual(frame.serial_number, "53:36:27:26:10:2f:00:81")
self.assertEqual(frame.state, OperatingState.DONE)
self.assertEqual(str(Position(frame.current_position)), "100 %")
self.assertEqual(str(Position(frame.target)), "100 %")
self.assertEqual(str(Position(frame.current_position_fp1)), "0 %")
self.assertEqual(str(Position(frame.current_position_fp2)), "UNKNOWN")
self.assertEqual(str(Position(frame.current_position_fp3)), "UNKNOWN")
self.assertEqual(str(Position(frame.current_position_fp4)), "UNKNOWN")
self.assertEqual(frame.remaining_time, 0)
self.assertEqual(frame.timestamp, 1326315944)
test_ts = datetime.fromtimestamp(1326315944).strftime("%Y-%m-%d %H:%M:%S")
self.assertEqual(frame.timestamp_formatted, test_ts)
self.assertEqual(str(frame.alias_array), "d802=6400, d803=ba00")
# Crosscheck, Serializing:
self.assertEqual(bytes(frame), raw)
|
class TestFrameGetNodeInformationMiSchroe(unittest.TestCase):
'''Test class data sample obtained from MiSchroe.'''
def test_frame1_from_raw(self) -> None:
'''Test parse EXAMPLE_FRAME1 from raw.'''
pass
def test_frame2_from_raw(self) -> None:
'''Test parse EXAMPLE_FRAME2 from raw.'''
pass
| 3 | 3 | 34 | 0 | 32 | 2 | 1 | 0.07 | 1 | 11 | 7 | 0 | 2 | 0 | 2 | 74 | 98 | 5 | 87 | 13 | 84 | 6 | 63 | 13 | 60 | 1 | 2 | 0 | 2 |
140,320 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_node_state_position_changed_ntf_test.py
|
test.frame_node_state_position_changed_ntf_test.TestFrameNodeStatePositionChangedNotification
|
class TestFrameNodeStatePositionChangedNotification(unittest.TestCase):
"""Test class for FrameNodeStatePositionChangedNotification."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = (
b"\x00\x17\x02\x11\x05\x05\xc8\x00\xc8\x00\xf7\xff\xf7\xff"
b"\xf7\xff\xf7\xff\x00\x00L\xcf\x00\x00\x87"
)
def test_bytes(self) -> None:
"""Test FrameNodeStatePositionChangedNotification."""
frame = FrameNodeStatePositionChangedNotification()
frame.node_id = 5
frame.state = OperatingState.DONE
frame.current_position = Position(position=51200)
frame.target = Position(position=51200)
frame.current_position_fp1 = Position()
frame.current_position_fp2 = Position()
frame.current_position_fp3 = Position()
frame.current_position_fp4 = Position()
frame.remaining_time = 0
frame.timestamp = 1288634368
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self) -> None:
"""Test parse FrameNodeStatePositionChangedNotification from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameNodeStatePositionChangedNotification))
self.assertEqual(frame.node_id, 5)
self.assertEqual(frame.state, OperatingState.DONE)
self.assertEqual(Position(frame.current_position).position, 51200)
self.assertEqual(Position(frame.target).position, 51200)
self.assertEqual(Position(frame.current_position_fp1).position, 63487)
self.assertEqual(Position(frame.current_position_fp2).position, 63487)
self.assertEqual(Position(frame.current_position_fp3).position, 63487)
self.assertEqual(Position(frame.current_position_fp4).position, 63487)
self.assertEqual(frame.remaining_time, 0)
self.assertEqual(frame.timestamp, 1288634368)
def test_str(self) -> None:
"""Test string representation of FrameNodeStatePositionChangedNotification."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
test_ts = datetime.fromtimestamp(1288634368).strftime("%Y-%m-%d %H:%M:%S")
self.assertEqual(
str(frame),
'<FrameNodeStatePositionChangedNotification node_id="5" state="DONE" '
'current_position="100 %" target="100 %" current_position_fp1="UNKNOWN" '
'current_position_fp2="UNKNOWN" current_position_fp3="UNKNOWN" '
'current_position_fp4="UNKNOWN" remaining_time="0" time="{}"/>'.format(
test_ts
),
)
|
class TestFrameNodeStatePositionChangedNotification(unittest.TestCase):
'''Test class for FrameNodeStatePositionChangedNotification.'''
def test_bytes(self) -> None:
'''Test FrameNodeStatePositionChangedNotification.'''
pass
def test_frame_from_raw(self) -> None:
'''Test parse FrameNodeStatePositionChangedNotification from raw.'''
pass
def test_str(self) -> None:
'''Test string representation of FrameNodeStatePositionChangedNotification.'''
pass
| 4 | 4 | 14 | 0 | 13 | 1 | 1 | 0.12 | 1 | 5 | 2 | 0 | 3 | 0 | 3 | 75 | 53 | 5 | 43 | 9 | 39 | 5 | 32 | 9 | 28 | 1 | 2 | 0 | 3 |
140,321 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_command_send_cfm_test.py
|
test.frame_command_send_cfm_test.TestFrameCommandSendConfirmation
|
class TestFrameCommandSendConfirmation(unittest.TestCase):
"""Test class FrameCommandSendConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FrameCommandSendConfirmation."""
frame = FrameCommandSendConfirmation(
session_id=1000, status=CommandSendConfirmationStatus.ACCEPTED
)
self.assertEqual(bytes(frame), b"\x00\x06\x03\x01\x03\xe8\x01\xee")
def test_bytes_error(self):
"""Test failed FrameCommandSendConfirmation."""
frame = FrameCommandSendConfirmation(
session_id=1000, status=CommandSendConfirmationStatus.REJECTED
)
self.assertEqual(bytes(frame), b"\x00\x06\x03\x01\x03\xe8\x00\xef")
def test_frame_from_raw(self):
"""Test parse FrameCommandSendConfirmation from raw."""
frame = frame_from_raw(b"\x00\x06\x03\x01\x03\xe8\x00\xef")
self.assertTrue(isinstance(frame, FrameCommandSendConfirmation))
self.assertEqual(frame.status, CommandSendConfirmationStatus.REJECTED)
self.assertEqual(frame.session_id, 1000)
def test_str(self):
"""Test string representation of FrameCommandSendConfirmation."""
frame = FrameCommandSendConfirmation(
session_id=1000, status=CommandSendConfirmationStatus.ACCEPTED
)
self.assertEqual(
str(frame),
'<FrameCommandSendConfirmation session_id="1000" status="CommandSendConfirmationStatus.ACCEPTED"/>',
)
|
class TestFrameCommandSendConfirmation(unittest.TestCase):
'''Test class FrameCommandSendConfirmation.'''
def test_bytes(self):
'''Test FrameCommandSendConfirmation.'''
pass
def test_bytes_error(self):
'''Test failed FrameCommandSendConfirmation.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameCommandSendConfirmation from raw.'''
pass
def test_str(self):
'''Test string representation of FrameCommandSendConfirmation.'''
pass
| 5 | 5 | 7 | 0 | 6 | 1 | 1 | 0.25 | 1 | 4 | 2 | 0 | 4 | 0 | 4 | 76 | 35 | 5 | 24 | 9 | 19 | 6 | 15 | 9 | 10 | 1 | 2 | 0 | 4 |
140,322 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_set_node_name_req_test.py
|
test.frame_set_node_name_req_test.TestFrameSetNodeNameRequest
|
class TestFrameSetNodeNameRequest(unittest.TestCase):
"""Test class FrameSetNodeNameRequest."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = (
b"\x00D\x02\x08\x04Fnord\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x1b"
)
def test_bytes(self):
"""Test FrameSetNodeNameRequest with NO_TYPE."""
frame = FrameSetNodeNameRequest(node_id=4, name="Fnord")
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameSetNodeNameRequest from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameSetNodeNameRequest))
self.assertEqual(frame.node_id, 4)
self.assertEqual(frame.name, "Fnord")
def test_str(self):
"""Test string representation of FrameSetNodeNameRequest."""
frame = FrameSetNodeNameRequest(node_id=4, name="Fnord")
self.assertEqual(
str(frame), '<FrameSetNodeNameRequest node_id="4" name="Fnord"/>'
)
|
class TestFrameSetNodeNameRequest(unittest.TestCase):
'''Test class FrameSetNodeNameRequest.'''
def test_bytes(self):
'''Test FrameSetNodeNameRequest with NO_TYPE.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameSetNodeNameRequest from raw.'''
pass
def test_str(self):
'''Test string representation of FrameSetNodeNameRequest.'''
pass
| 4 | 4 | 5 | 0 | 4 | 1 | 1 | 0.24 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 31 | 5 | 21 | 8 | 17 | 5 | 13 | 8 | 9 | 1 | 2 | 0 | 3 |
140,323 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_password_change_cfm_test.py
|
test.frame_password_change_cfm_test.TestFramePasswordChangeConfirmation
|
class TestFramePasswordChangeConfirmation(unittest.TestCase):
"""Test class for FramePasswordChangeConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FramePasswordChangeConfirmation."""
frame = FramePasswordChangeConfirmation()
self.assertEqual(bytes(frame), b"\x00\x040\x03\x007")
def test_bytes_error(self):
"""Test failed FramePasswordChangeConfirmation."""
frame = FramePasswordChangeConfirmation(
status=PasswordChangeConfirmationStatus.FAILED
)
self.assertEqual(bytes(frame), b"\x00\x040\x03\x016")
def test_frame_from_raw(self):
"""Test parse FramePasswordChangeConfirmation from raw."""
frame = frame_from_raw(b"\x00\x040\x03\x016")
self.assertTrue(isinstance(frame, FramePasswordChangeConfirmation))
self.assertEqual(frame.status, PasswordChangeConfirmationStatus.FAILED)
def test_str(self):
"""Test string representation of FramePasswordChangeConfirmation."""
frame = FramePasswordChangeConfirmation()
self.assertEqual(
str(frame),
'<FramePasswordChangeConfirmation status="PasswordChangeConfirmationStatus.SUCCESSFUL"/>',
)
|
class TestFramePasswordChangeConfirmation(unittest.TestCase):
'''Test class for FramePasswordChangeConfirmation.'''
def test_bytes(self):
'''Test FramePasswordChangeConfirmation.'''
pass
def test_bytes_error(self):
'''Test failed FramePasswordChangeConfirmation.'''
pass
def test_frame_from_raw(self):
'''Test parse FramePasswordChangeConfirmation from raw.'''
pass
def test_str(self):
'''Test string representation of FramePasswordChangeConfirmation.'''
pass
| 5 | 5 | 6 | 0 | 5 | 1 | 1 | 0.32 | 1 | 4 | 2 | 0 | 4 | 0 | 4 | 76 | 30 | 5 | 19 | 9 | 14 | 6 | 14 | 9 | 9 | 1 | 2 | 0 | 4 |
140,324 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_password_change_req_test.py
|
test.frame_password_change_req_test.TestFramePasswordChange
|
class TestFramePasswordChange(unittest.TestCase):
"""Test class for FramePasswordChangeRequest."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FramePasswordChangeRequest."""
frame = FramePasswordChangeRequest(currentpassword="fnord", newpassword="bfeld")
self.assertEqual(
bytes(frame),
b"\x00C0\x02fnord\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00bfeld\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00i",
)
def test_bytes_long_newpw(self):
"""Test FramePasswordChangeRequest with long new password."""
frame = FramePasswordChangeRequest(currentpassword="fnord", newpassword="x" * 32)
self.assertEqual(
bytes(frame), b"\x00C0\x02fnord\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\x00"
)
def test_bytes_long_oldpw(self):
"""Test FramePasswordChangeRequest with long old password."""
frame = FramePasswordChangeRequest(currentpassword="x" * 32, newpassword="bfeld")
self.assertEqual(
bytes(frame), b"\x00C0\x02xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxbfeld\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18"
)
def test_bytes_long_bothpw(self):
"""Test FramePasswordChangeRequest with long passwords."""
frame = FramePasswordChangeRequest(currentpassword="x" * 32, newpassword="y" * 32)
self.assertEqual(
bytes(frame), b"\x00C0\x02xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyq"
)
def test_frame_from_raw(self):
"""Test parsing FramePasswordChangeRequest from raw bytes."""
frame = frame_from_raw(
b"\x00C0\x02fnord\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00bfeld\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00i"
)
self.assertTrue(isinstance(frame, FramePasswordChangeRequest))
self.assertEqual(frame.newpassword, "bfeld")
self.assertEqual(frame.currentpassword, "fnord")
def test_errors(self):
"""Test FramePasswordChangeRequest with wrong password."""
with self.assertRaises(PyVLXException):
bytes(FramePasswordChangeRequest())
with self.assertRaises(PyVLXException):
bytes(FramePasswordChangeRequest(currentpassword="fnord"))
with self.assertRaises(PyVLXException):
bytes(FramePasswordChangeRequest(currentpassword="fnord", newpassword="x" * 33))
with self.assertRaises(PyVLXException):
bytes(FramePasswordChangeRequest(newpassword="fnord", currentpassword="x" * 33))
with self.assertRaises(PyVLXException):
bytes(FramePasswordChangeRequest(newpassword="x" * 33, currentpassword="x" * 33))
def test_str(self):
"""Test string representation of FramePasswordChangeRequest."""
frame = FramePasswordChangeRequest(currentpassword="fnord", newpassword="bfeld")
self.assertEqual(str(frame), '<FramePasswordChangeRequest currentpassword="fn****" newpassword="bf****"/>')
def test_str_no_password(self):
"""Test string representation of FramePasswordChangeRequest with no password."""
frame = FramePasswordChangeRequest()
self.assertEqual(str(frame), '<FramePasswordChangeRequest currentpassword="None" newpassword="None"/>')
|
class TestFramePasswordChange(unittest.TestCase):
'''Test class for FramePasswordChangeRequest.'''
def test_bytes(self):
'''Test FramePasswordChangeRequest.'''
pass
def test_bytes_long_newpw(self):
'''Test FramePasswordChangeRequest with long new password.'''
pass
def test_bytes_long_oldpw(self):
'''Test FramePasswordChangeRequest with long old password.'''
pass
def test_bytes_long_bothpw(self):
'''Test FramePasswordChangeRequest with long passwords.'''
pass
def test_frame_from_raw(self):
'''Test parsing FramePasswordChangeRequest from raw bytes.'''
pass
def test_errors(self):
'''Test FramePasswordChangeRequest with wrong password.'''
pass
def test_str(self):
'''Test string representation of FramePasswordChangeRequest.'''
pass
def test_str_no_password(self):
'''Test string representation of FramePasswordChangeRequest with no password.'''
pass
| 9 | 9 | 8 | 0 | 7 | 1 | 1 | 0.18 | 1 | 4 | 2 | 0 | 8 | 0 | 8 | 80 | 75 | 9 | 56 | 16 | 47 | 10 | 35 | 16 | 26 | 1 | 2 | 1 | 8 |
140,325 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_password_enter_cfm_test.py
|
test.frame_password_enter_cfm_test.TestFramePasswordEnterConfirmation
|
class TestFramePasswordEnterConfirmation(unittest.TestCase):
"""Test class for FramePasswordEnterConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FramePasswordEnterConfirmation."""
frame = FramePasswordEnterConfirmation()
self.assertEqual(bytes(frame), b"\x00\x040\x01\x005")
def test_bytes_error(self):
"""Test failed FramePasswordEnterConfirmation."""
frame = FramePasswordEnterConfirmation(
status=PasswordEnterConfirmationStatus.FAILED
)
self.assertEqual(bytes(frame), b"\x00\x040\x01\x014")
def test_frame_from_raw(self):
"""Test parse FramePasswordEnterConfirmation from raw."""
frame = frame_from_raw(b"\x00\x040\x01\x014")
self.assertTrue(isinstance(frame, FramePasswordEnterConfirmation))
self.assertEqual(frame.status, PasswordEnterConfirmationStatus.FAILED)
def test_str(self):
"""Test string representation of FramePasswordEnterConfirmation."""
frame = FramePasswordEnterConfirmation()
self.assertEqual(
str(frame),
'<FramePasswordEnterConfirmation status="PasswordEnterConfirmationStatus.SUCCESSFUL"/>',
)
|
class TestFramePasswordEnterConfirmation(unittest.TestCase):
'''Test class for FramePasswordEnterConfirmation.'''
def test_bytes(self):
'''Test FramePasswordEnterConfirmation.'''
pass
def test_bytes_error(self):
'''Test failed FramePasswordEnterConfirmation.'''
pass
def test_frame_from_raw(self):
'''Test parse FramePasswordEnterConfirmation from raw.'''
pass
def test_str(self):
'''Test string representation of FramePasswordEnterConfirmation.'''
pass
| 5 | 5 | 6 | 0 | 5 | 1 | 1 | 0.32 | 1 | 4 | 2 | 0 | 4 | 0 | 4 | 76 | 30 | 5 | 19 | 9 | 14 | 6 | 14 | 9 | 9 | 1 | 2 | 0 | 4 |
140,326 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_password_enter_req_test.py
|
test.frame_password_enter_req_test.TestFramePasswordEnter
|
class TestFramePasswordEnter(unittest.TestCase):
"""Test class for FramePasswordEnterRequest."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FramePasswordEnterRequest."""
frame = FramePasswordEnterRequest(password="fnord")
self.assertEqual(
bytes(frame),
b"\x00#0\x00fnord\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00b",
)
def test_bytes_long_pw(self):
"""Test FramePasswordEnterRequest with long password."""
frame = FramePasswordEnterRequest(password="x" * 32)
self.assertEqual(
bytes(frame), b"\x00#0\x00xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\x13"
)
def test_frame_from_raw(self):
"""Test parsing FramePasswordEnterRequest from raw bytes."""
frame = frame_from_raw(
b"\x00#0\x00fnord\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00b"
)
self.assertTrue(isinstance(frame, FramePasswordEnterRequest))
self.assertEqual(frame.password, "fnord")
def test_frame_from_raw_long(self):
"""Test parsing FramePasswordEnterRequest from raw bytes with long password."""
frame = frame_from_raw(b"\x00#0\x00xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\x13")
self.assertTrue(isinstance(frame, FramePasswordEnterRequest))
self.assertEqual(frame.password, "x" * 32)
def test_errors(self):
"""Test FramePasswordEnterRequest with wrong password."""
with self.assertRaises(PyVLXException):
bytes(FramePasswordEnterRequest())
with self.assertRaises(PyVLXException):
bytes(FramePasswordEnterRequest(password="x" * 33))
def test_str(self):
"""Test string representation of FramePasswordEnterRequest."""
frame = FramePasswordEnterRequest(password="fnord")
self.assertEqual(str(frame), '<FramePasswordEnterRequest password="fn****"/>')
def test_str_no_password(self):
"""Test string representation of FramePasswordEnterRequest with no password."""
frame = FramePasswordEnterRequest()
self.assertEqual(str(frame), '<FramePasswordEnterRequest password="None"/>')
|
class TestFramePasswordEnter(unittest.TestCase):
'''Test class for FramePasswordEnterRequest.'''
def test_bytes(self):
'''Test FramePasswordEnterRequest.'''
pass
def test_bytes_long_pw(self):
'''Test FramePasswordEnterRequest with long password.'''
pass
def test_frame_from_raw(self):
'''Test parsing FramePasswordEnterRequest from raw bytes.'''
pass
def test_frame_from_raw_long(self):
'''Test parsing FramePasswordEnterRequest from raw bytes with long password.'''
pass
def test_errors(self):
'''Test FramePasswordEnterRequest with wrong password.'''
pass
def test_str(self):
'''Test string representation of FramePasswordEnterRequest.'''
pass
def test_str_no_password(self):
'''Test string representation of FramePasswordEnterRequest with no password.'''
pass
| 8 | 8 | 6 | 0 | 5 | 2 | 1 | 0.35 | 1 | 4 | 2 | 0 | 7 | 0 | 7 | 79 | 54 | 8 | 37 | 14 | 29 | 13 | 26 | 14 | 18 | 1 | 2 | 1 | 7 |
140,327 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_reboot_cfm_test.py
|
test.frame_reboot_cfm_test.TestFrameGatewayRebootConfirmation
|
class TestFrameGatewayRebootConfirmation(unittest.TestCase):
"""Test class TestFrameGatewayRebootConfirmation."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x03\x00\x02\x01"
def test_bytes(self):
"""Test FrameGatewayRebootConfirmation with NO_TYPE."""
frame = FrameGatewayRebootConfirmation()
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameGatewayRebootConfirmation from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameGatewayRebootConfirmation))
def test_str(self):
"""Test string representation of FrameGatewayRebootConfirmation."""
frame = FrameGatewayRebootConfirmation()
self.assertEqual(str(frame), '<FrameGatewayRebootConfirmation/>')
|
class TestFrameGatewayRebootConfirmation(unittest.TestCase):
'''Test class TestFrameGatewayRebootConfirmation.'''
def test_bytes(self):
'''Test FrameGatewayRebootConfirmation with NO_TYPE.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGatewayRebootConfirmation from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGatewayRebootConfirmation.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.45 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 21 | 5 | 11 | 8 | 7 | 5 | 11 | 8 | 7 | 1 | 2 | 0 | 3 |
140,328 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_reboot_req_test.py
|
test.frame_reboot_req_test.TestFrameGatewayRebootRequest
|
class TestFrameGatewayRebootRequest(unittest.TestCase):
"""Test class TestFrameGatewayRebootRequest."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME = b"\x00\x03\x00\x01\x02"
def test_bytes(self):
"""Test FrameGatewayRebootRequest with NO_TYPE."""
frame = FrameGatewayRebootRequest()
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME)
def test_frame_from_raw(self):
"""Test parse FrameGatewayRebootRequest from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME)
self.assertTrue(isinstance(frame, FrameGatewayRebootRequest))
def test_str(self):
"""Test string representation of FrameGatewayRebootRequest."""
frame = FrameGatewayRebootRequest()
self.assertEqual(str(frame), '<FrameGatewayRebootRequest/>')
|
class TestFrameGatewayRebootRequest(unittest.TestCase):
'''Test class TestFrameGatewayRebootRequest.'''
def test_bytes(self):
'''Test FrameGatewayRebootRequest with NO_TYPE.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameGatewayRebootRequest from raw.'''
pass
def test_str(self):
'''Test string representation of FrameGatewayRebootRequest.'''
pass
| 4 | 4 | 4 | 0 | 3 | 1 | 1 | 0.45 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 21 | 5 | 11 | 8 | 7 | 5 | 11 | 8 | 7 | 1 | 2 | 0 | 3 |
140,329 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_session_finished_notification_test.py
|
test.frame_session_finished_notification_test.TestFrameSessionFinishedNotification
|
class TestFrameSessionFinishedNotification(unittest.TestCase):
"""Test class FrameSessionFinishedNotification."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FrameSessionFinishedNotification."""
frame = FrameSessionFinishedNotification(session_id=1000)
self.assertEqual(bytes(frame), b"\x00\x05\x03\x04\x03\xe8\xe9")
def test_frame_from_raw(self):
"""Test parse FrameSessionFinishedNotification from raw."""
frame = frame_from_raw(b"\x00\x05\x03\x04\x03\xe8\xe9")
self.assertTrue(isinstance(frame, FrameSessionFinishedNotification))
self.assertEqual(frame.session_id, 1000)
def test_str(self):
"""Test string representation of FrameSessionFinishedNotification."""
frame = FrameSessionFinishedNotification(session_id=1000)
self.assertEqual(
str(frame), '<FrameSessionFinishedNotification session_id="1000"/>'
)
|
class TestFrameSessionFinishedNotification(unittest.TestCase):
'''Test class FrameSessionFinishedNotification.'''
def test_bytes(self):
'''Test FrameSessionFinishedNotification.'''
pass
def test_frame_from_raw(self):
'''Test parse FrameSessionFinishedNotification from raw.'''
pass
def test_str(self):
'''Test string representation of FrameSessionFinishedNotification.'''
pass
| 4 | 4 | 5 | 0 | 4 | 1 | 1 | 0.38 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 22 | 4 | 13 | 7 | 9 | 5 | 11 | 7 | 7 | 1 | 2 | 0 | 3 |
140,330 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_password_change_ntf_test.py
|
test.frame_password_change_ntf_test.TestFramePasswordChange
|
class TestFramePasswordChange(unittest.TestCase):
"""Test class for FramePasswordChangeNotification."""
# pylint: disable=too-many-public-methods,invalid-name
def test_bytes(self):
"""Test FramePasswordChangeNotification."""
frame = FramePasswordChangeNotification(newpassword="fnord")
self.assertEqual(
bytes(frame),
b"\x00#0\x04fnord\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00f",
)
def test_bytes_long_pw(self):
"""Test FramePasswordChangeNotification with long new password."""
frame = FramePasswordChangeNotification(newpassword="x" * 32)
self.assertEqual(
bytes(frame), b"\x00#0\x04xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\x17"
)
def test_frame_from_raw(self):
"""Test parsing FramePasswordChangeNotification from raw bytes."""
frame = frame_from_raw(
b"\x00#0\x04fnord\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00f",
)
self.assertTrue(isinstance(frame, FramePasswordChangeNotification))
self.assertEqual(frame.newpassword, "fnord")
def test_errors(self):
"""Test FramePasswordChangeNotification with wrong password."""
with self.assertRaises(PyVLXException):
bytes(FramePasswordChangeNotification())
with self.assertRaises(PyVLXException):
bytes(FramePasswordChangeNotification(newpassword="x" * 33))
def test_str(self):
"""Test string representation of FramePasswordChangeNotification."""
frame = FramePasswordChangeNotification(newpassword="fnord")
self.assertEqual(str(frame), '<FramePasswordChangeNotification newpassword="fn****"/>')
def test_str_no_password(self):
"""Test string representation of FramePasswordChangeNotification with no password."""
frame = FramePasswordChangeNotification()
self.assertEqual(str(frame), '<FramePasswordChangeNotification newpassword="None"/>')
|
class TestFramePasswordChange(unittest.TestCase):
'''Test class for FramePasswordChangeNotification.'''
def test_bytes(self):
'''Test FramePasswordChangeNotification.'''
pass
def test_bytes_long_pw(self):
'''Test FramePasswordChangeNotification with long new password.'''
pass
def test_frame_from_raw(self):
'''Test parsing FramePasswordChangeNotification from raw bytes.'''
pass
def test_errors(self):
'''Test FramePasswordChangeNotification with wrong password.'''
pass
def test_str(self):
'''Test string representation of FramePasswordChangeNotification.'''
pass
def test_str_no_password(self):
'''Test string representation of FramePasswordChangeNotification with no password.'''
pass
| 7 | 7 | 6 | 0 | 5 | 2 | 1 | 0.33 | 1 | 4 | 2 | 0 | 6 | 0 | 6 | 78 | 48 | 7 | 33 | 12 | 26 | 11 | 22 | 12 | 15 | 1 | 2 | 1 | 6 |
140,331 |
Julius2342/pyvlx
|
Julius2342_pyvlx/test/frame_status_request_test.py
|
test.frame_status_request_test.TestFrameStatusRequestNotification
|
class TestFrameStatusRequestNotification(unittest.TestCase):
"""Test class FrameStatusRequestNotification."""
# pylint: disable=too-many-public-methods,invalid-name
EXAMPLE_FRAME_EMPTY = b"\x00>\x03\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00:"
EXAMPLE_FRAME = b"\x00>\x03\x07\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00: "
def test_bytes(self) -> None:
"""Test FrameStatusRequestNotification."""
frame = FrameStatusRequestNotification()
self.assertEqual(bytes(frame), self.EXAMPLE_FRAME_EMPTY)
def test_frame_from_raw(self) -> None:
"""Test parse FrameStatusRequestNotification from raw."""
frame = frame_from_raw(self.EXAMPLE_FRAME_EMPTY)
self.assertTrue(isinstance(frame, FrameStatusRequestNotification))
def test_str(self) -> None:
"""Test string representation of FrameStatusRequestNotification."""
frame = FrameStatusRequestNotification()
self.assertEqual(str(frame), "<FrameStatusRequestNotification session_id=\"0\" "
"status_id=\"0\" node_id=\"0\" run_status=\"RunStatus.EXECUTION_COMPLETED\" "
"status_reply=\"StatusReply.UNKNOWN_STATUS_REPLY\" "
"status_type=\"StatusType.REQUEST_TARGET_POSITION\" status_count=\"0\" "
"parameter_data=\"\"/>")
|
class TestFrameStatusRequestNotification(unittest.TestCase):
'''Test class FrameStatusRequestNotification.'''
def test_bytes(self) -> None:
'''Test FrameStatusRequestNotification.'''
pass
def test_frame_from_raw(self) -> None:
'''Test parse FrameStatusRequestNotification from raw.'''
pass
def test_str(self) -> None:
'''Test string representation of FrameStatusRequestNotification.'''
pass
| 4 | 4 | 5 | 0 | 4 | 1 | 1 | 0.25 | 1 | 3 | 1 | 0 | 3 | 0 | 3 | 75 | 30 | 5 | 20 | 9 | 16 | 5 | 12 | 9 | 8 | 1 | 2 | 0 | 3 |
140,332 |
Julius2342/pyvlx
|
Julius2342_pyvlx/pyvlx/api/frames/frame_get_network_setup.py
|
pyvlx.api.frames.frame_get_network_setup.FrameGetNetworkSetupRequest
|
class FrameGetNetworkSetupRequest(FrameBase):
"""Frame for requesting network setup."""
PAYLOAD_LEN = 0
def __init__(self) -> None:
"""Init Frame."""
super().__init__(Command.GW_GET_NETWORK_SETUP_REQ)
|
class FrameGetNetworkSetupRequest(FrameBase):
'''Frame for requesting network setup.'''
def __init__(self) -> None:
'''Init Frame.'''
pass
| 2 | 2 | 3 | 0 | 2 | 1 | 1 | 0.5 | 1 | 2 | 1 | 0 | 1 | 0 | 1 | 8 | 8 | 2 | 4 | 3 | 2 | 2 | 4 | 3 | 2 | 1 | 1 | 0 | 1 |
140,333 |
Julius2342/pyvlx
|
Julius2342_pyvlx/pyvlx/api/set_utc.py
|
pyvlx.api.set_utc.SetUTC
|
class SetUTC(ApiEvent):
"""Class for setting UTC time within gateway."""
def __init__(self, pyvlx: "PyVLX", timestamp: float = time.time()):
"""Initialize SetUTC class."""
super().__init__(pyvlx=pyvlx)
self.timestamp = timestamp
self.success = False
async def handle_frame(self, frame: FrameBase) -> bool:
"""Handle incoming API frame, return True if this was the expected frame."""
if not isinstance(frame, FrameSetUTCConfirmation):
return False
self.success = True
return True
def request_frame(self) -> FrameSetUTCRequest:
"""Construct initiating frame."""
timestamp = int(self.timestamp)
return FrameSetUTCRequest(timestamp=timestamp)
|
class SetUTC(ApiEvent):
'''Class for setting UTC time within gateway.'''
def __init__(self, pyvlx: "PyVLX", timestamp: float = time.time()):
'''Initialize SetUTC class.'''
pass
async def handle_frame(self, frame: FrameBase) -> bool:
'''Handle incoming API frame, return True if this was the expected frame.'''
pass
def request_frame(self) -> FrameSetUTCRequest:
'''Construct initiating frame.'''
pass
| 4 | 4 | 5 | 0 | 4 | 1 | 1 | 0.31 | 1 | 7 | 3 | 0 | 3 | 2 | 3 | 12 | 20 | 3 | 13 | 7 | 9 | 4 | 13 | 7 | 9 | 2 | 1 | 1 | 4 |
140,334 |
Julius2342/pyvlx
|
Julius2342_pyvlx/pyvlx/api/frames/frame_status_request.py
|
pyvlx.api.frames.frame_status_request.FrameStatusRequestConfirmation
|
class FrameStatusRequestConfirmation(FrameBase):
"""Frame for confirmation for status request request."""
PAYLOAD_LEN = 3
def __init__(self, session_id: Optional[int] = None, status: Optional[StatusRequestStatus] = None):
"""Init Frame."""
super().__init__(Command.GW_STATUS_REQUEST_CFM)
self.session_id = session_id
self.status = status
def get_payload(self) -> bytes:
"""Return Payload."""
assert self.session_id is not None
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
assert self.status is not None
ret += bytes([self.status.value])
return ret
def from_payload(self, payload: bytes) -> None:
"""Init frame from binary data."""
self.session_id = payload[0] * 256 + payload[1]
self.status = StatusRequestStatus(payload[2])
def __str__(self) -> str:
"""Return human readable string."""
return '<{} session_id="{}" status="{}"/>'.format(
type(self).__name__, self.session_id, self.status
)
|
class FrameStatusRequestConfirmation(FrameBase):
'''Frame for confirmation for status request request.'''
def __init__(self, session_id: Optional[int] = None, status: Optional[StatusRequestStatus] = None):
'''Init Frame.'''
pass
def get_payload(self) -> bytes:
'''Return Payload.'''
pass
def from_payload(self, payload: bytes) -> None:
'''Init frame from binary data.'''
pass
def __str__(self) -> str:
'''Return human readable string.'''
pass
| 5 | 5 | 5 | 0 | 4 | 1 | 1 | 0.26 | 1 | 7 | 2 | 0 | 4 | 2 | 4 | 11 | 29 | 5 | 19 | 9 | 14 | 5 | 17 | 9 | 12 | 1 | 1 | 0 | 4 |
140,335 |
Julius2342/pyvlx
|
Julius2342_pyvlx/pyvlx/api/frames/frame_set_utc.py
|
pyvlx.api.frames.frame_set_utc.FrameSetUTCRequest
|
class FrameSetUTCRequest(FrameBase):
"""Frame for command for setting UTC time."""
PAYLOAD_LEN = 4
def __init__(self, timestamp: float = 0):
"""Init Frame."""
super().__init__(Command.GW_SET_UTC_REQ)
self.timestamp = timestamp
@property
def timestamp_formatted(self) -> str:
"""Return time as human readable string."""
return datetime.fromtimestamp(self.timestamp).strftime("%Y-%m-%d %H:%M:%S")
def get_payload(self) -> bytes:
"""Return Payload."""
return struct.pack(">I", self.timestamp)
def from_payload(self, payload: bytes) -> None:
"""Init frame from binary data."""
self.timestamp = struct.unpack(">I", payload[0:4])[0]
def __str__(self) -> str:
"""Return human readable string."""
return '<{} time="{}"/>'.format(type(self).__name__, self.timestamp_formatted)
|
class FrameSetUTCRequest(FrameBase):
'''Frame for command for setting UTC time.'''
def __init__(self, timestamp: float = 0):
'''Init Frame.'''
pass
@property
def timestamp_formatted(self) -> str:
'''Return time as human readable string.'''
pass
def get_payload(self) -> bytes:
'''Return Payload.'''
pass
def from_payload(self, payload: bytes) -> None:
'''Init frame from binary data.'''
pass
def __str__(self) -> str:
'''Return human readable string.'''
pass
| 7 | 6 | 3 | 0 | 2 | 1 | 1 | 0.43 | 1 | 7 | 1 | 0 | 5 | 1 | 5 | 12 | 26 | 6 | 14 | 9 | 7 | 6 | 13 | 8 | 7 | 1 | 1 | 0 | 5 |
140,336 |
Julius2342/pyvlx
|
Julius2342_pyvlx/pyvlx/api/frames/frame_set_utc.py
|
pyvlx.api.frames.frame_set_utc.FrameSetUTCConfirmation
|
class FrameSetUTCConfirmation(FrameBase):
"""Frame for confirmation for setting UTC time."""
PAYLOAD_LEN = 0
def __init__(self) -> None:
"""Init Frame."""
super().__init__(Command.GW_SET_UTC_CFM)
|
class FrameSetUTCConfirmation(FrameBase):
'''Frame for confirmation for setting UTC time.'''
def __init__(self) -> None:
'''Init Frame.'''
pass
| 2 | 2 | 3 | 0 | 2 | 1 | 1 | 0.5 | 1 | 2 | 1 | 0 | 1 | 0 | 1 | 8 | 8 | 2 | 4 | 3 | 2 | 2 | 4 | 3 | 2 | 1 | 1 | 0 | 1 |
140,337 |
Julius2342/pyvlx
|
Julius2342_pyvlx/pyvlx/api/frames/frame_set_node_name.py
|
pyvlx.api.frames.frame_set_node_name.SetNodeNameConfirmationStatus
|
class SetNodeNameConfirmationStatus(Enum):
"""Enum class for status of password enter confirmation."""
OK = 0
ERROR_REQUEST_REJECTED = 1
ERROR_INVALID_SYSTEM_TABLE_INDEX = 2
|
class SetNodeNameConfirmationStatus(Enum):
'''Enum class for status of password enter confirmation.'''
| 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.25 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 49 | 6 | 1 | 4 | 4 | 3 | 1 | 4 | 4 | 3 | 0 | 4 | 0 | 0 |
140,338 |
Julius2342/pyvlx
|
Julius2342_pyvlx/pyvlx/api/frames/frame_command_send.py
|
pyvlx.api.frames.frame_command_send.FrameCommandRemainingTimeNotification
|
class FrameCommandRemainingTimeNotification(FrameBase):
"""Frame for notification of remaining time in scope of command send frame."""
PAYLOAD_LEN = 6
def __init__(self, session_id: Optional[int] = None, index_id: Optional[int] = None, node_parameter: Optional[int] = None, seconds: int = 0):
"""Init Frame."""
super().__init__(Command.GW_COMMAND_REMAINING_TIME_NTF)
self.session_id = session_id
self.index_id = index_id
self.node_parameter = node_parameter
self.seconds = seconds
def get_payload(self) -> bytes:
"""Return Payload."""
assert self.session_id is not None
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
assert self.index_id is not None
ret += bytes([self.index_id])
assert self.node_parameter is not None
ret += bytes([self.node_parameter])
ret += bytes([self.seconds >> 8 & 255, self.seconds & 255])
return ret
def from_payload(self, payload: bytes) -> None:
"""Init frame from binary data."""
self.session_id = payload[0] * 256 + payload[1]
self.index_id = payload[2]
self.node_parameter = payload[3]
self.seconds = payload[4] * 256 + payload[5]
def __str__(self) -> str:
"""Return human readable string."""
return (
'<{} session_id="{}" index_id="{}" '
'node_parameter="{}" seconds="{}"/>'.format(
type(self).__name__, self.session_id,
self.index_id, self.node_parameter, self.seconds
)
)
|
class FrameCommandRemainingTimeNotification(FrameBase):
'''Frame for notification of remaining time in scope of command send frame.'''
def __init__(self, session_id: Optional[int] = None, index_id: Optional[int] = None, node_parameter: Optional[int] = None, seconds: int = 0):
'''Init Frame.'''
pass
def get_payload(self) -> bytes:
'''Return Payload.'''
pass
def from_payload(self, payload: bytes) -> None:
'''Init frame from binary data.'''
pass
def __str__(self) -> str:
'''Return human readable string.'''
pass
| 5 | 5 | 8 | 0 | 7 | 1 | 1 | 0.17 | 1 | 6 | 1 | 0 | 4 | 4 | 4 | 11 | 40 | 5 | 30 | 11 | 25 | 5 | 24 | 11 | 19 | 1 | 1 | 0 | 4 |
140,339 |
Julius2342/pyvlx
|
Julius2342_pyvlx/pyvlx/api/frames/frame_command_send.py
|
pyvlx.api.frames.frame_command_send.FrameCommandRunStatusNotification
|
class FrameCommandRunStatusNotification(FrameBase):
"""Frame for run status notification in scope of command send frame."""
PAYLOAD_LEN = 13
def __init__(
self,
session_id: Optional[int] = None,
status_id: Optional[int] = None,
index_id: Optional[int] = None,
node_parameter: Optional[int] = None,
parameter_value: Optional[int] = None,
):
"""Init Frame."""
super().__init__(Command.GW_COMMAND_RUN_STATUS_NTF)
self.session_id = session_id
self.status_id = status_id
self.index_id = index_id
self.node_parameter = node_parameter
self.parameter_value = parameter_value
def get_payload(self) -> bytes:
"""Return Payload."""
assert self.session_id is not None
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
assert self.status_id is not None
ret += bytes([self.status_id])
assert self.index_id is not None
ret += bytes([self.index_id])
assert self.node_parameter is not None
ret += bytes([self.node_parameter])
assert self.parameter_value is not None
ret += bytes([self.parameter_value >> 8 & 255, self.parameter_value & 255])
# XXX: Missing implementation of run_status, status_reply and information_code
ret += bytes(6)
return ret
def from_payload(self, payload: bytes) -> None:
"""Init frame from binary data."""
self.session_id = payload[0] * 256 + payload[1]
self.status_id = payload[2]
self.index_id = payload[3]
self.node_parameter = payload[4]
self.parameter_value = payload[5] * 256 + payload[6]
def __str__(self) -> str:
"""Return human readable string."""
return (
'<{} session_id="{}" status_id="{}" '
'index_id="{}" node_parameter="{}" parameter_value="{}"/>'.format(
type(self).__name__, self.session_id,
self.status_id, self.index_id,
self.node_parameter, self.parameter_value
)
)
|
class FrameCommandRunStatusNotification(FrameBase):
'''Frame for run status notification in scope of command send frame.'''
def __init__(
self,
session_id: Optional[int] = None,
status_id: Optional[int] = None,
index_id: Optional[int] = None,
node_parameter: Optional[int] = None,
parameter_value: Optional[int] = None,
):
'''Init Frame.'''
pass
def get_payload(self) -> bytes:
'''Return Payload.'''
pass
def from_payload(self, payload: bytes) -> None:
'''Init frame from binary data.'''
pass
def __str__(self) -> str:
'''Return human readable string.'''
pass
| 5 | 5 | 12 | 0 | 11 | 1 | 1 | 0.14 | 1 | 6 | 1 | 0 | 4 | 5 | 4 | 11 | 56 | 6 | 44 | 19 | 32 | 6 | 30 | 12 | 25 | 1 | 1 | 0 | 4 |
140,340 |
Julius2342/pyvlx
|
Julius2342_pyvlx/pyvlx/api/frames/frame_command_send.py
|
pyvlx.api.frames.frame_command_send.FrameCommandSendConfirmation
|
class FrameCommandSendConfirmation(FrameBase):
"""Frame for confirmation of command send frame."""
PAYLOAD_LEN = 3
def __init__(self, session_id: Optional[int] = None, status: Optional[CommandSendConfirmationStatus] = None):
"""Init Frame."""
super().__init__(Command.GW_COMMAND_SEND_CFM)
self.session_id = session_id
self.status = status
def get_payload(self) -> bytes:
"""Return Payload."""
assert self.session_id is not None
assert self.status is not None
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
ret += bytes([self.status.value])
return ret
def from_payload(self, payload: bytes) -> None:
"""Init frame from binary data."""
self.session_id = payload[0] * 256 + payload[1]
self.status = CommandSendConfirmationStatus(payload[2])
def __str__(self) -> str:
"""Return human readable string."""
return '<{} session_id="{}" status="{}"/>'.format(
type(self).__name__, self.session_id, self.status
)
|
class FrameCommandSendConfirmation(FrameBase):
'''Frame for confirmation of command send frame.'''
def __init__(self, session_id: Optional[int] = None, status: Optional[CommandSendConfirmationStatus] = None):
'''Init Frame.'''
pass
def get_payload(self) -> bytes:
'''Return Payload.'''
pass
def from_payload(self, payload: bytes) -> None:
'''Init frame from binary data.'''
pass
def __str__(self) -> str:
'''Return human readable string.'''
pass
| 5 | 5 | 5 | 0 | 4 | 1 | 1 | 0.26 | 1 | 7 | 2 | 0 | 4 | 2 | 4 | 11 | 29 | 5 | 19 | 9 | 14 | 5 | 17 | 9 | 12 | 1 | 1 | 0 | 4 |
140,341 |
Julius2342/pyvlx
|
Julius2342_pyvlx/pyvlx/api/frames/frame_status_request.py
|
pyvlx.api.frames.frame_status_request.FrameStatusRequestNotification
|
class FrameStatusRequestNotification(FrameBase):
"""Frame for notification of status request request."""
# PAYLOAD_LEN = 59
# No PAYLOAD_LEN because it is variable depending on StatusType
def __init__(self) -> None:
"""Init Frame."""
super().__init__(Command.GW_STATUS_REQUEST_NTF)
self.session_id = 0
self.status_id = 0
self.node_id = 0
self.run_status = RunStatus.EXECUTION_COMPLETED
self.status_reply = StatusReply.UNKNOWN_STATUS_REPLY
self.status_type = StatusType.REQUEST_TARGET_POSITION
self.status_count = 0
self.parameter_data: Dict[NodeParameter, Parameter] = {}
self.target_position = Parameter()
self.current_position = Parameter()
self.remaining_time = 0
self.last_master_execution_address = b''
self.last_command_originator = 0
def get_payload(self) -> bytes:
"""Return Payload."""
payload = bytes()
payload += bytes([self.session_id >> 8 & 255, self.session_id & 255])
payload += bytes([self.status_id])
payload += bytes([self.node_id])
payload += bytes([self.run_status.value])
payload += bytes([self.status_reply.value])
payload += bytes([self.status_type.value])
if self.status_type == StatusType.REQUEST_MAIN_INFO:
payload += bytes(self.target_position.raw)
payload += bytes(self.current_position.raw)
payload += bytes([self.remaining_time >> 8 & 255, self.remaining_time & 255])
payload += self.last_master_execution_address
payload += bytes([self.last_command_originator])
else:
payload += bytes([self.status_count])
keys = self.parameter_data.keys()
for key in keys:
payload += bytes([key.value])
payload += bytes(self.parameter_data[key].raw)
payload += bytes(51 - len(self.parameter_data))
return payload
def from_payload(self, payload: bytes) -> None:
"""Init frame from binary data."""
self.session_id = payload[0] * 256 + payload[1]
self.status_id = payload[2]
self.node_id = payload[3]
self.run_status = RunStatus(payload[4])
self.status_reply = StatusReply(payload[5])
self.status_type = StatusType(payload[6])
if self.status_type == StatusType.REQUEST_MAIN_INFO:
self.target_position = Parameter(payload[7:8])
self.current_position = Parameter(payload[9:10])
self.remaining_time = payload[11] * 256 + payload[12]
self.last_master_execution_address = payload[13:16]
self.last_command_originator = payload[17]
else:
self.status_count = payload[7]
for i in range(8, 8 + self.status_count*3, 3):
self.parameter_data.update({NodeParameter(payload[i]): Parameter(payload[i+1:i+3])})
def __str__(self) -> str:
"""Return human readable string."""
if self.status_type == StatusType.REQUEST_MAIN_INFO:
return (
'<{} session_id="{}" status_id="{}" '
'node_id="{}" run_status="{}" status_reply="{}" status_type="{}" target_position="{}" '
'current_position="{}" remaining_time="{}" last_master_execution_address="{!r}" last_command_originator="{}"/>'.format(
type(self).__name__,
self.session_id,
self.status_id,
self.node_id,
self.run_status,
self.status_reply,
self.status_type,
self.target_position,
self.current_position,
self.remaining_time,
self.last_master_execution_address,
self.last_command_originator,
)
)
parameter_data_str = ""
for key, value in self.parameter_data.items():
parameter_data_str += "%s: %s, " % (
str(key),
str(value),
)
return (
'<{} session_id="{}" status_id="{}" '
'node_id="{}" run_status="{}" status_reply="{}" status_type="{}" status_count="{}" '
'parameter_data="{}"/>'.format(
type(self).__name__,
self.session_id,
self.status_id,
self.node_id,
self.run_status,
self.status_reply,
self.status_type,
self.status_count,
parameter_data_str
)
)
|
class FrameStatusRequestNotification(FrameBase):
'''Frame for notification of status request request.'''
def __init__(self) -> None:
'''Init Frame.'''
pass
def get_payload(self) -> bytes:
'''Return Payload.'''
pass
def from_payload(self, payload: bytes) -> None:
'''Init frame from binary data.'''
pass
def __str__(self) -> str:
'''Return human readable string.'''
pass
| 5 | 5 | 26 | 1 | 24 | 1 | 3 | 0.07 | 1 | 11 | 6 | 0 | 4 | 13 | 4 | 11 | 111 | 8 | 96 | 24 | 91 | 7 | 60 | 24 | 55 | 3 | 1 | 2 | 10 |
140,342 |
Julius2342/pyvlx
|
Julius2342_pyvlx/pyvlx/api/frames/frame_command_send.py
|
pyvlx.api.frames.frame_command_send.FrameCommandSendRequest
|
class FrameCommandSendRequest(FrameBase):
"""Frame for sending command to gw."""
PAYLOAD_LEN = 66
def __init__(
self,
node_ids: Optional[List[int]] = None,
parameter: Parameter = Parameter(),
active_parameter: int = 0,
session_id: Optional[int] = None,
originator: Originator = Originator.USER,
**functional_parameter: bytes
):
"""Init Frame."""
super().__init__(Command.GW_COMMAND_SEND_REQ)
self.node_ids = node_ids if node_ids is not None else []
self.parameter = parameter
self.active_parameter = active_parameter
self.fpi1 = 0
self.fpi2 = 0
self.functional_parameter = {}
self.session_id = session_id
self.originator = originator
self.priority = Priority.USER_LEVEL_2
"""Set the functional parameter indicator bytes in order to show which functional
parameters are included in the frame. Functional parameter dictionary will be checked
for keys 'fp1' to 'fp16' to set the appropriate indicator and the corresponding
self.functional_parameter."""
for i in range(1, 17):
key = "fp%s" % (i)
if key in functional_parameter:
self.functional_parameter[key] = functional_parameter[key]
if i < 9:
self.fpi1 += 2 ** (8 - i)
if i >= 9:
self.fpi2 += 2 ** (16 - i)
else:
self.functional_parameter[key] = bytes(2)
def get_payload(self) -> bytes:
"""Return Payload."""
# Session id
assert self.session_id is not None
ret = bytes([self.session_id >> 8 & 255, self.session_id & 255])
ret += bytes([self.originator.value])
ret += bytes([self.priority.value])
ret += bytes(
[self.active_parameter]
) # ParameterActive pointing to main parameter (MP)
# FPI 1+2
ret += bytes([self.fpi1])
ret += bytes([self.fpi2])
# Main parameter + functional parameter fp1 to fp3
ret += bytes(self.parameter)
ret += bytes(self.functional_parameter["fp1"])
ret += bytes(self.functional_parameter["fp2"])
ret += bytes(self.functional_parameter["fp3"])
# Functional parameter fp4 to fp16
ret += bytes(26)
# Nodes array: Number of nodes + node array + padding
ret += bytes([len(self.node_ids)]) # index array count
ret += bytes(self.node_ids) + bytes(20 - len(self.node_ids))
# Priority Level Lock
ret += bytes([0])
# Priority Level information 1+2
ret += bytes([0, 0])
# Locktime
ret += bytes([0])
return ret
def from_payload(self, payload: bytes) -> None:
"""Init frame from binary data."""
self.session_id = payload[0] * 256 + payload[1]
self.originator = Originator(payload[2])
self.priority = Priority(payload[3])
len_node_ids = payload[41]
if len_node_ids > 20:
raise PyVLXException("command_send_request_wrong_node_length")
self.node_ids = []
for i in range(len_node_ids):
self.node_ids.append(payload[42] + i)
self.parameter = Parameter(payload[7:9])
def __str__(self) -> str:
"""Return human readable string."""
functional_parameter = ""
for key, value in self.functional_parameter.items():
functional_parameter += "%s: %s, " % (
str(key),
Position(Parameter(bytes(value))),
)
return (
'<{} node_ids="{}" active_parameter="{}" parameter="{}" functional_parameter="{}" '
'session_id="{}" originator="{}"/>'.format(
type(self).__name__, self.node_ids, self.active_parameter,
self.parameter, functional_parameter,
self.session_id, self.originator,
)
)
|
class FrameCommandSendRequest(FrameBase):
'''Frame for sending command to gw.'''
def __init__(
self,
node_ids: Optional[List[int]] = None,
parameter: Parameter = Parameter(),
active_parameter:
'''Init Frame.'''
pass
def get_payload(self) -> bytes:
'''Return Payload.'''
pass
def from_payload(self, payload: bytes) -> None:
'''Init frame from binary data.'''
pass
def __str__(self) -> str:
'''Return human readable string.'''
pass
| 5 | 5 | 24 | 1 | 19 | 5 | 3 | 0.24 | 1 | 12 | 6 | 0 | 4 | 9 | 4 | 11 | 104 | 9 | 78 | 30 | 65 | 19 | 57 | 22 | 52 | 6 | 1 | 3 | 12 |
140,343 |
Julius2342/pyvlx
|
Julius2342_pyvlx/pyvlx/api/frames/frame_discover_nodes.py
|
pyvlx.api.frames.frame_discover_nodes.FrameDiscoverNodesConfirmation
|
class FrameDiscoverNodesConfirmation(FrameBase):
"""Frame for discover nodes confirmation."""
PAYLOAD_LEN = 0
def __init__(self) -> None:
"""Init Frame."""
super().__init__(Command.GW_CS_DISCOVER_NODES_CFM)
|
class FrameDiscoverNodesConfirmation(FrameBase):
'''Frame for discover nodes confirmation.'''
def __init__(self) -> None:
'''Init Frame.'''
pass
| 2 | 2 | 3 | 0 | 2 | 1 | 1 | 0.5 | 1 | 2 | 1 | 0 | 1 | 0 | 1 | 8 | 8 | 2 | 4 | 3 | 2 | 2 | 4 | 3 | 2 | 1 | 1 | 0 | 1 |
140,344 |
Julius2342/pyvlx
|
Julius2342_pyvlx/pyvlx/api/frames/frame_discover_nodes.py
|
pyvlx.api.frames.frame_discover_nodes.FrameDiscoverNodesNotification
|
class FrameDiscoverNodesNotification(FrameBase):
"""Frame for discover nodes notification."""
PAYLOAD_LEN = 131
def __init__(self) -> None:
"""Init Frame."""
super().__init__(Command.GW_CS_DISCOVER_NODES_NTF)
self.payload = b"\0" * 131
def get_payload(self) -> bytes:
"""Return Payload."""
return self.payload
def from_payload(self, payload: bytes) -> None:
"""Init frame from binary data."""
self.payload = payload
def __str__(self) -> str:
"""Return human readable string."""
return '<{} payload="{}"/>'.format(
type(self).__name__,
':'.join('{:02x}'.format(c) for c in self.payload)
)
|
class FrameDiscoverNodesNotification(FrameBase):
'''Frame for discover nodes notification.'''
def __init__(self) -> None:
'''Init Frame.'''
pass
def get_payload(self) -> bytes:
'''Return Payload.'''
pass
def from_payload(self, payload: bytes) -> None:
'''Init frame from binary data.'''
pass
def __str__(self) -> str:
'''Return human readable string.'''
pass
| 5 | 5 | 4 | 0 | 3 | 1 | 1 | 0.36 | 1 | 5 | 1 | 0 | 4 | 1 | 4 | 11 | 24 | 5 | 14 | 7 | 9 | 5 | 11 | 7 | 6 | 1 | 1 | 0 | 4 |
140,345 |
Julius2342/pyvlx
|
Julius2342_pyvlx/pyvlx/api/frames/frame_discover_nodes.py
|
pyvlx.api.frames.frame_discover_nodes.FrameDiscoverNodesRequest
|
class FrameDiscoverNodesRequest(FrameBase):
"""Frame for discover nodes request."""
PAYLOAD_LEN = 1
def __init__(self, node_type: NodeType = NodeType.NO_TYPE):
"""Init Frame."""
super().__init__(Command.GW_CS_DISCOVER_NODES_REQ)
self.node_type = node_type
def get_payload(self) -> bytes:
"""Return Payload."""
ret = bytes([self.node_type.value])
return ret
def from_payload(self, payload: bytes) -> None:
"""Init frame from binary data."""
self.node_type = NodeType(payload[0])
def __str__(self) -> str:
"""Return human readable string."""
return '<{} node_type="{}"/>'.format(type(self).__name__, self.node_type)
|
class FrameDiscoverNodesRequest(FrameBase):
'''Frame for discover nodes request.'''
def __init__(self, node_type: NodeType = NodeType.NO_TYPE):
'''Init Frame.'''
pass
def get_payload(self) -> bytes:
'''Return Payload.'''
pass
def from_payload(self, payload: bytes) -> None:
'''Init frame from binary data.'''
pass
def __str__(self) -> str:
'''Return human readable string.'''
pass
| 5 | 5 | 4 | 0 | 3 | 1 | 1 | 0.42 | 1 | 6 | 2 | 0 | 4 | 1 | 4 | 11 | 22 | 5 | 12 | 8 | 7 | 5 | 12 | 8 | 7 | 1 | 1 | 0 | 4 |
140,346 |
Julius2342/pyvlx
|
Julius2342_pyvlx/pyvlx/api/frames/frame_error_notification.py
|
pyvlx.api.frames.frame_error_notification.FrameErrorNotification
|
class FrameErrorNotification(FrameBase):
"""Frame for error notification."""
PAYLOAD_LEN = 1
def __init__(self, error_type: ErrorType = ErrorType.NotFurtherDefined):
"""Init Frame."""
super().__init__(Command.GW_ERROR_NTF)
self.error_type = error_type
def get_payload(self) -> bytes:
"""Return Payload."""
ret = bytes([self.error_type.value])
return ret
def from_payload(self, payload: bytes) -> None:
"""Init frame from binary data."""
self.error_type = ErrorType(payload[0])
def __str__(self) -> str:
"""Return human readable string."""
return '<{} error_type="{}"/>'.format(type(self).__name__, self.error_type)
|
class FrameErrorNotification(FrameBase):
'''Frame for error notification.'''
def __init__(self, error_type: ErrorType = ErrorType.NotFurtherDefined):
'''Init Frame.'''
pass
def get_payload(self) -> bytes:
'''Return Payload.'''
pass
def from_payload(self, payload: bytes) -> None:
'''Init frame from binary data.'''
pass
def __str__(self) -> str:
'''Return human readable string.'''
pass
| 5 | 5 | 4 | 0 | 3 | 1 | 1 | 0.42 | 1 | 6 | 2 | 0 | 4 | 1 | 4 | 11 | 22 | 5 | 12 | 8 | 7 | 5 | 12 | 8 | 7 | 1 | 1 | 0 | 4 |
140,347 |
Julius2342/pyvlx
|
Julius2342_pyvlx/pyvlx/api/frames/frame_facory_default.py
|
pyvlx.api.frames.frame_facory_default.FrameGatewayFactoryDefaultConfirmation
|
class FrameGatewayFactoryDefaultConfirmation(FrameBase):
"""Frame for response for factory reset."""
PAYLOAD_LEN = 0
def __init__(self) -> None:
"""Init Frame."""
super().__init__(Command.GW_SET_FACTORY_DEFAULT_CFM)
def __str__(self) -> str:
"""Return human readable string."""
return '<{}/>'.format(type(self).__name__)
|
class FrameGatewayFactoryDefaultConfirmation(FrameBase):
'''Frame for response for factory reset.'''
def __init__(self) -> None:
'''Init Frame.'''
pass
def __str__(self) -> str:
'''Return human readable string.'''
pass
| 3 | 3 | 3 | 0 | 2 | 1 | 1 | 0.5 | 1 | 4 | 1 | 0 | 2 | 0 | 2 | 9 | 12 | 3 | 6 | 4 | 3 | 3 | 6 | 4 | 3 | 1 | 1 | 0 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.