mirror of
https://github.com/thegeeklab/docker-tidy.git
synced 2024-11-25 05:30:39 +00:00
remove py26, better pre-commit support, cleaner tox
This commit is contained in:
parent
b66adba924
commit
1b7040a432
12
.travis.yml
12
.travis.yml
@ -1,11 +1,9 @@
|
|||||||
language: python
|
language: python
|
||||||
env:
|
env:
|
||||||
- TOX_ENV=py26
|
- TOXENV=py27
|
||||||
- TOX_ENV=py27
|
- TOXENV=py33
|
||||||
- TOX_ENV=py33
|
- TOXENV=py34
|
||||||
- TOX_ENV=py34
|
|
||||||
install:
|
install:
|
||||||
- "pip install --use-mirrors tox"
|
- pip install tox
|
||||||
script:
|
script:
|
||||||
- tox -e $TOX_ENV
|
- tox
|
||||||
sudo: false
|
|
||||||
|
2
debian/rules
vendored
2
debian/rules
vendored
@ -7,7 +7,7 @@ export DH_OPTIONS
|
|||||||
dh $@ --with python-virtualenv
|
dh $@ --with python-virtualenv
|
||||||
|
|
||||||
override_dh_virtualenv:
|
override_dh_virtualenv:
|
||||||
dh_virtualenv
|
dh_virtualenv --python python2.7
|
||||||
|
|
||||||
# do not call `make clean` as part of packaging
|
# do not call `make clean` as part of packaging
|
||||||
override_dh_auto_clean:
|
override_dh_auto_clean:
|
||||||
|
@ -7,7 +7,8 @@ from pytimeparse import timeparse
|
|||||||
def timedelta_type(value):
|
def timedelta_type(value):
|
||||||
"""Return the :class:`datetime.datetime.DateTime` for a time in the past.
|
"""Return the :class:`datetime.datetime.DateTime` for a time in the past.
|
||||||
|
|
||||||
:param value: a string containing a time format supported by :mod:`pytimeparse`
|
:param value: a string containing a time format supported by
|
||||||
|
mod:`pytimeparse`
|
||||||
"""
|
"""
|
||||||
if value is None:
|
if value is None:
|
||||||
return None
|
return None
|
||||||
|
@ -77,18 +77,22 @@ def get_opts(args=None):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--max-run-time',
|
'--max-run-time',
|
||||||
type=timedelta_type,
|
type=timedelta_type,
|
||||||
help="Maximum time a container is allows to run. Time may be specified "
|
help="Maximum time a container is allows to run. Time may "
|
||||||
"in any pytimeparse supported format.")
|
"be specified in any pytimeparse supported format."
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--prefix', action="append", default=[],
|
'--prefix', action="append", default=[],
|
||||||
help="Only stop containers which match one of the "
|
help="Only stop containers which match one of the "
|
||||||
"prefix.")
|
"prefix."
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--dry-run', action="store_true",
|
'--dry-run', action="store_true",
|
||||||
help="Only log actions, don't stop anything.")
|
help="Only log actions, don't stop anything."
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-t', '--timeout', type=int, default=60,
|
'-t', '--timeout', type=int, default=60,
|
||||||
help="HTTP timeout in seconds for making docker API calls.")
|
help="HTTP timeout in seconds for making docker API calls."
|
||||||
|
)
|
||||||
opts = parser.parse_args(args=args)
|
opts = parser.parse_args(args=args)
|
||||||
|
|
||||||
if not opts.prefix:
|
if not opts.prefix:
|
||||||
|
@ -54,7 +54,12 @@ def test_has_been_running_since_false(container, earlier_time):
|
|||||||
@mock.patch('docker_custodian.docker_autostop.get_opts',
|
@mock.patch('docker_custodian.docker_autostop.get_opts',
|
||||||
autospec=True)
|
autospec=True)
|
||||||
@mock.patch('docker_custodian.docker_autostop.docker', autospec=True)
|
@mock.patch('docker_custodian.docker_autostop.docker', autospec=True)
|
||||||
def test_main(mock_docker, mock_get_opts, mock_stop_containers, mock_build_matcher):
|
def test_main(
|
||||||
|
mock_docker,
|
||||||
|
mock_get_opts,
|
||||||
|
mock_stop_containers,
|
||||||
|
mock_build_matcher
|
||||||
|
):
|
||||||
mock_get_opts.return_value.timeout = 30
|
mock_get_opts.return_value.timeout = 30
|
||||||
main()
|
main()
|
||||||
mock_get_opts.assert_called_once_with()
|
mock_get_opts.assert_called_once_with()
|
||||||
|
@ -182,7 +182,9 @@ def test_api_call_with_timeout():
|
|||||||
docker_gc.api_call(func, id)
|
docker_gc.api_call(func, id)
|
||||||
|
|
||||||
func.assert_called_once_with(id)
|
func.assert_called_once_with(id)
|
||||||
mock_log.warn.assert_called_once_with('Failed to call remove_image abcd msg')
|
mock_log.warn.assert_called_once_with(
|
||||||
|
'Failed to call remove_image abcd msg'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_api_call_with_api_error():
|
def test_api_call_with_api_error():
|
||||||
|
27
tox.ini
27
tox.ini
@ -1,30 +1,13 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist = py26,py27,py33,py34
|
envlist = py27,py33,py34
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
deps =
|
deps =
|
||||||
-rrequirements.txt
|
-rrequirements.txt
|
||||||
flake8
|
|
||||||
pytest
|
|
||||||
mock
|
mock
|
||||||
|
pre-commit
|
||||||
|
pytest
|
||||||
commands =
|
commands =
|
||||||
py.test {posargs:tests}
|
py.test {posargs:tests}
|
||||||
flake8 .
|
pre-commit install -f --install-hooks
|
||||||
|
pre-commit run --all-files
|
||||||
[testenv:py26]
|
|
||||||
deps =
|
|
||||||
-rrequirements.txt
|
|
||||||
flake8
|
|
||||||
pytest
|
|
||||||
mock < 1.1.0
|
|
||||||
|
|
||||||
[testenv:install-hooks]
|
|
||||||
deps =
|
|
||||||
pre-commit
|
|
||||||
commands =
|
|
||||||
pre-commit install
|
|
||||||
|
|
||||||
[flake8]
|
|
||||||
ignore =
|
|
||||||
exclude = .git/*,.tox/*,debian/*
|
|
||||||
max_line_length = 85
|
|
||||||
|
Loading…
Reference in New Issue
Block a user