Skip to content

Commit

Permalink
tox: Update depedencies and fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Signed-off-by: Jonathas-Conceicao <jonathas.conceicao@ossystems.com.br>
  • Loading branch information
otavio authored and Jonathas-Conceicao committed Apr 27, 2020
1 parent 540a6de commit e88244d
Show file tree
Hide file tree
Showing 17 changed files with 66 additions and 57 deletions.
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
junit_family=xunit1
filterwarnings = ignore:.*pep8.*
28 changes: 28 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[metadata]
name = uhu
description = "UpdateHub's firmware update package management utilities"
long_description = file: foo.md
long_description_content_type = text/markdown
keywords=industrial-linux, embedded-linux, embedded, firmware-updates, linux, update-service
author = O.S. Systems Software LTDA
author_mail = contato@ossystems.com.br
url = http://www.ossystems.com.br
license = GPL-2.0

[options]
zip_safe = False
python_requires = >=3.4
install_requires =
click >= 6.5
humanize >= 0.5.1
progress >= 1.1
prompt-toolkit >=2.0.0, <3.0.0
pycryptodomex
requests >= 2.20.0
rfc3987 >= 1.3
updatehub-package-schema >= 1.0.3

[options.entry_points]
console_scripts =
uhu=uhu.cli:cli

22 changes: 0 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,7 @@

from uhu import get_version


setup(
name='uhu',
description="UpdateHub's firmware update package management utilities",
keywords='industrial-linux embedded-linux embedded firmware-updates linux update-service', # nopep8
version=get_version(),
packages=find_packages(exclude=['tests*']),
entry_points={
'console_scripts': ['uhu=uhu.cli:cli']
},
install_requires=[
'click>=6.5',
'humanize>=0.5.1',
'progress>=1.1',
'prompt-toolkit>=2.0.0,<3.0.0',
'pycrypto',
'updatehub-package-schema>=1.0.3',
'requests>=2.20.0',
'rfc3987>=1.3',
],
author='O.S. Systems Software LTDA',
author_email='contato@ossystems.com.br',
url='http://www.ossystems.com.br',
license='GPL-2.0',
zip_safe=False,
)
6 changes: 3 additions & 3 deletions tests/core/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import unittest
from unittest.mock import patch

from Crypto.PublicKey import RSA
from Crypto.Hash import SHA256
from Crypto.Signature import PKCS1_v1_5
from Cryptodome.PublicKey import RSA
from Cryptodome.Hash import SHA256
from Cryptodome.Signature import PKCS1_v1_5
from pkgschema import ValidationError

from uhu.core.hardware import SupportedHardwareManager
Expand Down
6 changes: 3 additions & 3 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import unittest
from unittest.mock import patch

from Crypto.Hash import SHA256
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5
from Cryptodome.Hash import SHA256
from Cryptodome.PublicKey import RSA
from Cryptodome.Signature import PKCS1_v1_5

from uhu import utils

Expand Down
17 changes: 9 additions & 8 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
[tox]
envlist = py34, py35, py36
envlist = py35, py36, py37, py38

[testenv]
deps =
pylint==1.7.*
pytest==2.9.1
pytest-cov==2.2.1
pytest-pep8==1.0.6
pylint==2.4.*
pytest==5.4.*
pytest-pep8==1.0.*
pytest-cov==2.5.*
requests>=2
pycrypto==2.6.1
pycryptodomex==3.9.*
commands =
py.test \
--cov={envsitepackagesdir}/uhu \
--cov-report=xml \
--cov-report=term-missing \
--junitxml=test-report.xml \
--pep8 \
{posargs}
pylint uhu
pylint \
-d R1710 \
uhu
2 changes: 1 addition & 1 deletion uhu/core/_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def get(cls, name):

@classmethod
def names(cls):
return sorted([mode for mode in cls.registry])
return sorted(list(cls.registry))


class ObjectType(type):
Expand Down
2 changes: 1 addition & 1 deletion uhu/core/_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get(cls, name):

@classmethod
def all(cls):
return [option for option in cls.registry.values()]
return list(cls.registry.values())


class OptionType(type):
Expand Down
10 changes: 5 additions & 5 deletions uhu/core/install_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ def get_version(fn, type_, **kwargs):
with open(fn, 'rb') as fp:
if type_ == 'linux-kernel':
return get_kernel_version(fp)
elif type_ == 'u-boot':
if type_ == 'u-boot':
return get_uboot_version(fp)
elif type_ == 'regexp':
if type_ == 'regexp':
kwargs = {k: v for k, v in kwargs.items() if v is not None}
return get_object_version(fp, **kwargs)

Expand Down Expand Up @@ -249,9 +249,9 @@ def __init__(self, metadata):
def to_metadata(self):
if self.condition == self.CONTENT_DIVERGES:
return self._format_metadata('sha256sum')
elif self.condition == self.VERSION_DIVERGES:
if self.condition == self.VERSION_DIVERGES:
return self._metadata_version_diverges()
elif self.condition == self.ALWAYS:
if self.condition == self.ALWAYS:
return {}
raise ValueError('Invalid install-condition condition.')

Expand All @@ -260,7 +260,7 @@ def _metadata_version_diverges(self):
'install-condition-pattern-type', None)
if self.pattern in KNOWN_PATTERNS:
return self._metadata_known_pattern()
elif self.pattern == CUSTOM_PATTERN:
if self.pattern == CUSTOM_PATTERN:
return self._metadata_custom_pattern()
raise ValueError('Unknown install-condition pattern type.')

Expand Down
2 changes: 1 addition & 1 deletion uhu/core/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ._object import Modes


class Object: # pylint: disable=too-few-public-methods
class Object: # pylint: disable=too-few-public-methods, self-cls-assignment

def __new__(cls, options):
opts = deepcopy(options)
Expand Down
1 change: 0 additions & 1 deletion uhu/core/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,3 @@ def _objects_to_str(objects):

class DuplicateObjectEntryError(Exception):
"""Exception raised upon an attempt to add an existing package."""
pass
4 changes: 2 additions & 2 deletions uhu/core/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ class InstallConditionOption(StringOption):
def humanize(cls, value):
if value == 'always':
return 'always install'
elif value == 'content-diverges':
if value == 'content-diverges':
return 'install when CONTENT diverges'
elif value == 'version-diverges':
if value == 'version-diverges':
return 'install when VERSION diverges'


Expand Down
3 changes: 2 additions & 1 deletion uhu/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from ..config import config
from ..utils import sign_dict

from .package import Package


def dump_package(package, fn):
"""Dumps a package into a file."""
Expand All @@ -21,7 +23,6 @@ def dump_package(package, fn):

def load_package(fn):
"""Loads a package from package dump file."""
from .package import Package
with open(fn) as fp:
dump = json.load(fp, object_pairs_hook=OrderedDict)
return Package(dump=dump)
Expand Down
1 change: 0 additions & 1 deletion uhu/repl/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

class CancelPromptException(Exception):
"""Exception that must be raised when user types Ctrl C."""
pass


class ValidationError(ValidationError): # pylint: disable=function-redefined
Expand Down
8 changes: 4 additions & 4 deletions uhu/repl/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ def _get_object_option_value_completer(option, obj=None):
"""Retuns a completer for object_option_value prompt."""
if option.choices:
return ObjectOptionValueCompleter(option)
elif option.type_name == 'boolean':
if option.type_name == 'boolean':
return YesNoCompleter()
elif option.metadata == 'filename':
if option.metadata == 'filename':
return ObjectFilenameCompleter()
elif option.metadata == 'target-type':
if option.metadata == 'target-type':
return WordCompleter(obj.target_types)


Expand Down Expand Up @@ -255,7 +255,7 @@ def prompt_installation_set(package, msg=None):
if package.objects.is_single():
return None

objects = [(index, objs) for index, objs in enumerate(package.objects)]
objects = list(enumerate(package.objects))
indexes = [str(i) for i, _ in objects]

msg = msg if msg is not None else 'Select an installation set: '
Expand Down
2 changes: 1 addition & 1 deletion uhu/updatehub/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def request(method, url, *args, sign=True, **kwargs):
raise HTTPError(UNKNOWN_ERROR)
if response.status_code == 401:
raise HTTPError('Unautorized. Did you set your credentials?')
elif not response.ok:
if not response.ok:
raise HTTPError(format_server_error(response))
return response

Expand Down
6 changes: 3 additions & 3 deletions uhu/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import json
import os

from Crypto.Hash import SHA256
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5
from Cryptodome.Hash import SHA256
from Cryptodome.PublicKey import RSA
from Cryptodome.Signature import PKCS1_v1_5


# Environment variables
Expand Down

0 comments on commit e88244d

Please sign in to comment.