Skip to content

Commit

Permalink
Pre merge code quality checks (#72)
Browse files Browse the repository at this point in the history
* fix files with flake8

* bump version for per merge checks
  • Loading branch information
circa10a authored Dec 30, 2018
1 parent db75750 commit 5f6357b
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 15 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ tests/
.coveragerc
.travis.yml
doc/
.flake8
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
ignore = E501
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:

script:
- ./run_tests.sh
- flake8

after_script:
- codecov
Expand Down
3 changes: 2 additions & 1 deletion dev-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ dependencies:
- pytest
- pytest-cov
- pytest-mock
- codecov
- codecov
- flake8
5 changes: 2 additions & 3 deletions ouroboros/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def checkURI(uri):
"""Validate tcp:// regex"""
regex = re.compile( r"""(?xi) # "verbose" mode & case-insensitive
regex = re.compile(r"""(?xi) # "verbose" mode & case-insensitive
\A # in the beginning...
tcps?:// # tcp or tcps protocol
(?: # hostname / IP address
Expand Down Expand Up @@ -46,8 +46,7 @@ def get_int_env_var(env_var):
def parse(sysargs):
"""Declare command line options"""
parser = argparse.ArgumentParser(description='ouroboros',
epilog='Example: ouroboros -u tcp://1.2.3.4:5678'
+ '-i 20 -m container1 container2 -l warn')
epilog='Example: ouroboros -u tcp://1.2.3.4:5678 -i 20 -m container1 container2 -l warn')

parser.add_argument('-u', '--url', default=defaults.LOCAL_UNIX_SOCKET,
help='Url for tcp host (defaults to "unix://var/run/docker.sock")')
Expand Down
3 changes: 2 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ requests
pytest
pytest-cov
pytest-mock
codecov
codecov
flake8
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def read_reqs(requirements):

setup(
name='ouroboros-cli',
version='0.4.0',
version='0.4.1',
description='Automatically update running docker containers',
long_description=readme(),
long_description_content_type='text/markdown',
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/_metrics_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest
from prometheus_client import REGISTRY
import ouroboros.metrics as metrics

Expand All @@ -14,4 +13,4 @@ def test_monitored_containers():
test_count = 5.0
metrics.monitored_containers(num=test_count)
num_monitored = REGISTRY.get_sample_value('containers_being_monitored')
assert num_monitored == test_count
assert num_monitored == test_count
1 change: 1 addition & 0 deletions tests/unit/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def test_metrics_port_arg_invalid_value(mocker):
cli.parse(['--metrics-port', 'test'])
assert pytest_wrapped_e.type == SystemExit


# Webhooks
@pytest.mark.parametrize('webhook_args, webhook_result', [
(['-w', 'http://my-webhook-1 ', 'http://my-webhook-2', 'http://my-webhook-3'], ['http://my-webhook-1 ', 'http://my-webhook-2', 'http://my-webhook-3']),
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/container_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,4 @@
}
}
}
}
}
1 change: 1 addition & 0 deletions tests/unit/container_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import ouroboros.defaults
import logging


@pytest.fixture()
def fake_container():
return container_object
Expand Down
1 change: 1 addition & 0 deletions tests/unit/defaults_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
import ouroboros.defaults as defaults


@pytest.mark.parametrize('default, result', [
(defaults.INTERVAL, 300),
(defaults.LOCAL_UNIX_SOCKET, 'unix://var/run/docker.sock'),
Expand Down
1 change: 0 additions & 1 deletion tests/unit/image_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest
import ouroboros.image as image
import docker

Expand Down
1 change: 1 addition & 0 deletions tests/unit/logger_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
import ouroboros.logger as log


@pytest.mark.parametrize('level_string, level_code', [
('debug', 10),
('info', 20),
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/main_unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ def test_main_full(fake_namespace, fake_api, caplog):
fake_namespace.keep_tag = True
fake_namespace.webhook_urls = ["http://testurl1"]

fake_api.inspect_container.return_value = container_object # called twice
fake_api.containers.return_value = [container_object] # called twice
fake_api.inspect_container.return_value = container_object # called twice
fake_api.containers.return_value = [container_object] # called twice
fake_api.inspect_image.side_effect = [{'RepoTags': ["repo:1.1"],
'Id': '1'},
{'RepoTags': ["repo:latest"],
'Id': '2'}] # called twice
'Id': '2'}] # called twice
fake_api.create_container.return_value = {'Id': '2'}

with pytest.raises(SystemExit) as e:
Expand Down Expand Up @@ -71,7 +71,7 @@ def test_main_exception(fake_namespace, fake_api, caplog):

fake_api.inspect_container.return_value = container_object # called twice
fake_api.containers.return_value = [container_object] # called twice
fake_api.inspect_image.return_value = {'RepoTags': ["repo:1.1"], 'Id': '1'} # called once
fake_api.inspect_image.return_value = {'RepoTags': ["repo:1.1"], 'Id': '1'} # called once

fake_api.pull.side_effect = docker.errors.APIError("I blew up!!")
fake_api.create_container.return_value = {'Id': '2'}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/webhook_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import requests
import ouroboros.webhook as webhook


def test_webook_schema_error():
with pytest.raises(Exception):
assert webhook.post(urls=['http:/my-false-url'], container_name='test_name', old_sha='1', new_sha='2')

0 comments on commit 5f6357b

Please sign in to comment.