Skip to content

Commit 15b8041

Browse files
committed
Fix version & tests
1 parent e33300e commit 15b8041

File tree

6 files changed

+44
-58
lines changed

6 files changed

+44
-58
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,3 @@ docs/_build/
5757

5858
# PyBuilder
5959
target/
60-
61-
# Version file
62-
databox/_version.py

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ Following guidelines of http://keepachangelog.com/
33

44
## [Unreleased]
55

6+
## [2.1.2] - Sep 25, 2017
7+
- Release with fixed version
8+
69
## [2.1.1] - July 28, 2017
710
- Use setuptools_scm to extract version from Git
811

@@ -40,7 +43,8 @@ Following guidelines of http://keepachangelog.com/
4043
## [0.1] - May 20, 2015
4144
- Initial release
4245

43-
[Unreleased]: https://github.com/databox/databox-go/compare/2.1.1...master
46+
[Unreleased]: https://github.com/databox/databox-go/compare/2.1.2...master
47+
[2.1.2]: https://github.com/databox/databox-python/compare/2.1.1...2.1.2
4448
[2.1.1]: https://github.com/databox/databox-python/compare/2.1.0...2.1.1
4549
[2.1.0]: https://github.com/databox/databox-python/compare/2.0.0...2.1.0
4650
[2.0.0]: https://github.com/databox/databox-python/compare/0.1.6...2.0.0

databox test/test_push.py

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
from pprint import pprint as pp
44
from os import getenv
55

6+
RESPONSE_ID = '2837643'
67

78
def mock_push_json(data=None, path='/'):
8-
return {'id': '2837643'}
9+
return {'id': RESPONSE_ID}
910

1011

1112
class TestPush(unittest.TestCase):
@@ -16,19 +17,16 @@ def setUp(self):
1617
self.original_push_json = self.client._push_json
1718
self.client._push_json = mock_push_json
1819

20+
1921
def test_push(self):
20-
assert self.client.push("templj", 10.0) is True
21-
assert self.client.push("templj", 12.0, date="2015-01-01 09:00:00") is True
22+
assert self.client.push("templj", 10.0) is RESPONSE_ID
23+
assert self.client.push("templj", 12.0, date="2015-01-01 09:00:00") is RESPONSE_ID
2224

23-
def test_push_with_attributes(self):
24-
self.client._push_json = lambda data=None, path='/': data
2525

26-
push = self.client.push("meta", 100, attributes={
26+
def test_push_with_attributes(self):
27+
assert self.client.push("meta", 100, attributes={
2728
'n': 100
28-
})
29-
30-
assert self.client.last_push_content['data'][0]['$meta'] == 100
31-
assert self.client.last_push_content['data'][0]['n'] == 100
29+
}) is RESPONSE_ID
3230

3331

3432
def test_push_validation(self):
@@ -43,7 +41,7 @@ def test_insert_all(self):
4341
{'key': 'templj', 'value': 83.3},
4442
{'key': 'templj', 'value': 83.3, 'date': "2015-01-01 09:00:00"},
4543
{'key': 'templj', 'value': 12.3},
46-
]) is True
44+
]) is RESPONSE_ID
4745

4846
self.assertRaises(
4947
Client.KPIValidationException,
@@ -67,23 +65,3 @@ def test_last_push(self):
6765
def test_last_push_with_number(self):
6866
self.client._get_json = lambda data=None, path='/': path
6967
assert self.client.last_push(3) == '/lastpushes?limit=3'
70-
71-
72-
def test_short(self):
73-
Client._push_json = mock_push_json
74-
75-
assert push("templj", 22, token=self.databox_push_token) is True
76-
77-
assert insert_all([
78-
{
79-
'key': 'templj',
80-
'value': 83.3
81-
},
82-
], token=self.databox_push_token) is True
83-
84-
Client._get_json = lambda number=None, path='/': {
85-
'err': [],
86-
'no_err': 0
87-
}
88-
89-
assert last_push(token=self.databox_push_token)['err'] == []

databox/__init__.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import requests
2-
import pkg_resources
32
from requests.auth import HTTPBasicAuth
43
from os import getenv
54
from json import dumps as json_dumps
65

7-
_name = "databox"
8-
_version = pkg_resources.get_distribution(_name).version
9-
6+
from .__version__ import __version__
107

118
class Client(object):
129
push_token = None
@@ -61,8 +58,8 @@ def _push_json(self, data=None, path="/"):
6158
auth=HTTPBasicAuth(self.push_token, ''),
6259
headers={
6360
'Content-Type': 'application/json',
64-
'User-Agent': 'databox-python/' + _version,
65-
'Accept': 'application/vnd.databox.v' + _version.split('.')[0] + '+json'
61+
'User-Agent': 'databox-python/' + __version__,
62+
'Accept': 'application/vnd.databox.v' + __version__.split('.')[0] + '+json'
6663
},
6764
data=data
6865
)
@@ -75,8 +72,8 @@ def _get_json(self, path):
7572
auth=HTTPBasicAuth(self.push_token, ''),
7673
headers={
7774
'Content-Type': 'application/json',
78-
'User-Agent': 'databox-python/' + _version,
79-
'Accept': 'application/vnd.databox.v' + _version.split('.')[0] + '+json'
75+
'User-Agent': 'databox-python/' + __version__,
76+
'Accept': 'application/vnd.databox.v' + __version__.split('.')[0] + '+json'
8077
}
8178
)
8279

@@ -88,8 +85,8 @@ def _delete_json(self, path):
8885
auth=HTTPBasicAuth(self.push_token, ''),
8986
headers={
9087
'Content-Type': 'application/json',
91-
'User-Agent': 'databox-python/' + _version,
92-
'Accept': 'application/vnd.databox.v' + _version.split('.')[0] + '+json'
88+
'User-Agent': 'databox-python/' + __version__,
89+
'Accept': 'application/vnd.databox.v' + __version__.split('.')[0] + '+json'
9390
}
9491
)
9592

databox/__version__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
__title__ = 'databox'
2+
__version__ = '2.1.2'
3+
__description__ = 'Python wrapper for Databox - Mobile Executive Dashboard.'
4+
__url__ = 'https://github.com/databox/databox-python'
5+
__author__ = 'Databox'
6+
__author_email__ = '[email protected]'
7+
__license__ = 'MIT'

setup.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
# -*- coding: utf-8 -*-
2+
import os
3+
24
from setuptools import setup, find_packages
3-
import pkg_resources
5+
from codecs import open
6+
7+
here = os.path.abspath(os.path.dirname(__file__))
48

5-
_name = "databox"
6-
_version = pkg_resources.get_distribution(_name).version
9+
about = {}
10+
with open(os.path.join(here, 'databox', '__version__.py'), 'r', 'utf-8') as f:
11+
exec(f.read(), about)
712

813
setup(
9-
use_scm_version={'write_to': 'databox/_version.py'},
10-
setup_requires=['setuptools_scm>1.5.4'],
11-
name=_name,
12-
version=_version,
13-
author="Databox",
14-
author_email="[email protected]",
15-
description="Python wrapper for Databox - Mobile Executive Dashboard.",
16-
url="https://github.com/databox/databox-python",
17-
download_url="https://github.com/databox/databox-python/tarball/"+_version,
14+
name=about['__title__'],
15+
version=about['__version__'],
16+
author=about['__author__'],
17+
author_email=about['__author_email__'],
18+
description=about['__description__'],
19+
url=about['__url__'],
20+
download_url=about['__url__'] + "/tarball/" + about['__version__'],
1821
keywords=['databox', 'sdk', 'bi'],
19-
license='MIT',
22+
license=about['__license__'],
2023
packages=find_packages(exclude=('databox test',)),
2124
install_requires=[
2225
'requests >= 2.13'

0 commit comments

Comments
 (0)