Compare commits

..

No commits in common. "9c0e2bef39bd2d0252574f9d6e57298ac0fd84ea" and "79260a0e475c50a248c754d5e82d3110d753a5eb" have entirely different histories.

5 changed files with 17 additions and 28 deletions

View File

@ -11,18 +11,6 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
- [x]
## [2.4.9] - 2023-08-13
### Added
- Error tests added in tests/test_errors.py
- Errors section in README updated.
### Changed
- VBANCMDConnectionError class now subclasses VBANCMDError
- If the configs loader is passed an invalid config TOML it will log an error but continue to load further configs into memory.
## [2.3.2] - 2023-07-12
### Added

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "vban-cmd"
version = "2.4.9"
version = "2.4.8"
description = "Python interface for the VBAN RT Packet Service (Sendtext)"
authors = ["onyx-and-iris <code@onyxandiris.online>"]
license = "MIT"

View File

@ -1,5 +1,3 @@
import re
import pytest
import vban_cmd
@ -17,15 +15,16 @@ class TestErrors:
vban_cmd.api("unknown_kind")
def test_it_tests_an_unknown_config_name(self):
EXPECTED_MSG = "\n".join(
(
f"No config with name 'unknown' is loaded into memory",
f"Known configs: {list(vban.configs.keys())}",
)
EXPECTED_MSG = (
f"No config with name 'unknown' is loaded into memory",
f"Known configs: {list(vban.configs.keys())}",
)
with pytest.raises(vban_cmd.error.VBANCMDError, match=re.escape(EXPECTED_MSG)):
with pytest.raises(vban_cmd.error.VBANCMDError) as exc_info:
vban.apply_config("unknown")
e = exc_info.value
assert e.message == "\n".join(EXPECTED_MSG)
def test_it_tests_an_invalid_config_key(self):
CONFIG = {
"strip-0": {"A1": True, "B1": True, "gain": -6.0},

View File

@ -148,13 +148,8 @@ class Loader(metaclass=SingletonType):
self.logger.info(
f"config file with name {identifier} already in memory, skipping.."
)
return
try:
self.parser = dataextraction_factory(data)
except tomllib.TOMLDecodeError as e:
ERR_MSG = (str(e), f"When attempting to load {identifier}.toml")
self.logger.error(f"{type(e).__name__}: {' '.join(ERR_MSG)}")
return
return False
self.parser = dataextraction_factory(data)
return True
def register(self, identifier, data=None):

View File

@ -1,6 +1,13 @@
class VBANCMDError(Exception):
"""Base VBANCMD Exception class. Raised when general errors occur"""
def __init__(self, msg):
self.message = msg
super().__init__(self.message)
def __str__(self):
return f"{type(self).__name__}: {self.message}"
class VBANCMDConnectionError(VBANCMDError):
"""Exception raised when connection/timeout errors occur"""