Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate sort requirements and imports, pytest inits linters #32

Merged
merged 4 commits into from
May 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ install:

script:
- pypi-version check
- cat requirements.txt requirements-tests.txt requirements-dev.txt | safety check --stdin
- radon cc cli -nb --total-average
- ./scripts/isort-diff.sh
- cat requirements.txt requirements-tests.txt requirements-dev.txt | safety check --stdin
- bash <(curl -s https://linters.io/sort-requirements) requirements.txt requirements-tests.txt requirements-dev.txt
- bash <(curl -s https://linters.io/isort-diff) cli tests
- bash <(curl -s https://linters.io/pytest-inits) tests
- flake8 cli && flake8 tests
- coverage run -m pytest -vv tests

Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
add-trailing-comma==1.0.0
flake8==3.7.7
flake8-docstrings==1.3.0
flake8-commas==2.0.0
flake8-comprehensions==2.1.0
flake8-docstrings==1.3.0
flake8-per-file-ignores==0.8.1
isort==4.3.17
pep8-naming==0.8.2
safety==1.8.5
pypi-version==0.1.0
radon==3.0.1
safety==1.8.5
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
accessify==0.3.1
asyncio==3.4.3
click==7.0
remme==1.1.0a1
marshmallow==2.19.2
remme==1.1.0a1
13 changes: 0 additions & 13 deletions scripts/isort-diff.sh

This file was deleted.

Empty file removed tests/__init__.py
Empty file.
Empty file removed tests/account/__init__.py
Empty file.
Empty file removed tests/atomic_swap/__init__.py
Empty file.
Empty file removed tests/config/__init__.py
Empty file.
13 changes: 6 additions & 7 deletions tests/config/test_node_private_key_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@

from cli.config import NodePrivateKey
from cli.errors import NotSupportedOsToGetNodePrivateKeyError
from tests.constants import NODE_PRIVATE_KEY_FILE_PATH_IN_TESTING


def test_node_private_key_get(create_node_private_key_file):
def test_node_private_key_get(create_node_private_key_file, node_private_key_file_path):
"""
Case: get the node's private key.
Expect: private key has been read from the node's private key file.
"""
private_key = NodePrivateKey.get(file_path=NODE_PRIVATE_KEY_FILE_PATH_IN_TESTING)
private_key = NodePrivateKey.get(file_path=node_private_key_file_path)
assert '8a069bfff838f73d1b072ba72ee0f61b19d9b7216d5a735d7ff4d15063dd9772' == private_key


@pytest.mark.parametrize('operating_system', ['Darwin', 'Windows'])
def test_node_private_key_get_not_supported_os(operating_system, mocker):
def test_node_private_key_get_not_supported_os(operating_system, node_private_key_file_path, mocker):
"""
Case: get the node's private key from not supported operating system.
Expect: operating system is not supported to get the node's private key error message.
Expand All @@ -27,17 +26,17 @@ def test_node_private_key_get_not_supported_os(operating_system, mocker):
mock_account_get_balance.return_value = operating_system

with pytest.raises(NotSupportedOsToGetNodePrivateKeyError) as error:
NodePrivateKey.get(file_path=NODE_PRIVATE_KEY_FILE_PATH_IN_TESTING)
NodePrivateKey.get(file_path=node_private_key_file_path)

assert 'The current operating system is not supported to get the node\'s private key.' in error.value.message


def test_node_private_key_get_from_non_existing_file():
def test_node_private_key_get_from_non_existing_file(node_private_key_file_path):
"""
Case: get the node's private key from non-existing file.
Expect: private key hasn't been founded on the machine error message.
"""
with pytest.raises(FileNotFoundError) as error:
NodePrivateKey.get(file_path=NODE_PRIVATE_KEY_FILE_PATH_IN_TESTING)
NodePrivateKey.get(file_path=node_private_key_file_path)

assert 'Private key hasn\'t been founded on the machine.' in str(error)
14 changes: 10 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@

import pytest

from tests.constants import (
NODE_PRIVATE_KEY_DIRECTORY_PATH,
NODE_PRIVATE_KEY_FILE_PATH_IN_TESTING,
)
NODE_PRIVATE_KEY_DIRECTORY_PATH = str(pathlib.Path.home()) + '/docker/volumes/remme_validator_keys/_data/'
NODE_PRIVATE_KEY_FILE_PATH_IN_TESTING = NODE_PRIVATE_KEY_DIRECTORY_PATH + 'validator.priv'


def pytest_configure():
Expand All @@ -31,6 +29,14 @@ def pytest_configure():
sys.path.insert(0, str(pathlib.Path(__file__).parents[1]))


@pytest.fixture()
def node_private_key_file_path():
"""
Get node's private key file path.
"""
return NODE_PRIVATE_KEY_FILE_PATH_IN_TESTING


@pytest.yield_fixture()
def create_config_file():
"""
Expand Down
4 changes: 0 additions & 4 deletions tests/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
"""
Provide constants for testing a command line interface.
"""
import pathlib

NODE_PRIVATE_KEY_DIRECTORY_PATH = str(pathlib.Path.home()) + '/docker/volumes/remme_validator_keys/_data/'
NODE_PRIVATE_KEY_FILE_PATH_IN_TESTING = NODE_PRIVATE_KEY_DIRECTORY_PATH + 'validator.priv'
Empty file removed tests/generic/__init__.py
Empty file.
Empty file removed tests/generic/forms/__init__.py
Empty file.
Empty file removed tests/node/__init__.py
Empty file.
Empty file removed tests/public_key/__init__.py
Empty file.