Merge pull request #342 from pylast/cover-tests
Include tests in coverage
This commit is contained in:
commit
77c17a9c36
|
@ -1,6 +1,6 @@
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
rev: v2.6.1
|
rev: v2.7.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
args: ["--py3-plus"]
|
args: ["--py3-plus"]
|
||||||
|
@ -26,17 +26,17 @@ repos:
|
||||||
- id: seed-isort-config
|
- id: seed-isort-config
|
||||||
|
|
||||||
- repo: https://github.com/timothycrosley/isort
|
- repo: https://github.com/timothycrosley/isort
|
||||||
rev: 4.3.21
|
rev: 5.4.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: isort
|
- id: isort
|
||||||
|
|
||||||
- repo: https://github.com/pre-commit/pygrep-hooks
|
- repo: https://github.com/pre-commit/pygrep-hooks
|
||||||
rev: v1.5.1
|
rev: v1.6.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: python-check-blanket-noqa
|
- id: python-check-blanket-noqa
|
||||||
|
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v3.1.0
|
rev: v3.2.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: check-merge-conflict
|
- id: check-merge-conflict
|
||||||
- id: check-yaml
|
- id: check-yaml
|
||||||
|
|
|
@ -153,11 +153,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
||||||
# Assert
|
# Assert
|
||||||
tags = artist.get_tags()
|
tags = artist.get_tags()
|
||||||
assert len(tags) > 0
|
assert len(tags) > 0
|
||||||
found = False
|
found = any(tag.name == "testing" for tag in tags)
|
||||||
for tag in tags:
|
|
||||||
if tag.name == "testing":
|
|
||||||
found = True
|
|
||||||
break
|
|
||||||
assert found
|
assert found
|
||||||
|
|
||||||
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
|
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
|
||||||
|
@ -172,11 +168,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
tags = artist.get_tags()
|
tags = artist.get_tags()
|
||||||
found = False
|
found = any(tag.name == "testing" for tag in tags)
|
||||||
for tag in tags:
|
|
||||||
if tag.name == "testing":
|
|
||||||
found = True
|
|
||||||
break
|
|
||||||
assert not found
|
assert not found
|
||||||
|
|
||||||
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
|
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
|
||||||
|
@ -191,11 +183,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
tags = artist.get_tags()
|
tags = artist.get_tags()
|
||||||
found = False
|
found = any(tag.name == "testing" for tag in tags)
|
||||||
for tag in tags:
|
|
||||||
if tag.name == "testing":
|
|
||||||
found = True
|
|
||||||
break
|
|
||||||
assert not found
|
assert not found
|
||||||
|
|
||||||
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
|
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
|
||||||
|
@ -213,12 +201,8 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
||||||
# Assert
|
# Assert
|
||||||
tags_after = artist.get_tags()
|
tags_after = artist.get_tags()
|
||||||
assert len(tags_after) == len(tags_before) - 2
|
assert len(tags_after) == len(tags_before) - 2
|
||||||
found1, found2 = False, False
|
found1 = any(tag.name == "removetag1" for tag in tags_after)
|
||||||
for tag in tags_after:
|
found2 = any(tag.name == "removetag2" for tag in tags_after)
|
||||||
if tag.name == "removetag1":
|
|
||||||
found1 = True
|
|
||||||
elif tag.name == "removetag2":
|
|
||||||
found2 = True
|
|
||||||
assert not found1
|
assert not found1
|
||||||
assert not found2
|
assert not found2
|
||||||
|
|
||||||
|
@ -308,4 +292,4 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
||||||
playcount = artist.get_userplaycount()
|
playcount = artist.get_userplaycount()
|
||||||
|
|
||||||
# Assert
|
# Assert
|
||||||
assert playcount >= 0
|
assert playcount >= 0 # whilst xfail: # pragma: no cover
|
||||||
|
|
|
@ -13,7 +13,7 @@ from flaky import flaky
|
||||||
WRITE_TEST = sys.version_info[:2] == (3, 8)
|
WRITE_TEST = sys.version_info[:2] == (3, 8)
|
||||||
|
|
||||||
|
|
||||||
def load_secrets():
|
def load_secrets(): # pragma: no cover
|
||||||
secrets_file = "test_pylast.yaml"
|
secrets_file = "test_pylast.yaml"
|
||||||
if os.path.isfile(secrets_file):
|
if os.path.isfile(secrets_file):
|
||||||
import yaml # pip install pyyaml
|
import yaml # pip install pyyaml
|
||||||
|
|
|
@ -68,7 +68,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
||||||
if int(registered):
|
if int(registered):
|
||||||
# Last.fm API broken? Used to be yyyy-mm-dd not Unix timestamp
|
# Last.fm API broken? Used to be yyyy-mm-dd not Unix timestamp
|
||||||
assert registered == "1037793040"
|
assert registered == "1037793040"
|
||||||
else:
|
else: # pragma: no cover
|
||||||
# Old way
|
# Old way
|
||||||
# Just check date because of timezones
|
# Just check date because of timezones
|
||||||
assert "2002-11-20 " in registered
|
assert "2002-11-20 " in registered
|
||||||
|
@ -192,8 +192,13 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
||||||
|
|
||||||
# Act/Assert
|
# Act/Assert
|
||||||
self.helper_validate_cacheable(lastfm_user, "get_friends")
|
self.helper_validate_cacheable(lastfm_user, "get_friends")
|
||||||
self.helper_validate_cacheable(lastfm_user, "get_loved_tracks")
|
# no cover whilst xfail:
|
||||||
self.helper_validate_cacheable(lastfm_user, "get_recent_tracks")
|
self.helper_validate_cacheable( # pragma: no cover
|
||||||
|
lastfm_user, "get_loved_tracks"
|
||||||
|
)
|
||||||
|
self.helper_validate_cacheable( # pragma: no cover
|
||||||
|
lastfm_user, "get_recent_tracks"
|
||||||
|
)
|
||||||
|
|
||||||
def test_user_get_top_tags_with_limit(self):
|
def test_user_get_top_tags_with_limit(self):
|
||||||
# Arrange
|
# Arrange
|
||||||
|
|
2
tox.ini
2
tox.ini
|
@ -8,7 +8,7 @@ setenv =
|
||||||
PYLAST_PASSWORD_HASH={env:PYLAST_PASSWORD_HASH:}
|
PYLAST_PASSWORD_HASH={env:PYLAST_PASSWORD_HASH:}
|
||||||
PYLAST_API_KEY={env:PYLAST_API_KEY:}
|
PYLAST_API_KEY={env:PYLAST_API_KEY:}
|
||||||
PYLAST_API_SECRET={env:PYLAST_API_SECRET:}
|
PYLAST_API_SECRET={env:PYLAST_API_SECRET:}
|
||||||
commands = pytest -v -s -W all --cov pylast --cov-report term-missing --random-order {posargs}
|
commands = pytest -v -s -W all --cov pylast --cov tests --cov-report term-missing --random-order {posargs}
|
||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
deps = ipdb
|
deps = ipdb
|
||||||
|
|
Loading…
Reference in a new issue