Skip to content

Commit 6ec0548

Browse files
committed
Refactor tests and CI
1 parent d6f7070 commit 6ec0548

File tree

5 files changed

+64
-33
lines changed

5 files changed

+64
-33
lines changed

.travis.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,41 @@
11
dist: bionic
22
sudo: false
33
cache:
4-
pip: true
4+
directories:
5+
- $HOME/.cache/pip
6+
- $HOME/.cache/pipenv
57

68
language: python
79
python:
10+
# First value is default
811
- "3.5"
912
- "3.6"
1013
- "pypy3.5"
1114

1215
install:
13-
- python3 -m pip install tox tox-travis
16+
- pip install pipenv
17+
- pipenv install --dev --skip-lock
1418

1519
script:
16-
- tox
20+
- pipenv run fulltest
21+
22+
jobs:
23+
include:
24+
- stage: Test
25+
name: Test docs
26+
install:
27+
- pip install pipenv sphinx
28+
- pipenv install --skip-lock
29+
script:
30+
- pipenv run doctest
31+
- pipenv run build-docs
32+
33+
- stage: Coverage
34+
name: codecov
35+
before_script: pip install codecov
36+
script:
37+
- pytest --cov
38+
- codecov --required
1739

1840
env:
1941
secure: "ci9SGpJhSCsF3EKNpn0N0LfvCjTDAS/OMn2EIkzyh0d1mwcWX/O56osLsqYqEK+JCUIS+t1E4u99iLSABecTTotqZ8yVwpDaiyLMjwbBYJ2TdmkYvi9bYgyLVmAZ3UZUIwu2pLwTQBWN1a3ng5VQert2xSsxc9E0uNhd7GxkHkbgOMaD17mC7EPIy7e6QfYCskFn8Z+V+FTM9JRkjpnq+KOhDy5f/7H3ePEx3AvoMBW4LSYjIiQFVh+kIIbvvg7EhNdqJIcvdvkQ2M7Eqw2pj2cExB3RyRO6YQf4ie7//enXyRcCHKLTwtx1cBOSOjLqUJhkYBcm4vTBPLs11nz76sGFah+EXCGx9WcCrvUE5Zz5mcP165xpUBFKot8WEAfja+gH+5dH+3v4H86RLPwG4dE/kIz5i8R85dvZRWkKZdcaKfVYuZhij7QFqxbNLmuhyYTdw+J9vyHK7rE2ZthUNeQGgMNGtnQ56fPA5Foy0xseqxRwMvU6m7bTeFEBvXq4afTI+VSlodUYh492v9pV+LHnZ6uNJrJKCMvqLW+LVvrFJUdb0t4qH5aZ94loUtbCnipRR4vYWId5D+NqiVth6EhWypNjJCINtFaOP8NUCMBdbX8RQjZ0W0r++9q07hXvsoEVK3ofjtYnGJfqfanKqS0DmXsgH8LKyPvd75zoc9U="

Pipfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ pytest-pythonpath = "*"
1717
"flake8-quotes" = "~=0.8"
1818
"flake8-commas" = "~=0.1"
1919
"flake8_tuple" = "~=0.2"
20-
tox = "~=2.3"
2120
Sphinx = "~=1.4"
2221
sphinx-autobuild = "~=0.6"
2322

2423
[requires]
2524
python_version = "3.5"
2625

2726
[scripts]
28-
test = "pytest --flake8"
27+
test = "pytest --exitfirst --failed-first"
28+
fulltest = "pytest --flake8 --cov --no-cov-on-fail vk tests docs/conf.py"
2929
# We use equivalent of "make mode":
3030
# sphinx-build -M builder . _build
3131
docs = "sphinx-autobuild --open-browser --port 0 --delay 1 -d docs/_build/doctrees docs docs/_build/html"

setup.cfg

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,8 @@ classifiers =
2222
[options]
2323
packages = find:
2424

25-
[bdist_wheel]
26-
universal = 1
27-
2825
[tox:tox]
29-
envlist = py35, py36, pypy3
26+
envlist = py35, py36, pypy3, docs
3027
skipsdist = true
3128

3229
[testenv]
@@ -37,15 +34,26 @@ deps =
3734
pipenv<2018.7
3835
commands=
3936
pipenv install --dev --skip-lock
40-
pipenv run test
37+
pipenv run fulltest
4138
py35: pipenv run doctest
4239
py35: pipenv run build-docs
4340

41+
[testenv:docs]
42+
basepython = python3.5
43+
deps =
44+
; 2018.7.1 contains error
45+
pipenv<2018.7
46+
sphinx
47+
commands=
48+
pipenv install --skip-lock
49+
pipenv run doctest
50+
pipenv run build-docs
51+
4452
[tool:pytest]
45-
testpaths = tests docs/conf.py
53+
testpaths = tests
4654
norecursedirs =
4755
.*/
48-
doc/
56+
docs/
4957

5058
[flake8]
5159
max-line-length = 120
@@ -54,9 +62,11 @@ exclude =
5462
docs/_build/
5563

5664
[coverage:run]
65+
source = vk
5766
branch = True
58-
source =
59-
vk/
67+
68+
[coverage:report]
69+
fail_under = 50
6070

6171
[mypy]
6272
check_untyped_defs = yes

tests/auth/test_auth.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/auth/conftest.py renamed to tests/test_user_api.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
1-
import pytest
1+
from pytest import fixture, mark
22

3+
import vk
34

4-
@pytest.fixture
5+
6+
@fixture
57
def user_login():
68
return 'user-login'
79

810

9-
@pytest.fixture
11+
@fixture
1012
def user_password():
1113
return 'user-password'
1214

1315

14-
@pytest.fixture
16+
@fixture
1517
def app_id():
1618
return 'app-id'
1719

1820

19-
@pytest.fixture
21+
@fixture
2022
def scope():
2123
return 'scope'
2224

2325

24-
@pytest.fixture(autouse=True)
26+
@fixture(autouse=True)
2527
def mock_requests_session(monkeypatch, user_login, user_password, access_token, response_class, session_class):
2628

2729
class MockedSession(session_class):
@@ -47,3 +49,13 @@ def mocked_request(self, method, url, **kwargs):
4749
raise NotImplementedError
4850

4951
monkeypatch.setattr('requests.Session', MockedSession)
52+
53+
54+
@mark.skip
55+
def test_login(user_login, user_password, app_id, scope, access_token):
56+
57+
api = vk.API(user_login=user_login, user_password=user_password, app_id=app_id, scope=scope)
58+
assert 'access_token' not in api._session.method_default_params
59+
60+
api._session.update_access_token()
61+
assert api._session.method_default_params.get('access_token') == access_token

0 commit comments

Comments
 (0)