From 98289618875d793eb506196fa6318e098260f59b Mon Sep 17 00:00:00 2001 From: Mateusz Krasucki Date: Tue, 12 Nov 2019 16:44:23 +0000 Subject: [PATCH] ADD converting proto standing value msg. to float - Adds method for converting protobuf standing value message to float. --- eve_glue/standing.py | 7 +++++++ setup.py | 11 ++++++++--- tests/test_standing.py | 19 +++++++++++++++++++ tox.ini | 6 ++++-- 4 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 eve_glue/standing.py create mode 100644 tests/test_standing.py diff --git a/eve_glue/standing.py b/eve_glue/standing.py new file mode 100644 index 0000000..9c15635 --- /dev/null +++ b/eve_glue/standing.py @@ -0,0 +1,7 @@ +"""Helpers for evaluating standing.""" + + +def read_standing_from_proto(standing_proto): + """Convert protobuf standing value message to float.""" + + return standing_proto.units + (standing_proto.nanos * (10**-9)) diff --git a/setup.py b/setup.py index 7b61061..1acaf34 100644 --- a/setup.py +++ b/setup.py @@ -4,11 +4,10 @@ from setuptools import setup, find_packages from setuphelpers import long_description, git_version, test_command - setup( name="eve-glue", - version="{}{}".format(git_version(), os.getenv( - "PACKAGE_VERSION_SUFFIX", "")), + version="{}{}".format(git_version(), os.getenv("PACKAGE_VERSION_SUFFIX", + "")), description="eve-glue", long_description=long_description(), cmdclass=test_command(cover="eve_glue"), @@ -16,7 +15,13 @@ author="Team Tech Co", author_email="teamtechco@ccpgames.com", url="https://github.com/ccpgames/eve-glue", + dependency_links=[ + 'https://pypi.evetech.net/pypi/eveproto', + ], setup_requires=["setuphelpers"], + tests_require=[ + 'eveproto>=0.1.80', + ], classifiers=[ "Development Status :: 3 - Alpha", "Environment :: Web Environment", diff --git a/tests/test_standing.py b/tests/test_standing.py new file mode 100644 index 0000000..e966ab4 --- /dev/null +++ b/tests/test_standing.py @@ -0,0 +1,19 @@ +"""Pytests for the eve_glue module standing.""" + +from eve_glue import standing +from eve.standing.standing_pb2 import Value as StandingValue + + +def test_read_standing_from_proto(): + """Test read standing from proto.""" + + assert standing.read_standing_from_proto( + StandingValue(units=2, nanos=232543000)) == 2.232543 + assert standing.read_standing_from_proto( + StandingValue(units=-2, nanos=-131200000)) == -2.1312 + assert standing.read_standing_from_proto( + StandingValue(units=0, nanos=-131200000)) == -0.1312 + assert standing.read_standing_from_proto( + StandingValue(units=0, nanos=131200000)) == 0.1312 + assert standing.read_standing_from_proto(StandingValue(units=0, + nanos=0)) == 0 diff --git a/tox.ini b/tox.ini index 2ffdc69..2b22a1b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,8 @@ [tox] envlist = python3.6,flake8,pylint - +indexserver = + default = https://pypi.evetech.net/pypi/ + [testenv] passenv = TEAMCITY_VERSION @@ -17,6 +19,7 @@ deps = setuphelpers >= 0.1.2 coverage == 4.5.3 teamcity-messages >= 1.25 + eveproto >= 0.1.80 commands = py.test --basetemp={envtmpdir} --cov {envsitepackagesdir}/eve_glue {env:PYTEST_ADDOPTS:} {posargs} @@ -40,7 +43,6 @@ deps = pylint == 2.3.1 setuphelpers >= 0.1.2 teamcity-messages >= 1.25 -ignore_outcome = True commands = pylint eve_glue {env:PYLINT_ADDOPTS:} [pytest]