Skip to content

Commit

Permalink
ADD converting proto standing value msg. to float
Browse files Browse the repository at this point in the history
- Adds method for converting protobuf standing value message to float.
  • Loading branch information
mateuszkrasucki committed Nov 12, 2019
1 parent 3b4d959 commit 9828961
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
7 changes: 7 additions & 0 deletions eve_glue/standing.py
Original file line number Diff line number Diff line change
@@ -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))
11 changes: 8 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@
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"),
packages=find_packages(),
author="Team Tech Co",
author_email="[email protected]",
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",
Expand Down
19 changes: 19 additions & 0 deletions tests/test_standing.py
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[tox]
envlist = python3.6,flake8,pylint

indexserver =
default = https://pypi.evetech.net/pypi/

[testenv]
passenv =
TEAMCITY_VERSION
Expand All @@ -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}

Expand All @@ -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]
Expand Down

0 comments on commit 9828961

Please sign in to comment.