Skip to content

Commit

Permalink
adding small unit test + travis integration for OASYS
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibault VALLOIS authored and Thibault VALLOIS committed Feb 20, 2019
1 parent f2337f7 commit c555c12
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 18 deletions.
15 changes: 10 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
dist: xenial
language: python
python:
- "3.4"
# command to install dependencies
install: "source install.sh"
# # command to run tests
script: python setup.py test
- 3.5
- 3.6
- 3.7

install:
- pip install .

script:
pytest oasys/tests
18 changes: 5 additions & 13 deletions oasys/application/addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,12 @@


def is_updatable(item):
if isinstance(item, Available):
if isinstance(item, Available) or item.installable is None:
return False
elif item.installable is None:
return False
else:
inst, dist = item
try:
v1 = version.StrictVersion(dist.version)
v2 = version.StrictVersion(inst.version)
except ValueError:
pass
else:
return v1 < v2

inst, dist = item
try:
return version.StrictVersion(dist.version) < version.StrictVersion(inst.version)
except ValueError:
return (version.LooseVersion(dist.version) <
version.LooseVersion(inst.version))

Expand Down
Empty file added oasys/tests/__init__.py
Empty file.
18 changes: 18 additions & 0 deletions oasys/tests/test_addons.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from unittest.mock import Mock
import pytest
from oasys.application.addons import is_updatable, Available, Installed, Installable


@pytest.mark.parametrize('items,expected', [
(Available(installable=True), False),
(Installed(installable=None, local=Mock()), False),
(Installed(installable=Installable(name='mock_name',
version='2.0.0',
summary='mock_summary',
description='mock_description',
package_url='mock_package_url',
release_urls='mock_release_urls'),
local=Mock(version='1.0.0')), True),
])
def test_is_updatable(items, expected):
assert is_updatable(items) == expected
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
if "darwin" in sys.platform:
INSTALL_REQUIRES = (
'setuptools',
'pytest',
'numpy>=1.16.0',
'PyQt5>=5.11.3',
'scipy',
Expand All @@ -68,6 +69,7 @@
if "debian" in platform.platform().lower(): # miniconda
INSTALL_REQUIRES = (
'setuptools',
'pytest',
'numpy>=1.16.0',
'PyQt5>=5.11.3',
'scipy',
Expand All @@ -84,6 +86,7 @@
elif "ubuntu" in platform.platform().lower(): # default python.org
INSTALL_REQUIRES = (
'setuptools',
'pytest',
'numpy>=1.16.0',
'PyQt5>=5.11.3',
'scipy',
Expand All @@ -100,6 +103,7 @@
else:
INSTALL_REQUIRES = (
'setuptools',
'pytest',
'numpy>=1.16.0',
'PyQt5>=5.11.3',
'scipy',
Expand Down

0 comments on commit c555c12

Please sign in to comment.