mirror of
https://github.com/thegeeklab/docker-tidy.git
synced 2024-11-21 19:50:40 +00:00
refactor: rename modules to reflect pep8 recommendations (#19)
This commit is contained in:
parent
ab5823c8c9
commit
4a6e468e1f
@ -6,9 +6,9 @@ import docker.errors
|
||||
import requests.exceptions
|
||||
|
||||
import docker
|
||||
from dockertidy.Config import SingleConfig
|
||||
from dockertidy.Logger import SingleLog
|
||||
from dockertidy.Parser import timedelta
|
||||
from dockertidy.config import SingleConfig
|
||||
from dockertidy.logger import SingleLog
|
||||
from dockertidy.parser import timedelta
|
||||
|
||||
|
||||
class AutoStop:
|
@ -3,13 +3,13 @@
|
||||
|
||||
import argparse
|
||||
|
||||
import dockertidy.Exception
|
||||
import dockertidy.exception
|
||||
from dockertidy import __version__
|
||||
from dockertidy.Autostop import AutoStop
|
||||
from dockertidy.Config import SingleConfig
|
||||
from dockertidy.GarbageCollector import GarbageCollector
|
||||
from dockertidy.Logger import SingleLog
|
||||
from dockertidy.Parser import timedelta_validator
|
||||
from dockertidy.autostop import AutoStop
|
||||
from dockertidy.config import SingleConfig
|
||||
from dockertidy.garbage_collector import GarbageCollector
|
||||
from dockertidy.logger import SingleLog
|
||||
from dockertidy.parser import timedelta_validator
|
||||
|
||||
|
||||
class DockerTidy:
|
||||
@ -124,7 +124,7 @@ class DockerTidy:
|
||||
def _get_config(self):
|
||||
try:
|
||||
config = SingleConfig(args=self.args)
|
||||
except dockertidy.Exception.ConfigError as e:
|
||||
except dockertidy.exception.ConfigError as e:
|
||||
self.log.sysexit_with_message(e)
|
||||
|
||||
try:
|
@ -10,11 +10,11 @@ import ruamel.yaml
|
||||
from appdirs import AppDirs
|
||||
from jsonschema._utils import format_as_index
|
||||
|
||||
import dockertidy.Exception
|
||||
import dockertidy.Parser
|
||||
from dockertidy.Parser import env
|
||||
from dockertidy.Utils import Singleton
|
||||
from dockertidy.Utils import dict_intersect
|
||||
import dockertidy.exception
|
||||
import dockertidy.parser
|
||||
from dockertidy.parser import env
|
||||
from dockertidy.utils import Singleton
|
||||
from dockertidy.utils import dict_intersect
|
||||
|
||||
config_dir = AppDirs("docker-tidy").user_config_dir
|
||||
default_config_file = os.path.join(config_dir, "config.yml")
|
||||
@ -162,7 +162,7 @@ class Config():
|
||||
if '"{}" not set'.format(envname) in str(e):
|
||||
pass
|
||||
else:
|
||||
raise dockertidy.Exception.ConfigError(
|
||||
raise dockertidy.exception.ConfigError(
|
||||
"Unable to read environment variable", str(e)
|
||||
)
|
||||
|
||||
@ -194,7 +194,7 @@ class Config():
|
||||
normalized = ruamel.yaml.safe_load(s)
|
||||
except (ruamel.yaml.composer.ComposerError, ruamel.yaml.scanner.ScannerError) as e:
|
||||
message = "{} {}".format(e.context, e.problem)
|
||||
raise dockertidy.Exception.ConfigError(
|
||||
raise dockertidy.exception.ConfigError(
|
||||
"Unable to read config file {}".format(config), message
|
||||
)
|
||||
|
||||
@ -236,7 +236,7 @@ class Config():
|
||||
schema=format_as_index(list(e.relative_schema_path)[:-1]),
|
||||
message=e.message
|
||||
)
|
||||
raise dockertidy.Exception.ConfigError("Configuration error", schema_error)
|
||||
raise dockertidy.exception.ConfigError("Configuration error", schema_error)
|
||||
|
||||
return True
|
||||
|
@ -9,9 +9,9 @@ import docker.errors
|
||||
import requests.exceptions
|
||||
|
||||
import docker
|
||||
from dockertidy.Config import SingleConfig
|
||||
from dockertidy.Logger import SingleLog
|
||||
from dockertidy.Parser import timedelta
|
||||
from dockertidy.config import SingleConfig
|
||||
from dockertidy.logger import SingleLog
|
||||
from dockertidy.parser import timedelta
|
||||
|
||||
|
||||
class GarbageCollector:
|
@ -8,8 +8,8 @@ import sys
|
||||
import colorama
|
||||
from pythonjsonlogger import jsonlogger
|
||||
|
||||
from dockertidy.Utils import Singleton
|
||||
from dockertidy.Utils import to_bool
|
||||
from dockertidy.utils import Singleton
|
||||
from dockertidy.utils import to_bool
|
||||
|
||||
CONSOLE_FORMAT = "{}[%(levelname)s]{} %(message)s"
|
||||
JSON_FORMAT = "(asctime) (levelname) (message)"
|
@ -3,7 +3,7 @@
|
||||
import pytest
|
||||
|
||||
import docker
|
||||
from dockertidy import Autostop
|
||||
from dockertidy import autostop
|
||||
|
||||
pytest_plugins = [
|
||||
"dockertidy.test.fixtures.fixtures",
|
||||
@ -11,28 +11,28 @@ pytest_plugins = [
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def autostop(mocker):
|
||||
def autostop_fixture(mocker):
|
||||
mocker.patch.object(
|
||||
Autostop.AutoStop,
|
||||
autostop.AutoStop,
|
||||
"_get_docker_client",
|
||||
return_value=mocker.create_autospec(docker.APIClient)
|
||||
)
|
||||
|
||||
stop = Autostop.AutoStop()
|
||||
stop = autostop.AutoStop()
|
||||
return stop
|
||||
|
||||
|
||||
def test_stop_container(autostop, mocker):
|
||||
def test_stop_container(autostop_fixture, mocker):
|
||||
client = mocker.create_autospec(docker.APIClient)
|
||||
cid = "asdb"
|
||||
|
||||
autostop._stop_container(client, cid)
|
||||
autostop_fixture._stop_container(client, cid)
|
||||
client.stop.assert_called_once_with(cid)
|
||||
|
||||
|
||||
def test_build_container_matcher(autostop, mocker):
|
||||
def test_build_container_matcher(autostop_fixture, mocker):
|
||||
prefixes = ["one_", "two_"]
|
||||
matcher = autostop._build_container_matcher(prefixes)
|
||||
matcher = autostop_fixture._build_container_matcher(prefixes)
|
||||
|
||||
assert matcher("one_container")
|
||||
assert matcher("two_container")
|
||||
@ -40,9 +40,9 @@ def test_build_container_matcher(autostop, mocker):
|
||||
assert not matcher("one")
|
||||
|
||||
|
||||
def test_has_been_running_since_true(autostop, container, later_time):
|
||||
assert autostop._has_been_running_since(container, later_time)
|
||||
def test_has_been_running_since_true(autostop_fixture, container, later_time):
|
||||
assert autostop_fixture._has_been_running_since(container, later_time)
|
||||
|
||||
|
||||
def test_has_been_running_since_false(autostop, container, earlier_time):
|
||||
assert not autostop._has_been_running_since(container, earlier_time)
|
||||
def test_has_been_running_since_false(autostop_fixture, container, earlier_time):
|
||||
assert not autostop_fixture._has_been_running_since(container, earlier_time)
|
||||
|
@ -4,7 +4,7 @@ import pytest
|
||||
import requests
|
||||
|
||||
import docker
|
||||
from dockertidy import GarbageCollector
|
||||
from dockertidy import garbage_collector
|
||||
|
||||
pytest_plugins = [
|
||||
"dockertidy.test.fixtures.fixtures",
|
||||
@ -14,12 +14,12 @@ pytest_plugins = [
|
||||
@pytest.fixture
|
||||
def gc(mocker):
|
||||
mocker.patch.object(
|
||||
GarbageCollector.GarbageCollector,
|
||||
garbage_collector.GarbageCollector,
|
||||
"_get_docker_client",
|
||||
return_value=mocker.create_autospec(docker.APIClient)
|
||||
)
|
||||
|
||||
gc = GarbageCollector.GarbageCollector()
|
||||
gc = garbage_collector.GarbageCollector()
|
||||
return gc
|
||||
|
||||
|
||||
|
6
poetry.lock
generated
6
poetry.lock
generated
@ -362,7 +362,7 @@ python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "isort"
|
||||
version = "5.6.4"
|
||||
version = "5.7.0"
|
||||
description = "A Python utility / library to sort Python imports."
|
||||
category = "dev"
|
||||
optional = false
|
||||
@ -976,8 +976,8 @@ ipaddress = [
|
||||
{file = "ipaddress-1.0.23.tar.gz", hash = "sha256:b7f8e0369580bb4a24d5ba1d7cc29660a4a6987763faf1d8a8046830e020e7e2"},
|
||||
]
|
||||
isort = [
|
||||
{file = "isort-5.6.4-py3-none-any.whl", hash = "sha256:dcab1d98b469a12a1a624ead220584391648790275560e1a43e54c5dceae65e7"},
|
||||
{file = "isort-5.6.4.tar.gz", hash = "sha256:dcaeec1b5f0eca77faea2a35ab790b4f3680ff75590bfcb7145986905aab2f58"},
|
||||
{file = "isort-5.7.0-py3-none-any.whl", hash = "sha256:fff4f0c04e1825522ce6949973e83110a6e907750cd92d128b0d14aaaadbffdc"},
|
||||
{file = "isort-5.7.0.tar.gz", hash = "sha256:c729845434366216d320e936b8ad6f9d681aab72dc7cbc2d51bedc3582f3ad1e"},
|
||||
]
|
||||
jsonschema = [
|
||||
{file = "jsonschema-3.2.0-py2.py3-none-any.whl", hash = "sha256:4e5b3cf8216f577bee9ce139cbe72eca3ea4f292ec60928ff24758ce626cd163"},
|
||||
|
@ -77,7 +77,7 @@ pytest-mock = "^3.3.1"
|
||||
yapf = "^0.30.0"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
docker-tidy = "dockertidy.Cli:main"
|
||||
docker-tidy = "dockertidy.cli:main"
|
||||
|
||||
[tool.poetry-dynamic-versioning]
|
||||
enable = true
|
||||
@ -92,7 +92,7 @@ sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
|
||||
skip_glob = ["**/.env*", "**/env/*", "**/docs/*"]
|
||||
|
||||
[tool.pytest.ini_options]
|
||||
addopts = "--cov=dockertidy --cov-report xml:coverage.xml --cov-append --no-cov-on-fail"
|
||||
addopts = "dockertidy --cov=dockertidy --cov-report=xml:coverage.xml --cov-report=term --cov-append --no-cov-on-fail"
|
||||
filterwarnings = [
|
||||
"ignore::FutureWarning",
|
||||
"ignore:.*collections.*:DeprecationWarning",
|
||||
|
Loading…
Reference in New Issue
Block a user