Skip to content

Commit 153be06

Browse files
authored
bugfix/setup travis
* docs in package * noqa for init * complete MANIFEST * fix test: call cannot be imported directly with pytest * enable report cov report generation * bump version * bump version * add coveragerc to pkg * parse date with tz * fix tests: expiration now handles tz
1 parent 502a2f7 commit 153be06

File tree

10 files changed

+49
-31
lines changed

10 files changed

+49
-31
lines changed

.coveragerc

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[paths]
2+
source = src
3+
4+
[run]
5+
branch = true
6+
source =
7+
src
8+
tests
9+
parallel = true
10+
11+
[report]
12+
show_missing = true
13+
precision = 2

.travis.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
language: python
22
sudo: false
33
cache: pip
4-
env:
5-
matrix:
6-
- TOXENV=check
7-
- TOXENV=docs
84
matrix:
95
include:
10-
- python: '3.6'
6+
- python: '3.5'
117
env:
128
- TOXENV=python3-cover,report
13-
- python: '3.7'
9+
- python: '3.6'
1410
env:
1511
- TOXENV=python3-cover,report
1612
before_install:

CHANGELOG.rst

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
0.2.1 (2018-03-28)
5+
------------------
6+
7+
* fix tests, cov report, MANIFEST.in
8+
9+
410
0.1.1 (2018-03-02)
511
------------------
612

MANIFEST.in

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ graft tests
44
include Pipfile
55
include Pipfile.lock
66

7-
include CHANGELOG.md
8-
include README.md
7+
include .coveragerc
8+
9+
include CHANGELOG.rst
10+
include README.rst
911
include LICENSE
1012
include requirements.txt
1113
include test-requirements.txt
1214

13-
include tox.ini
14-
include setup.cfg
15+
include tox.ini .travis.yml
1516

1617
global-exclude *.py[cod] __pycache__ *.so *.dylib
17-
18+
exclude .pytest_cache

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
aiohttp==3.0.0
22
simplejson==3.13.2
33
simple-rest-client==0.5.0
4+
python-dateutil==2.7.2

setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import io
22
import re
3-
from setuptools import setup, find_packages
43
from os.path import join, dirname, abspath
4+
from setuptools import setup, find_packages
55

66

77
def read(name):
@@ -13,7 +13,7 @@ def read(name):
1313

1414
setup(
1515
name="AsyncOpenStackClient",
16-
version="0.2.0",
16+
version="0.2.1",
1717
author='Dreamlab - PaaS KRK',
1818
author_email='[email protected]',
1919
url='https://github.com/DreamLab/AsyncOpenStackClient',

src/asyncopenstackclient/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from .client import Client
2-
from .nova import NovaClient
3-
from .glance import GlanceClient
4-
from .auth import AuthPassword
1+
from .auth import AuthPassword # noqa
2+
from .client import Client # noqa
3+
from .glance import GlanceClient # noqa
4+
from .nova import NovaClient # noqa
55

66
__all__ = ['NovaClient', 'GlanceClient', 'AuthPassword']

src/asyncopenstackclient/auth.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from time import time, strptime, mktime
21
import aiohttp
2+
from dateutil import parser
3+
from time import time
34

45

56
class AuthModel:
@@ -51,7 +52,7 @@ async def get_token(self):
5152
result = await response.json()
5253
return (
5354
response.headers['X-Subject-Token'],
54-
mktime(strptime(result['token']['expires_at'], "%Y-%m-%dT%H:%M:%S.000000Z")),
55+
parser.parse(result['token']['expires_at']).timestamp(),
5556
result['token']['catalog']
5657
)
5758

tests/test_auth.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from unittest.mock import patch
2-
from aiounittest import AsyncTestCase, futurized
31
from aioresponses import aioresponses
2+
from aiounittest import AsyncTestCase, futurized
43
from asyncopenstackclient import AuthPassword
4+
from unittest.mock import patch
55

66

77
class TestAuth(AsyncTestCase):
@@ -40,7 +40,7 @@ async def test_get_token(self):
4040

4141
res = await self.auth.get_token()
4242

43-
self.assertEqual(res, (headers["X-Subject-Token"], 0, body["token"]["catalog"]))
43+
self.assertEqual(res, (headers["X-Subject-Token"], 3600, body["token"]["catalog"]))
4444

4545
def test_get_endpoint_url_existing_endpoint(self):
4646
self.auth.endpoints = [

tests/test_client.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from unittest.mock import patch, Mock, call, ANY
21
from aiounittest import AsyncTestCase, futurized
32
from asyncopenstackclient import Client
3+
from unittest import mock
44

55

66
class TestClient(AsyncTestCase):
@@ -9,7 +9,7 @@ def setUp(self):
99
pass
1010

1111
def tearDown(self):
12-
patch.stopall()
12+
mock.patch.stopall()
1313

1414
def test_create_object(self):
1515
api_name = 'mock_api'
@@ -28,7 +28,7 @@ def test_create_object_bad_session(self):
2828
Client('mock_name', 'mock_version', session=None)
2929

3030
async def test_get_credentials(self):
31-
session = Mock()
31+
session = mock.Mock()
3232
session.authenticate.return_value = futurized(None)
3333
session.get_endpoint_url.return_value = futurized("mock_url")
3434

@@ -38,13 +38,13 @@ async def test_get_credentials(self):
3838
self.assertEqual(client.api_url, "mock_url")
3939

4040
async def test_init_api(self):
41-
session = Mock()
41+
session = mock.Mock()
4242
session.authenticate.return_value = futurized(None)
4343
session.get_endpoint_url.return_value = futurized("mock_url")
4444
session.token = 'mock_token'
45-
mock_api = Mock()
45+
mock_api = mock.Mock()
4646

47-
patch('asyncopenstackclient.client.API', new_callable=mock_api).start()
47+
mock.patch('asyncopenstackclient.client.API', new_callable=mock_api).start()
4848

4949
client = Client("mock_name", ['mock', 'resource', 'list'], session=session)
5050
await client.init_api()
@@ -56,7 +56,7 @@ async def test_init_api(self):
5656
)
5757

5858
mock_api()().add_resource.assert_has_calls([
59-
call(resource_name='mock', resource_class=ANY),
60-
call(resource_name='resource', resource_class=ANY),
61-
call(resource_name='list', resource_class=ANY),
59+
mock.call(resource_name='mock', resource_class=mock.ANY),
60+
mock.call(resource_name='resource', resource_class=mock.ANY),
61+
mock.call(resource_name='list', resource_class=mock.ANY),
6262
])

0 commit comments

Comments
 (0)