mirror of
https://github.com/dtomlinson91/panaetius.git
synced 2025-12-21 20:55:43 +00:00
adding initial tests
This commit is contained in:
146
poetry.lock
generated
146
poetry.lock
generated
@@ -65,6 +65,17 @@ category = "dev"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "execnet"
|
||||
version = "1.9.0"
|
||||
description = "execnet: rapid multi-Python deployment"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||
|
||||
[package.extras]
|
||||
testing = ["pre-commit"]
|
||||
|
||||
[[package]]
|
||||
name = "flake8"
|
||||
version = "2.3.0"
|
||||
@@ -129,6 +140,14 @@ docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"]
|
||||
perf = ["ipython"]
|
||||
testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "packaging", "pep517", "pyfakefs", "flufl.flake8", "pytest-perf (>=0.9.2)", "pytest-black (>=0.3.7)", "pytest-mypy", "importlib-resources (>=1.3)"]
|
||||
|
||||
[[package]]
|
||||
name = "iniconfig"
|
||||
version = "1.1.1"
|
||||
description = "iniconfig: brain-dead simple config-ini parsing"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "isort"
|
||||
version = "5.9.3"
|
||||
@@ -159,14 +178,6 @@ category = "dev"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "more-itertools"
|
||||
version = "8.10.0"
|
||||
description = "More routines for operating on iterables, beyond itertools"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.5"
|
||||
|
||||
[[package]]
|
||||
name = "mypy"
|
||||
version = "0.910"
|
||||
@@ -193,6 +204,17 @@ category = "dev"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "packaging"
|
||||
version = "21.0"
|
||||
description = "Core utilities for Python packages"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.dependencies]
|
||||
pyparsing = ">=2.0.2"
|
||||
|
||||
[[package]]
|
||||
name = "pbr"
|
||||
version = "5.6.0"
|
||||
@@ -396,22 +418,76 @@ category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "pyparsing"
|
||||
version = "2.4.7"
|
||||
description = "Python parsing module"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
|
||||
|
||||
[[package]]
|
||||
name = "pytest"
|
||||
version = "3.10.1"
|
||||
version = "6.2.5"
|
||||
description = "pytest: simple powerful testing with Python"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.dependencies]
|
||||
atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""}
|
||||
attrs = ">=19.2.0"
|
||||
colorama = {version = "*", markers = "sys_platform == \"win32\""}
|
||||
importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""}
|
||||
iniconfig = "*"
|
||||
packaging = "*"
|
||||
pluggy = ">=0.12,<2.0"
|
||||
py = ">=1.8.2"
|
||||
toml = "*"
|
||||
|
||||
[package.extras]
|
||||
testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xmlschema"]
|
||||
|
||||
[[package]]
|
||||
name = "pytest-datadir"
|
||||
version = "1.3.1"
|
||||
description = "pytest plugin for test data directories and files"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
|
||||
|
||||
[package.dependencies]
|
||||
atomicwrites = ">=1.0"
|
||||
attrs = ">=17.4.0"
|
||||
colorama = {version = "*", markers = "sys_platform == \"win32\""}
|
||||
more-itertools = ">=4.0.0"
|
||||
pluggy = ">=0.7"
|
||||
py = ">=1.5.0"
|
||||
six = ">=1.10.0"
|
||||
pytest = ">=2.7.0"
|
||||
|
||||
[[package]]
|
||||
name = "pytest-forked"
|
||||
version = "1.3.0"
|
||||
description = "run tests in isolated forked subprocesses"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||
|
||||
[package.dependencies]
|
||||
py = "*"
|
||||
pytest = ">=3.10"
|
||||
|
||||
[[package]]
|
||||
name = "pytest-xdist"
|
||||
version = "2.4.0"
|
||||
description = "pytest xdist plugin for distributed testing and loop-on-failing modes"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
|
||||
[package.dependencies]
|
||||
execnet = ">=1.1"
|
||||
pytest = ">=6.0.0"
|
||||
pytest-forked = "*"
|
||||
|
||||
[package.extras]
|
||||
psutil = ["psutil (>=3.0)"]
|
||||
setproctitle = ["setproctitle"]
|
||||
testing = ["filelock"]
|
||||
|
||||
[[package]]
|
||||
name = "pyyaml"
|
||||
@@ -534,7 +610,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytes
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = "^3.7"
|
||||
content-hash = "09c1545b730544eb1d67b233f4446b9175031db78a91cd662e0c84af56bf8023"
|
||||
content-hash = "bc75d0878aaf4033c2d9520333a559d29e81962a8a0138ed8861014d2fc77eac"
|
||||
|
||||
[metadata.files]
|
||||
astroid = [
|
||||
@@ -561,6 +637,10 @@ dodgy = [
|
||||
{file = "dodgy-0.2.1-py3-none-any.whl", hash = "sha256:51f54c0fd886fa3854387f354b19f429d38c04f984f38bc572558b703c0542a6"},
|
||||
{file = "dodgy-0.2.1.tar.gz", hash = "sha256:28323cbfc9352139fdd3d316fa17f325cc0e9ac74438cbba51d70f9b48f86c3a"},
|
||||
]
|
||||
execnet = [
|
||||
{file = "execnet-1.9.0-py2.py3-none-any.whl", hash = "sha256:a295f7cc774947aac58dde7fdc85f4aa00c42adf5d8f5468fc630c1acf30a142"},
|
||||
{file = "execnet-1.9.0.tar.gz", hash = "sha256:8f694f3ba9cc92cab508b152dcfe322153975c29bda272e2fd7f3f00f36e47c5"},
|
||||
]
|
||||
flake8 = [
|
||||
{file = "flake8-2.3.0-py2.py3-none-any.whl", hash = "sha256:c99cc9716d6655d9c8bcb1e77632b8615bf0abd282d7abd9f5c2148cad7fc669"},
|
||||
{file = "flake8-2.3.0.tar.gz", hash = "sha256:5ee1a43ccd0716d6061521eec6937c983efa027793013e572712c4da55c7c83e"},
|
||||
@@ -581,6 +661,10 @@ importlib-metadata = [
|
||||
{file = "importlib_metadata-4.8.1-py3-none-any.whl", hash = "sha256:b618b6d2d5ffa2f16add5697cf57a46c76a56229b0ed1c438322e4e95645bd15"},
|
||||
{file = "importlib_metadata-4.8.1.tar.gz", hash = "sha256:f284b3e11256ad1e5d03ab86bb2ccd6f5339688ff17a4d797a0fe7df326f23b1"},
|
||||
]
|
||||
iniconfig = [
|
||||
{file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"},
|
||||
{file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"},
|
||||
]
|
||||
isort = [
|
||||
{file = "isort-5.9.3-py3-none-any.whl", hash = "sha256:e17d6e2b81095c9db0a03a8025a957f334d6ea30b26f9ec70805411e5c7c81f2"},
|
||||
{file = "isort-5.9.3.tar.gz", hash = "sha256:9c2ea1e62d871267b78307fe511c0838ba0da28698c5732d54e2790bf3ba9899"},
|
||||
@@ -613,10 +697,6 @@ mccabe = [
|
||||
{file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"},
|
||||
{file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"},
|
||||
]
|
||||
more-itertools = [
|
||||
{file = "more-itertools-8.10.0.tar.gz", hash = "sha256:1debcabeb1df793814859d64a81ad7cb10504c24349368ccf214c664c474f41f"},
|
||||
{file = "more_itertools-8.10.0-py3-none-any.whl", hash = "sha256:56ddac45541718ba332db05f464bebfb0768110111affd27f66e0051f276fa43"},
|
||||
]
|
||||
mypy = [
|
||||
{file = "mypy-0.910-cp35-cp35m-macosx_10_9_x86_64.whl", hash = "sha256:a155d80ea6cee511a3694b108c4494a39f42de11ee4e61e72bc424c490e46457"},
|
||||
{file = "mypy-0.910-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:b94e4b785e304a04ea0828759172a15add27088520dc7e49ceade7834275bedb"},
|
||||
@@ -646,6 +726,10 @@ mypy-extensions = [
|
||||
{file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"},
|
||||
{file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"},
|
||||
]
|
||||
packaging = [
|
||||
{file = "packaging-21.0-py3-none-any.whl", hash = "sha256:c86254f9220d55e31cc94d69bade760f0847da8000def4dfe1c6b872fd14ff14"},
|
||||
{file = "packaging-21.0.tar.gz", hash = "sha256:7dc96269f53a4ccec5c0670940a4281106dd0bb343f47b7471f779df49c2fbe7"},
|
||||
]
|
||||
pbr = [
|
||||
{file = "pbr-5.6.0-py2.py3-none-any.whl", hash = "sha256:c68c661ac5cc81058ac94247278eeda6d2e6aecb3e227b0387c30d277e7ef8d4"},
|
||||
{file = "pbr-5.6.0.tar.gz", hash = "sha256:42df03e7797b796625b1029c0400279c7c34fd7df24a7d7818a1abb5b38710dd"},
|
||||
@@ -708,9 +792,25 @@ pylite = [
|
||||
{file = "pylite-0.1.0-py3-none-any.whl", hash = "sha256:eb46f5beb1f2102672fd4355c013ac2feebc0df284d65f7711f2041a0a410141"},
|
||||
{file = "pylite-0.1.0.tar.gz", hash = "sha256:e338d20d3f8f72dd84d1e58f2fd6dba008d593e0cfacfb5fbdd5a297b830628e"},
|
||||
]
|
||||
pyparsing = [
|
||||
{file = "pyparsing-2.4.7-py2.py3-none-any.whl", hash = "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"},
|
||||
{file = "pyparsing-2.4.7.tar.gz", hash = "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"},
|
||||
]
|
||||
pytest = [
|
||||
{file = "pytest-3.10.1-py2.py3-none-any.whl", hash = "sha256:3f193df1cfe1d1609d4c583838bea3d532b18d6160fd3f55c9447fdca30848ec"},
|
||||
{file = "pytest-3.10.1.tar.gz", hash = "sha256:e246cf173c01169b9617fc07264b7b1316e78d7a650055235d6d897bc80d9660"},
|
||||
{file = "pytest-6.2.5-py3-none-any.whl", hash = "sha256:7310f8d27bc79ced999e760ca304d69f6ba6c6649c0b60fb0e04a4a77cacc134"},
|
||||
{file = "pytest-6.2.5.tar.gz", hash = "sha256:131b36680866a76e6781d13f101efb86cf674ebb9762eb70d3082b6f29889e89"},
|
||||
]
|
||||
pytest-datadir = [
|
||||
{file = "pytest-datadir-1.3.1.tar.gz", hash = "sha256:d3af1e738df87515ee509d6135780f25a15959766d9c2b2dbe02bf4fb979cb18"},
|
||||
{file = "pytest_datadir-1.3.1-py2.py3-none-any.whl", hash = "sha256:1847ed0efe0bc54cac40ab3fba6d651c2f03d18dd01f2a582979604d32e7621e"},
|
||||
]
|
||||
pytest-forked = [
|
||||
{file = "pytest-forked-1.3.0.tar.gz", hash = "sha256:6aa9ac7e00ad1a539c41bec6d21011332de671e938c7637378ec9710204e37ca"},
|
||||
{file = "pytest_forked-1.3.0-py2.py3-none-any.whl", hash = "sha256:dc4147784048e70ef5d437951728825a131b81714b398d5d52f17c7c144d8815"},
|
||||
]
|
||||
pytest-xdist = [
|
||||
{file = "pytest-xdist-2.4.0.tar.gz", hash = "sha256:89b330316f7fc475f999c81b577c2b926c9569f3d397ae432c0c2e2496d61ff9"},
|
||||
{file = "pytest_xdist-2.4.0-py3-none-any.whl", hash = "sha256:7b61ebb46997a0820a263553179d6d1e25a8c50d8a8620cd1aa1e20e3be99168"},
|
||||
]
|
||||
pyyaml = [
|
||||
{file = "PyYAML-6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53"},
|
||||
|
||||
@@ -103,6 +103,9 @@ dodgy:
|
||||
|
||||
bandit:
|
||||
run: true
|
||||
options:
|
||||
# ignore assert warning
|
||||
B101
|
||||
|
||||
mypy:
|
||||
run: true
|
||||
|
||||
@@ -28,11 +28,11 @@ toml = "^0.10.0"
|
||||
pylite = "^0.1.0"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
pytest = "^3.0" # TODO: Update to latest
|
||||
# sphinx = "^2.3"
|
||||
# sphinx_rtd_theme = "^0.4.3"
|
||||
prospector = {extras = ["with_bandit", "with_mypy"], version = "^1.5.1"}
|
||||
types-toml = "^0.10.1"
|
||||
pytest = "^6.2.5"
|
||||
pytest-datadir = "^1.3.1"
|
||||
pytest-xdist = "^2.4.0"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry>=0.12"]
|
||||
|
||||
3
pytest.ini
Normal file
3
pytest.ini
Normal file
@@ -0,0 +1,3 @@
|
||||
; parallel tests with pytest-xdist
|
||||
[pytest]
|
||||
addopts=-n4
|
||||
@@ -1 +0,0 @@
|
||||
__header__ = 'panaetius_test'
|
||||
6
tests/conftest.py
Normal file
6
tests/conftest.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def header():
|
||||
return "panaetius_testing"
|
||||
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
|
||||
from panaetius import Config, set_config
|
||||
from panaetius import Config, set_config, set_logger, SimpleLogger
|
||||
# from panaetius.logging import AdvancedLogger
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ["PANAETIUS_TEST_PATH"] = "/usr/local"
|
||||
@@ -17,17 +18,17 @@ if __name__ == "__main__":
|
||||
os.environ["PANAETIUS_TEST_NOC_EMBEDDED_FLOAT"] = "2.0"
|
||||
os.environ["PANAETIUS_TEST_NOC_EMBEDDED_BOOL"] = "true"
|
||||
|
||||
c = Config("panaetius_test")
|
||||
# c = Config("panaetius_test_noc")
|
||||
# c = Config("panaetius_test")
|
||||
c = Config("panaetius_test_noc")
|
||||
|
||||
set_config(c, key="toml.points", coerce=True)
|
||||
set_config(c, key="path", default="some path")
|
||||
set_config(c, key="top", default="some top")
|
||||
set_config(c, key="logging.path", default="some logging path")
|
||||
set_config(c, key="logging.path")
|
||||
set_config(c, key="nonexistent.item", default="some nonexistent item")
|
||||
set_config(c, key="nonexistent.item")
|
||||
set_config(c, key="toml.points_config")
|
||||
set_config(c, key="float", default=2.0)
|
||||
set_config(c, key="float", coerce=True)
|
||||
set_config(c, key="float_str", default="2.0")
|
||||
set_config(c, key="bool", coerce=True)
|
||||
set_config(c, key="noexistbool", default=False)
|
||||
@@ -47,5 +48,7 @@ if __name__ == "__main__":
|
||||
set_config(c, key="embedded.noexistfloat", default=2.0)
|
||||
set_config(c, key="embedded.noexistbool", default=False)
|
||||
|
||||
print(c)
|
||||
pass
|
||||
logger = set_logger(c, SimpleLogger())
|
||||
# logger = set_logger(c, AdvancedLogger(logging_level="INFO"))
|
||||
logger.info("test logging message")
|
||||
logger.debug("debugging message")
|
||||
@@ -1,33 +0,0 @@
|
||||
import panaetius
|
||||
|
||||
# from panaetius import CONFIG as CONFIG
|
||||
# from panaetius import logger as logger
|
||||
|
||||
print(panaetius.__header__)
|
||||
|
||||
panaetius.set_config(panaetius.CONFIG, 'logging.level')
|
||||
|
||||
# print(panaetius.CONFIG.logging_format)
|
||||
print(panaetius.CONFIG.logging_path)
|
||||
print(panaetius.config_inst.CONFIG_PATH)
|
||||
|
||||
# panaetius.logger.info('test event')
|
||||
|
||||
|
||||
panaetius.logger.info('setting foo.bar value')
|
||||
panaetius.set_config(panaetius.CONFIG, 'foo.bar', mask=True)
|
||||
|
||||
panaetius.logger.info(f'foo.bar set to {panaetius.CONFIG.foo_bar}')
|
||||
|
||||
# print((panaetius.CONFIG.path))
|
||||
# print(panaetius.CONFIG.logging_level)
|
||||
|
||||
panaetius.set_config(panaetius.CONFIG, 'test', mask=True)
|
||||
panaetius.logger.info(f'test_root={panaetius.CONFIG.test}')
|
||||
|
||||
print(panaetius.CONFIG.config_file)
|
||||
|
||||
# for i in panaetius.CONFIG.deferred_messages:
|
||||
# panaetius.logger.debug(i)
|
||||
|
||||
panaetius.logger.info('some logging message')
|
||||
36
tests/test_config.py
Normal file
36
tests/test_config.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import pathlib
|
||||
|
||||
import toml
|
||||
|
||||
import panaetius
|
||||
|
||||
|
||||
def test_default_config_path_set(header):
|
||||
# act
|
||||
config = panaetius.Config(header)
|
||||
|
||||
# assert
|
||||
assert str(config.config_path) == str(pathlib.Path.home() / ".config")
|
||||
|
||||
|
||||
def test_user_config_path_set(header, datadir):
|
||||
# arrange
|
||||
config_path = str(datadir / "without_logging")
|
||||
|
||||
# act
|
||||
config = panaetius.Config(header, config_path)
|
||||
|
||||
# assert
|
||||
assert str(config.config_path) == config_path
|
||||
|
||||
|
||||
def test_config_file_exists(header, datadir):
|
||||
# arrange
|
||||
config_path = str(datadir / "without_logging")
|
||||
|
||||
# act
|
||||
config = panaetius.Config(header, config_path)
|
||||
config_contents = config.config
|
||||
|
||||
# assert
|
||||
assert config._missing_config == False
|
||||
@@ -0,0 +1,12 @@
|
||||
[panaetius_testing]
|
||||
some_top_string = "some_top_value"
|
||||
|
||||
[panaetius_testing.second]
|
||||
some_second_string = "some_second_value"
|
||||
some_second_int = 1
|
||||
some_second_float = 1.0
|
||||
some_second_list = ["some", "second", "value"]
|
||||
some_second_table = { "first" = ["some", "first", "value"] }
|
||||
|
||||
# [panaetius_testing.logging]
|
||||
# path = ""
|
||||
Reference in New Issue
Block a user