Compare commits
201 commits
Author | SHA1 | Date | |
---|---|---|---|
|
88bb8ea789 | ||
|
6ae051157f | ||
|
c260d7b83f | ||
|
25904371de | ||
|
184d0328a9 | ||
|
aceaa69c9a | ||
|
de737fb4ee | ||
|
6f97f93dcc | ||
|
a23e1c5181 | ||
|
35b264bae4 | ||
|
353e32bd6b | ||
|
0fa96932a4 | ||
|
90c3614d6a | ||
|
fa68aa4ae8 | ||
|
8a26cf88d8 | ||
|
82cb504871 | ||
|
9d4283a924 | ||
|
e4d2ebc4a0 | ||
|
d5f1c3d3ac | ||
|
e737ae2f34 | ||
|
f4547a5821 | ||
|
a14a50a333 | ||
|
77d1b0009c | ||
|
d505d57fc4 | ||
|
3890cb4c04 | ||
|
5bccda1102 | ||
|
36d89a69e8 | ||
|
a28dea1158 | ||
|
6c888343c8 | ||
|
ffebde28e2 | ||
|
befb5aeceb | ||
|
370ff77f21 | ||
|
cdfc23b5e4 | ||
|
d5fe263c23 | ||
|
e90d717b66 | ||
|
b4c8dc7282 | ||
|
6f30559a3a | ||
|
a91bac007d | ||
|
c0f9f4222a | ||
|
47872dbb32 | ||
|
74392c4d71 | ||
|
97eab1719f | ||
|
e4b7af41f9 | ||
|
7f1c90cfea | ||
|
68c0197028 | ||
|
9e62e37b1e | ||
|
c26c5f86aa | ||
|
f7a73aa62f | ||
|
34e0e54fea | ||
|
02da99f4b0 | ||
|
5f302e0813 | ||
|
47eda3ea70 | ||
|
7da76f49bd | ||
|
1c669d8bb0 | ||
|
0f59831dc2 | ||
|
8d8263ce42 | ||
|
07ce433fc0 | ||
|
dc4bd8474c | ||
|
b05b8454f5 | ||
|
56fc297371 | ||
|
9f59dd770c | ||
|
f0ea480334 | ||
|
165e4761f4 | ||
|
cdb88b9bbb | ||
|
879591e1cc | ||
|
6a7a23cd9a | ||
|
793ae1453c | ||
|
111334328e | ||
|
15f0ccfd58 | ||
|
94432d62b0 | ||
|
dab0a5b661 | ||
|
7f07babdf4 | ||
|
f5ea06c6c9 | ||
|
4ea1df0930 | ||
|
e63ecc7bea | ||
|
28403386a8 | ||
|
8647cbdd48 | ||
|
a37ac22e6c | ||
|
7861fd55bd | ||
|
219be9f61a | ||
|
8169fad09d | ||
|
0152d98b28 | ||
|
d03e25fc6c | ||
|
ce76c03581 | ||
|
7f3518fc1a | ||
|
0560f711c3 | ||
|
41e0dd604e | ||
|
8ea5b42d92 | ||
|
dbbbcfec44 | ||
|
fc288040a8 | ||
|
98943d606e | ||
|
54a9f04f8f | ||
|
7f1de76f6e | ||
|
ece37c4659 | ||
|
8a967b52f4 | ||
|
d35eb5220f | ||
|
aeba21dedb | ||
|
af71e116e0 | ||
|
7df369dfff | ||
|
790351928f | ||
|
1e9d7d8c94 | ||
|
139e77707d | ||
|
8ed1ff2a3e | ||
|
3823d77a35 | ||
|
9f6fcf34fb | ||
|
75e2dd5f2e | ||
|
11f70bfee9 | ||
|
4fc4a6ad89 | ||
|
861182253c | ||
|
ea421db602 | ||
|
d3ba0be1a3 | ||
|
afbafe1e76 | ||
|
dec407d958 | ||
|
fa94ed0263 | ||
|
5b0c879fa0 | ||
|
aefa7cef1b | ||
|
caf0915062 | ||
|
2478980ca5 | ||
|
c1a8a9455f | ||
|
4f37ba41bd | ||
|
ac991cbd2c | ||
|
14e091c870 | ||
|
7b9c73acb7 | ||
|
54ea354a7a | ||
|
5ab3e53a44 | ||
|
eb4af40d64 | ||
|
6c3f3afb3a | ||
|
4e5fe31572 | ||
|
b0f2f5fe13 | ||
|
95c8b16564 | ||
|
549437b640 | ||
|
b373de6c68 | ||
|
5f8d150652 | ||
|
83aeaddc43 | ||
|
dd8836e59b | ||
|
5c9509dfc4 | ||
|
b726227d5d | ||
|
f28a74791d | ||
|
fe7484b3ca | ||
|
00f92eb436 | ||
|
f7090f26a0 | ||
|
4ae6c16f57 | ||
|
1a45c3b919 | ||
|
da2e7152ba | ||
|
a418f64b15 | ||
|
122c870312 | ||
|
44ade40579 | ||
|
26db2bc68b | ||
|
bb05699252 | ||
|
7f4bea6f07 | ||
|
d610721167 | ||
|
6465f4cf51 | ||
|
bafc3fe673 | ||
|
b151dd0c93 | ||
|
dd869b5183 | ||
|
3ffe7cf65a | ||
|
1841fb66dc | ||
|
d672e89f23 | ||
|
3b7cb9c8c7 | ||
|
e14f51a32a | ||
|
c63e0a75ef | ||
|
a204055798 | ||
|
9676714dcf | ||
|
2469a6ea47 | ||
|
d46aabc372 | ||
|
129e4392fc | ||
|
8b66e69004 | ||
|
2966ecfd13 | ||
|
4d4d167394 | ||
|
b48fbb4eb8 | ||
|
d3ee0e4942 | ||
|
25cf4165ea | ||
|
754d94374b | ||
|
b3fb55586c | ||
|
a0bdc3c5ac | ||
|
3a7c83998f | ||
|
ae7d4e3625 | ||
|
7b98775fa0 | ||
|
05b4ad8c62 | ||
|
c41f831d82 | ||
|
e5b9f2aa19 | ||
|
9072b98a18 | ||
|
3db88e98ce | ||
|
031b3ebbb1 | ||
|
aebbe53a61 | ||
|
73e3b1b9ed | ||
|
fd520ad47b | ||
|
a850f093f0 | ||
|
ddb1b1e501 | ||
|
72491f7a99 | ||
|
c8a64dbee9 | ||
|
20cd3ff475 | ||
|
e193106bde | ||
|
1a35601f51 | ||
|
ce2c1e6f76 | ||
|
a516a44c32 | ||
|
55107d12ba | ||
|
4e645ca134 | ||
|
10803a0a63 | ||
|
0c546976b9 | ||
|
6fe9aa632b |
|
@ -11,7 +11,6 @@ charset = utf-8
|
|||
[*.py]
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
# Two-space indentation
|
||||
|
|
3
.github/labels.yml
vendored
3
.github/labels.yml
vendored
|
@ -91,9 +91,6 @@
|
|||
- color: b60205
|
||||
description: Removal of a feature, usually done in major releases
|
||||
name: removal
|
||||
- color: 2d18b2
|
||||
description: "To automatically merge PRs that are ready"
|
||||
name: automerge
|
||||
- color: 0366d6
|
||||
description: "For dependencies"
|
||||
name: dependencies
|
||||
|
|
6
.github/release-drafter.yml
vendored
6
.github/release-drafter.yml
vendored
|
@ -22,8 +22,12 @@ categories:
|
|||
exclude-labels:
|
||||
- "changelog: skip"
|
||||
|
||||
template: |
|
||||
autolabeler:
|
||||
- label: "changelog: skip"
|
||||
branch:
|
||||
- "/pre-commit-ci-update-config/"
|
||||
|
||||
template: |
|
||||
$CHANGES
|
||||
|
||||
version-resolver:
|
||||
|
|
13
.github/renovate.json
vendored
Normal file
13
.github/renovate.json
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": ["config:base"],
|
||||
"labels": ["changelog: skip", "dependencies"],
|
||||
"packageRules": [
|
||||
{
|
||||
"groupName": "github-actions",
|
||||
"matchManagers": ["github-actions"],
|
||||
"separateMajorMinor": "false"
|
||||
}
|
||||
],
|
||||
"schedule": ["on the first day of the month"]
|
||||
}
|
88
.github/workflows/deploy.yml
vendored
88
.github/workflows/deploy.yml
vendored
|
@ -2,56 +2,74 @@ name: Deploy
|
|||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
branches: [main]
|
||||
tags: ["*"]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
release:
|
||||
types:
|
||||
- published
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
build:
|
||||
if: github.repository == 'pylast/pylast'
|
||||
runs-on: ubuntu-20.04
|
||||
# Always build & lint package.
|
||||
build-package:
|
||||
name: Build & verify package
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Cache
|
||||
uses: actions/cache@v2
|
||||
- uses: hynek/build-and-inspect-python-package@v2
|
||||
|
||||
# Upload to Test PyPI on every commit on main.
|
||||
release-test-pypi:
|
||||
name: Publish in-dev package to test.pypi.org
|
||||
if: |
|
||||
github.repository_owner == 'pylast'
|
||||
&& github.event_name == 'push'
|
||||
&& github.ref == 'refs/heads/main'
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-package
|
||||
|
||||
permissions:
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Download packages built by build-and-inspect-python-package
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: ~/.cache/pip
|
||||
key: deploy-${{ hashFiles('**/setup.py') }}
|
||||
restore-keys: |
|
||||
deploy-
|
||||
name: Packages
|
||||
path: dist
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
- name: Upload package to Test PyPI
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
with:
|
||||
python-version: 3.9
|
||||
repository-url: https://test.pypi.org/legacy/
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install -U pip
|
||||
python -m pip install -U setuptools twine wheel
|
||||
# Upload to real PyPI on GitHub Releases.
|
||||
release-pypi:
|
||||
name: Publish released package to pypi.org
|
||||
if: |
|
||||
github.repository_owner == 'pylast'
|
||||
&& github.event.action == 'published'
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-package
|
||||
|
||||
- name: Build package
|
||||
run: |
|
||||
python setup.py --version
|
||||
python setup.py sdist --format=gztar bdist_wheel
|
||||
twine check dist/*
|
||||
permissions:
|
||||
id-token: write
|
||||
|
||||
- name: Publish package to PyPI
|
||||
if: github.event.action == 'published'
|
||||
uses: pypa/gh-action-pypi-publish@master
|
||||
steps:
|
||||
- name: Download packages built by build-and-inspect-python-package
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
user: __token__
|
||||
password: ${{ secrets.pypi_password }}
|
||||
name: Packages
|
||||
path: dist
|
||||
|
||||
- name: Publish package to TestPyPI
|
||||
uses: pypa/gh-action-pypi-publish@master
|
||||
with:
|
||||
user: __token__
|
||||
password: ${{ secrets.test_pypi_password }}
|
||||
repository_url: https://test.pypi.org/legacy/
|
||||
- name: Upload package to PyPI
|
||||
uses: pypa/gh-action-pypi-publish@release/v1
|
||||
|
|
12
.github/workflows/labels.yml
vendored
12
.github/workflows/labels.yml
vendored
|
@ -1,15 +1,21 @@
|
|||
name: Sync labels
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
paths:
|
||||
- .github/labels.yml
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
sync:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
- uses: micnncim/action-label-syncer@v1
|
||||
with:
|
||||
prune: false
|
||||
|
|
20
.github/workflows/lint.yml
vendored
20
.github/workflows/lint.yml
vendored
|
@ -1,12 +1,22 @@
|
|||
name: Lint
|
||||
|
||||
on: [push, pull_request]
|
||||
on: [push, pull_request, workflow_dispatch]
|
||||
|
||||
env:
|
||||
FORCE_COLOR: 1
|
||||
PIP_DISABLE_PIP_VERSION_CHECK: 1
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
- uses: pre-commit/action@v2.0.0
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.x"
|
||||
cache: pip
|
||||
- uses: pre-commit/action@v3.0.1
|
||||
|
|
25
.github/workflows/release-drafter.yml
vendored
25
.github/workflows/release-drafter.yml
vendored
|
@ -4,14 +4,31 @@ on:
|
|||
push:
|
||||
# branches to consider in the event; optional, defaults to all
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
# pull_request event is required only for autolabeler
|
||||
pull_request:
|
||||
# Only following types are handled by the action, but one can default to all as well
|
||||
types: [opened, reopened, synchronize]
|
||||
# pull_request_target event is required for autolabeler to support PRs from forks
|
||||
# pull_request_target:
|
||||
# types: [opened, reopened, synchronize]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
update_release_draft:
|
||||
if: github.repository == 'pylast/pylast'
|
||||
if: github.repository_owner == 'pylast'
|
||||
permissions:
|
||||
# write permission is required to create a GitHub Release
|
||||
contents: write
|
||||
# write permission is required for autolabeler
|
||||
# otherwise, read permission is required at least
|
||||
pull-requests: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# Drafts your next release notes as pull requests are merged into "master"
|
||||
- uses: release-drafter/release-drafter@v5
|
||||
# Drafts your next release notes as pull requests are merged into "main"
|
||||
- uses: release-drafter/release-drafter@v6
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
|
22
.github/workflows/require-pr-label.yml
vendored
Normal file
22
.github/workflows/require-pr-label.yml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
name: Require PR label
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, labeled, unlabeled, synchronize]
|
||||
|
||||
jobs:
|
||||
label:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- uses: mheap/github-action-required-labels@v5
|
||||
with:
|
||||
mode: minimum
|
||||
count: 1
|
||||
labels:
|
||||
"changelog: Added, changelog: Changed, changelog: Deprecated, changelog:
|
||||
Fixed, changelog: Removed, changelog: Security, changelog: skip"
|
44
.github/workflows/test.yml
vendored
44
.github/workflows/test.yml
vendored
|
@ -1,44 +1,28 @@
|
|||
name: Test
|
||||
|
||||
on: [push, pull_request]
|
||||
on: [push, pull_request, workflow_dispatch]
|
||||
|
||||
env:
|
||||
FORCE_COLOR: 1
|
||||
|
||||
jobs:
|
||||
build:
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10-dev", "pypy3"]
|
||||
os: [ubuntu-20.04]
|
||||
include:
|
||||
# Include new variables for Codecov
|
||||
- { codecov-flag: GHA_Ubuntu2004, os: ubuntu-20.04 }
|
||||
python-version: ["pypy3.10", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
|
||||
os: [ubuntu-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Get pip cache dir
|
||||
id: pip-cache
|
||||
run: |
|
||||
echo "::set-output name=dir::$(pip cache dir)"
|
||||
|
||||
- name: Cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ${{ steps.pip-cache.outputs.dir }}
|
||||
key:
|
||||
${{ matrix.os }}-${{ matrix.python-version }}-v3-${{
|
||||
hashFiles('**/setup.py') }}
|
||||
restore-keys: |
|
||||
${{ matrix.os }}-${{ matrix.python-version }}-v3-
|
||||
allow-prereleases: true
|
||||
cache: pip
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
|
@ -56,7 +40,15 @@ jobs:
|
|||
PYLAST_USERNAME: ${{ secrets.PYLAST_USERNAME }}
|
||||
|
||||
- name: Upload coverage
|
||||
uses: codecov/codecov-action@v1
|
||||
uses: codecov/codecov-action@v3.1.5
|
||||
with:
|
||||
flags: ${{ matrix.codecov-flag }}
|
||||
flags: ${{ matrix.os }}
|
||||
name: ${{ matrix.os }} Python ${{ matrix.python-version }}
|
||||
|
||||
success:
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
name: Test successful
|
||||
steps:
|
||||
- name: Success
|
||||
run: echo Test successful
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
pull_request_rules:
|
||||
- name: Automatic merge on approval
|
||||
conditions:
|
||||
- label=automerge
|
||||
- status-success=build
|
||||
actions:
|
||||
merge:
|
||||
method: merge
|
|
@ -1,49 +1,74 @@
|
|||
repos:
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v2.10.0
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.5.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: ["--py36-plus"]
|
||||
- id: ruff
|
||||
args: [--exit-non-zero-on-fix]
|
||||
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 20.8b1
|
||||
- repo: https://github.com/psf/black-pre-commit-mirror
|
||||
rev: 24.4.2
|
||||
hooks:
|
||||
- id: black
|
||||
args: ["--target-version", "py36"]
|
||||
# override until resolved: https://github.com/psf/black/issues/402
|
||||
files: \.pyi?$
|
||||
types: []
|
||||
|
||||
- repo: https://github.com/asottile/blacken-docs
|
||||
rev: v1.9.2
|
||||
rev: 1.18.0
|
||||
hooks:
|
||||
- id: blacken-docs
|
||||
args: ["--target-version", "py36"]
|
||||
additional_dependencies: [black==20.8b1]
|
||||
|
||||
- repo: https://github.com/PyCQA/isort
|
||||
rev: 5.7.0
|
||||
hooks:
|
||||
- id: isort
|
||||
|
||||
- repo: https://gitlab.com/pycqa/flake8
|
||||
rev: 3.8.4
|
||||
hooks:
|
||||
- id: flake8
|
||||
additional_dependencies: [flake8-2020, flake8-implicit-str-concat]
|
||||
|
||||
- repo: https://github.com/pre-commit/pygrep-hooks
|
||||
rev: v1.7.1
|
||||
hooks:
|
||||
- id: python-check-blanket-noqa
|
||||
args: [--target-version=py38]
|
||||
additional_dependencies: [black]
|
||||
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v3.4.0
|
||||
rev: v4.6.0
|
||||
hooks:
|
||||
- id: check-added-large-files
|
||||
- id: check-case-conflict
|
||||
- id: check-merge-conflict
|
||||
- id: check-json
|
||||
- id: check-toml
|
||||
- id: check-yaml
|
||||
- id: debug-statements
|
||||
- id: end-of-file-fixer
|
||||
- id: forbid-submodules
|
||||
- id: trailing-whitespace
|
||||
exclude: .github/(ISSUE_TEMPLATE|PULL_REQUEST_TEMPLATE).md
|
||||
|
||||
- repo: https://github.com/python-jsonschema/check-jsonschema
|
||||
rev: 0.28.6
|
||||
hooks:
|
||||
- id: check-github-workflows
|
||||
- id: check-renovate
|
||||
|
||||
- repo: https://github.com/rhysd/actionlint
|
||||
rev: v1.7.1
|
||||
hooks:
|
||||
- id: actionlint
|
||||
|
||||
- repo: https://github.com/tox-dev/pyproject-fmt
|
||||
rev: 2.1.3
|
||||
hooks:
|
||||
- id: pyproject-fmt
|
||||
|
||||
- repo: https://github.com/abravalheri/validate-pyproject
|
||||
rev: v0.18
|
||||
hooks:
|
||||
- id: validate-pyproject
|
||||
|
||||
- repo: https://github.com/tox-dev/tox-ini-fmt
|
||||
rev: 0.5.0
|
||||
rev: 1.3.1
|
||||
hooks:
|
||||
- id: tox-ini-fmt
|
||||
|
||||
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||
rev: v4.0.0-alpha.8
|
||||
hooks:
|
||||
- id: prettier
|
||||
args: [--prose-wrap=always, --print-width=88]
|
||||
exclude: .github/(ISSUE_TEMPLATE|PULL_REQUEST_TEMPLATE).md
|
||||
|
||||
- repo: meta
|
||||
hooks:
|
||||
- id: check-hooks-apply
|
||||
- id: check-useless-excludes
|
||||
|
||||
ci:
|
||||
autoupdate_schedule: quarterly
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
checks:
|
||||
python:
|
||||
code_rating: true
|
||||
duplicate_code: true
|
||||
filter:
|
||||
excluded_paths:
|
||||
- '*/test/*'
|
||||
tools:
|
||||
external_code_coverage: true
|
105
CHANGELOG.md
105
CHANGELOG.md
|
@ -1,125 +1,136 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
## 4.2.1 and newer
|
||||
|
||||
See GitHub Releases:
|
||||
|
||||
- https://github.com/pylast/pylast/releases
|
||||
|
||||
## [4.2.0] - 2021-03-14
|
||||
|
||||
## Changed
|
||||
|
||||
* Fix unsafe creation of temp file for caching, and improve exception raising (#356) @kvanzuijlen
|
||||
* [pre-commit.ci] pre-commit autoupdate (#362) @pre-commit-ci
|
||||
|
||||
- Fix unsafe creation of temp file for caching, and improve exception raising (#356)
|
||||
@kvanzuijlen
|
||||
- [pre-commit.ci] pre-commit autoupdate (#362) @pre-commit-ci
|
||||
|
||||
## [4.1.0] - 2021-01-04
|
||||
|
||||
## Added
|
||||
|
||||
* Add support for streaming (#336) @kvanzuijlen
|
||||
* Add Python 3.9 final to Travis CI (#350) @sheetalsingala
|
||||
- Add support for streaming (#336) @kvanzuijlen
|
||||
- Add Python 3.9 final to Travis CI (#350) @sheetalsingala
|
||||
|
||||
## Changed
|
||||
|
||||
* Update copyright year (#360) @hugovk
|
||||
* Replace Travis CI with GitHub Actions (#352) @hugovk
|
||||
* [pre-commit.ci] pre-commit autoupdate (#359) @pre-commit-ci
|
||||
- Update copyright year (#360) @hugovk
|
||||
- Replace Travis CI with GitHub Actions (#352) @hugovk
|
||||
- [pre-commit.ci] pre-commit autoupdate (#359) @pre-commit-ci
|
||||
|
||||
## Fixed
|
||||
|
||||
* Set limit to 50 by default, not 1 (#355) @hugovk
|
||||
|
||||
- Set limit to 50 by default, not 1 (#355) @hugovk
|
||||
|
||||
## [4.0.0] - 2020-10-07
|
||||
|
||||
## Added
|
||||
|
||||
* Add support for Python 3.9 (#347) @hugovk
|
||||
- Add support for Python 3.9 (#347) @hugovk
|
||||
|
||||
## Removed
|
||||
|
||||
* Remove deprecated `Artist.get_cover_image`, `User.get_artist_tracks` and `STATUS_TOKEN_ERROR` (#348) @hugovk
|
||||
* Drop support for EOL Python 3.5 (#346) @hugovk
|
||||
|
||||
- Remove deprecated `Artist.get_cover_image`, `User.get_artist_tracks` and
|
||||
`STATUS_TOKEN_ERROR` (#348) @hugovk
|
||||
- Drop support for EOL Python 3.5 (#346) @hugovk
|
||||
|
||||
## [3.3.0] - 2020-06-25
|
||||
|
||||
### Added
|
||||
|
||||
* `User.get_now_playing`: Add album and cover image to info (#330) @hugovk
|
||||
- `User.get_now_playing`: Add album and cover image to info (#330) @hugovk
|
||||
|
||||
### Changed
|
||||
|
||||
* Improve handling of error responses from the API (#327) @spiritualized
|
||||
- Improve handling of error responses from the API (#327) @spiritualized
|
||||
|
||||
### Deprecated
|
||||
|
||||
* Deprecate `Artist.get_cover_image`, they're no longer available from Last.fm (#332) @hugovk
|
||||
- Deprecate `Artist.get_cover_image`, they're no longer available from Last.fm (#332)
|
||||
@hugovk
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fix `artist.get_bio_content()` to return `None` if bio is empty (#326) @hugovk
|
||||
|
||||
- Fix `artist.get_bio_content()` to return `None` if bio is empty (#326) @hugovk
|
||||
|
||||
## [3.2.1] - 2020-03-05
|
||||
|
||||
### Fixed
|
||||
|
||||
* Only Python 3 is supported: don't create universal wheel (#318) @hugovk
|
||||
* Fix regression calling `get_recent_tracks` with `limit=None` (#320) @hugovk
|
||||
* Fix `DeprecationWarning`: Please use `assertRegex` instead (#323) @hugovk
|
||||
- Only Python 3 is supported: don't create universal wheel (#318) @hugovk
|
||||
- Fix regression calling `get_recent_tracks` with `limit=None` (#320) @hugovk
|
||||
- Fix `DeprecationWarning`: Please use `assertRegex` instead (#323) @hugovk
|
||||
|
||||
## [3.2.0] - 2020-01-03
|
||||
|
||||
### Added
|
||||
|
||||
* Support for Python 3.8
|
||||
* Store album art URLs when you call `GetTopAlbums` ([#307])
|
||||
* Retry paging through results on exception ([#297])
|
||||
* More error status codes from https://last.fm/api/errorcodes ([#297])
|
||||
- Support for Python 3.8
|
||||
- Store album art URLs when you call `GetTopAlbums` ([#307])
|
||||
- Retry paging through results on exception ([#297])
|
||||
- More error status codes from https://last.fm/api/errorcodes ([#297])
|
||||
|
||||
### Changed
|
||||
|
||||
* Respect `get_recent_tracks`' limit when there's a now playing track ([#310])
|
||||
* Move installable code to `src/` ([#301])
|
||||
* Update `get_weekly_artist_charts` docstring: only for `User` ([#311])
|
||||
* Remove Python 2 warnings, `python_requires` should be enough ([#312])
|
||||
* Use setuptools_scm to simplify versioning during release ([#316])
|
||||
* Various lint and test updates
|
||||
- Respect `get_recent_tracks`' limit when there's a now playing track ([#310])
|
||||
- Move installable code to `src/` ([#301])
|
||||
- Update `get_weekly_artist_charts` docstring: only for `User` ([#311])
|
||||
- Remove Python 2 warnings, `python_requires` should be enough ([#312])
|
||||
- Use setuptools_scm to simplify versioning during release ([#316])
|
||||
- Various lint and test updates
|
||||
|
||||
### Deprecated
|
||||
|
||||
* Last.fm's `user.getArtistTracks` has now been deprecated by Last.fm and is no longer
|
||||
- Last.fm's `user.getArtistTracks` has now been deprecated by Last.fm and is no longer
|
||||
available. Last.fm returns a "Deprecated - This type of request is no longer
|
||||
supported" error when calling it. A future version of pylast will remove its
|
||||
`User.get_artist_tracks` altogether. ([#305])
|
||||
|
||||
* `STATUS_TOKEN_ERROR` is deprecated and will be removed in a future version.
|
||||
Use `STATUS_OPERATION_FAILED` instead.
|
||||
- `STATUS_TOKEN_ERROR` is deprecated and will be removed in a future version. Use
|
||||
`STATUS_OPERATION_FAILED` instead.
|
||||
|
||||
## [3.1.0] - 2019-03-07
|
||||
|
||||
### Added
|
||||
|
||||
* Extract username from session via new
|
||||
- Extract username from session via new
|
||||
`SessionKeyGenerator.get_web_auth_session_key_username` ([#290])
|
||||
* `User.get_track_scrobbles` ([#298])
|
||||
- `User.get_track_scrobbles` ([#298])
|
||||
|
||||
### Deprecated
|
||||
|
||||
* `User.get_artist_tracks`. Use `User.get_track_scrobbles` as a partial replacement.
|
||||
([#298])
|
||||
- `User.get_artist_tracks`. Use `User.get_track_scrobbles` as a partial replacement.
|
||||
([#298])
|
||||
|
||||
## [3.0.0] - 2019-01-01
|
||||
|
||||
### Added
|
||||
* This changelog file ([#273])
|
||||
|
||||
- This changelog file ([#273])
|
||||
|
||||
### Removed
|
||||
|
||||
* Support for Python 2.7 ([#265])
|
||||
- Support for Python 2.7 ([#265])
|
||||
|
||||
* Constants `COVER_SMALL`, `COVER_MEDIUM`, `COVER_LARGE`, `COVER_EXTRA_LARGE`
|
||||
and `COVER_MEGA`. Use `SIZE_SMALL` etc. instead. ([#282])
|
||||
- Constants `COVER_SMALL`, `COVER_MEDIUM`, `COVER_LARGE`, `COVER_EXTRA_LARGE` and
|
||||
`COVER_MEGA`. Use `SIZE_SMALL` etc. instead. ([#282])
|
||||
|
||||
## [2.4.0] - 2018-08-08
|
||||
|
||||
### Deprecated
|
||||
|
||||
* Support for Python 2.7 ([#265])
|
||||
- Support for Python 2.7 ([#265])
|
||||
|
||||
[4.2.0]: https://github.com/pylast/pylast/compare/4.1.0...4.2.0
|
||||
[4.1.0]: https://github.com/pylast/pylast/compare/4.0.0...4.1.0
|
||||
|
|
6
COPYING
6
COPYING
|
@ -32,11 +32,11 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|||
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||
|
||||
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
|
||||
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
|
||||
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
|
||||
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
||||
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||
|
|
127
README.md
127
README.md
|
@ -1,12 +1,11 @@
|
|||
pyLast
|
||||
======
|
||||
# pyLast
|
||||
|
||||
[](https://pypi.org/project/pylast/)
|
||||
[](https://pypi.org/project/pylast/)
|
||||
[](https://pypistats.org/packages/pylast)
|
||||
[](https://github.com/pylast/pylast/actions)
|
||||
[](https://codecov.io/gh/pylast/pylast)
|
||||
[](https://github.com/psf/black)
|
||||
[](https://codecov.io/gh/pylast/pylast)
|
||||
[](https://github.com/psf/black)
|
||||
[](https://zenodo.org/badge/latestdoi/7803088)
|
||||
|
||||
A Python interface to [Last.fm](https://www.last.fm/) and other API-compatible websites
|
||||
|
@ -14,53 +13,48 @@ such as [Libre.fm](https://libre.fm/).
|
|||
|
||||
Use the pydoc utility for help on usage or see [tests/](tests/) for examples.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Install via pip:
|
||||
|
||||
```sh
|
||||
python3 -m pip install pylast
|
||||
```
|
||||
## Installation
|
||||
|
||||
Install latest development version:
|
||||
|
||||
```sh
|
||||
python3 -m pip install -U git+https://github.com/pylast/pylast
|
||||
python3 -m pip install -U git+https://git.hirad.it/Hirad/pylast
|
||||
```
|
||||
|
||||
Or from requirements.txt:
|
||||
|
||||
```txt
|
||||
-e git://github.com/pylast/pylast.git#egg=pylast
|
||||
-e https://git.hirad.it/Hirad/pylast#egg=pylast
|
||||
```
|
||||
|
||||
Note:
|
||||
|
||||
* pyLast 4.0+ supports Python 3.6-3.9.
|
||||
* pyLast 3.2 - 3.3 supports Python 3.5-3.8.
|
||||
* pyLast 3.0 - 3.1 supports Python 3.5-3.7.
|
||||
* pyLast 2.2 - 2.4 supports Python 2.7.10+, 3.4-3.7.
|
||||
* pyLast 2.0 - 2.1 supports Python 2.7.10+, 3.4-3.6.
|
||||
* pyLast 1.7 - 1.9 supports Python 2.7, 3.3-3.6.
|
||||
* pyLast 1.0 - 1.6 supports Python 2.7, 3.3-3.4.
|
||||
* pyLast 0.5 supports Python 2, 3.
|
||||
* pyLast < 0.5 supports Python 2.
|
||||
- pyLast 5.3+ supports Python 3.8-3.13.
|
||||
- pyLast 5.2+ supports Python 3.8-3.12.
|
||||
- pyLast 5.1 supports Python 3.7-3.11.
|
||||
- pyLast 5.0 supports Python 3.7-3.10.
|
||||
- pyLast 4.3 - 4.5 supports Python 3.6-3.10.
|
||||
- pyLast 4.0 - 4.2 supports Python 3.6-3.9.
|
||||
- pyLast 3.2 - 3.3 supports Python 3.5-3.8.
|
||||
- pyLast 3.0 - 3.1 supports Python 3.5-3.7.
|
||||
- pyLast 2.2 - 2.4 supports Python 2.7.10+, 3.4-3.7.
|
||||
- pyLast 2.0 - 2.1 supports Python 2.7.10+, 3.4-3.6.
|
||||
- pyLast 1.7 - 1.9 supports Python 2.7, 3.3-3.6.
|
||||
- pyLast 1.0 - 1.6 supports Python 2.7, 3.3-3.4.
|
||||
- pyLast 0.5 supports Python 2, 3.
|
||||
- pyLast < 0.5 supports Python 2.
|
||||
|
||||
Features
|
||||
--------
|
||||
## Features
|
||||
|
||||
* Simple public interface.
|
||||
* Access to all the data exposed by the Last.fm web services.
|
||||
* Scrobbling support.
|
||||
* Full object-oriented design.
|
||||
* Proxy support.
|
||||
* Internal caching support for some web services calls (disabled by default).
|
||||
* Support for other API-compatible networks like Libre.fm.
|
||||
- Simple public interface.
|
||||
- Access to all the data exposed by the Last.fm web services.
|
||||
- Scrobbling support.
|
||||
- Full object-oriented design.
|
||||
- Proxy support.
|
||||
- Internal caching support for some web services calls (disabled by default).
|
||||
- Support for other API-compatible networks like Libre.fm.
|
||||
|
||||
|
||||
Getting started
|
||||
---------------
|
||||
## Getting started
|
||||
|
||||
Here's some simple code example to get you started. In order to create any object from
|
||||
pyLast, you need a `Network` object which represents a social music network that is
|
||||
|
@ -85,12 +79,44 @@ network = pylast.LastFMNetwork(
|
|||
username=username,
|
||||
password_hash=password_hash,
|
||||
)
|
||||
```
|
||||
|
||||
Alternatively, instead of creating `network` with a username and password, you can
|
||||
authenticate with a session key:
|
||||
|
||||
```python
|
||||
import pylast
|
||||
|
||||
SESSION_KEY_FILE = os.path.join(os.path.expanduser("~"), ".session_key")
|
||||
network = pylast.LastFMNetwork(API_KEY, API_SECRET)
|
||||
if not os.path.exists(SESSION_KEY_FILE):
|
||||
skg = pylast.SessionKeyGenerator(network)
|
||||
url = skg.get_web_auth_url()
|
||||
|
||||
print(f"Please authorize this script to access your account: {url}\n")
|
||||
import time
|
||||
import webbrowser
|
||||
|
||||
webbrowser.open(url)
|
||||
|
||||
while True:
|
||||
try:
|
||||
session_key = skg.get_web_auth_session_key(url)
|
||||
with open(SESSION_KEY_FILE, "w") as f:
|
||||
f.write(session_key)
|
||||
break
|
||||
except pylast.WSError:
|
||||
time.sleep(1)
|
||||
else:
|
||||
session_key = open(SESSION_KEY_FILE).read()
|
||||
|
||||
network.session_key = session_key
|
||||
```
|
||||
|
||||
And away we go:
|
||||
|
||||
```python
|
||||
# Now you can use that object everywhere
|
||||
artist = network.get_artist("System of a Down")
|
||||
artist.shout("<3")
|
||||
|
||||
|
||||
track = network.get_track("Iron Maiden", "The Nomad")
|
||||
track.love()
|
||||
track.add_tags(("awesome", "favorite"))
|
||||
|
@ -101,18 +127,18 @@ track.add_tags(("awesome", "favorite"))
|
|||
|
||||
More examples in
|
||||
<a href="https://github.com/hugovk/lastfm-tools">hugovk/lastfm-tools</a> and
|
||||
[tests/](https://github.com/pylast/pylast/tree/master/tests).
|
||||
[tests/](https://github.com/pylast/pylast/tree/main/tests).
|
||||
|
||||
Testing
|
||||
-------
|
||||
## Testing
|
||||
|
||||
The [tests/](https://github.com/pylast/pylast/tree/master/tests) directory contains
|
||||
The [tests/](https://github.com/pylast/pylast/tree/main/tests) directory contains
|
||||
integration and unit tests with Last.fm, and plenty of code examples.
|
||||
|
||||
For integration tests you need a test account at Last.fm that will become cluttered with
|
||||
test data, and an API key and secret. Either copy
|
||||
[example_test_pylast.yaml](example_test_pylast.yaml) to test_pylast.yaml and fill out
|
||||
the credentials, or set them as environment variables like:
|
||||
[example_test_pylast.yaml](https://github.com/pylast/pylast/blob/main/example_test_pylast.yaml)
|
||||
to test_pylast.yaml and fill out the credentials, or set them as environment variables
|
||||
like:
|
||||
|
||||
```sh
|
||||
export PYLAST_USERNAME=TODO_ENTER_YOURS_HERE
|
||||
|
@ -143,8 +169,7 @@ coverage html # for HTML report
|
|||
open htmlcov/index.html
|
||||
```
|
||||
|
||||
Logging
|
||||
-------
|
||||
## Logging
|
||||
|
||||
To enable from your own code:
|
||||
|
||||
|
@ -152,7 +177,8 @@ To enable from your own code:
|
|||
import logging
|
||||
import pylast
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
|
||||
network = pylast.LastFMNetwork(...)
|
||||
```
|
||||
|
@ -160,5 +186,8 @@ network = pylast.LastFMNetwork(...)
|
|||
To enable from pytest:
|
||||
|
||||
```sh
|
||||
pytest --log-cli-level debug -k test_album_search_images
|
||||
pytest --log-cli-level info -k test_album_search_images
|
||||
```
|
||||
|
||||
To also see data returned from the API, use `level=logging.DEBUG` or
|
||||
`--log-cli-level debug` instead.
|
||||
|
|
19
RELEASING.md
19
RELEASING.md
|
@ -1,23 +1,22 @@
|
|||
# Release Checklist
|
||||
|
||||
* [ ] Get master to the appropriate code release state.
|
||||
[GitHub Actions](https://github.com/pylast/pylast/actions) should be running cleanly for
|
||||
all merges to master.
|
||||
- [ ] Get `main` to the appropriate code release state.
|
||||
[GitHub Actions](https://github.com/pylast/pylast/actions) should be running
|
||||
cleanly for all merges to `main`.
|
||||
[](https://github.com/pylast/pylast/actions)
|
||||
|
||||
* [ ] Edit release draft, adjust text if needed:
|
||||
- [ ] Edit release draft, adjust text if needed:
|
||||
https://github.com/pylast/pylast/releases
|
||||
|
||||
* [ ] Check next tag is correct, amend if needed
|
||||
- [ ] Check next tag is correct, amend if needed
|
||||
|
||||
* [ ] Copy text into [`CHANGELOG.md`](CHANGELOG.md)
|
||||
- [ ] Publish release
|
||||
|
||||
* [ ] Publish release
|
||||
|
||||
* [ ] Check the tagged [GitHub Actions build](https://github.com/pylast/pylast/actions?query=workflow%3ADeploy)
|
||||
- [ ] Check the tagged
|
||||
[GitHub Actions build](https://github.com/pylast/pylast/actions/workflows/deploy.yml)
|
||||
has deployed to [PyPI](https://pypi.org/project/pylast/#history)
|
||||
|
||||
* [ ] Check installation:
|
||||
- [ ] Check installation:
|
||||
|
||||
```bash
|
||||
pip3 uninstall -y pylast && pip3 install -U pylast && python3 -c "import pylast; print(pylast.__version__)"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
username: TODO_ENTER_YOURS_HERE
|
||||
password_hash: TODO_ENTER_YOURS_HERE
|
||||
api_key: TODO_ENTER_YOURS_HERE
|
||||
api_secret: TODO_ENTER_YOURS_HERE
|
||||
username: TODO_ENTER_YOURS_HERE
|
||||
password_hash: TODO_ENTER_YOURS_HERE
|
||||
api_key: TODO_ENTER_YOURS_HERE
|
||||
api_secret: TODO_ENTER_YOURS_HERE
|
||||
|
|
97
pyproject.toml
Normal file
97
pyproject.toml
Normal file
|
@ -0,0 +1,97 @@
|
|||
[build-system]
|
||||
build-backend = "hatchling.build"
|
||||
requires = [
|
||||
"hatch-vcs",
|
||||
"hatchling",
|
||||
]
|
||||
|
||||
[project]
|
||||
name = "pylast"
|
||||
description = "A Python interface to Last.fm and Libre.fm"
|
||||
readme = "README.md"
|
||||
keywords = [
|
||||
"Last.fm",
|
||||
"music",
|
||||
"scrobble",
|
||||
"scrobbling",
|
||||
]
|
||||
license = { text = "Apache-2.0" }
|
||||
maintainers = [
|
||||
{ name = "Hugo van Kemenade" },
|
||||
]
|
||||
authors = [
|
||||
{ name = "Amr Hassan <amr.hassan@gmail.com> and Contributors", email = "amr.hassan@gmail.com" },
|
||||
]
|
||||
requires-python = ">=3.8"
|
||||
classifiers = [
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"License :: OSI Approved :: Apache Software License",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
"Programming Language :: Python :: Implementation :: PyPy",
|
||||
"Topic :: Internet",
|
||||
"Topic :: Multimedia :: Sound/Audio",
|
||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||
]
|
||||
dynamic = [
|
||||
"version",
|
||||
]
|
||||
dependencies = [
|
||||
"httpx",
|
||||
]
|
||||
optional-dependencies.tests = [
|
||||
"flaky",
|
||||
"pytest",
|
||||
"pytest-cov",
|
||||
"pytest-random-order",
|
||||
"pyyaml",
|
||||
]
|
||||
urls.Changelog = "https://github.com/pylast/pylast/releases"
|
||||
urls.Homepage = "https://github.com/pylast/pylast"
|
||||
urls.Source = "https://github.com/pylast/pylast"
|
||||
|
||||
[tool.hatch]
|
||||
version.source = "vcs"
|
||||
|
||||
[tool.hatch.version.raw-options]
|
||||
local_scheme = "no-local-version"
|
||||
|
||||
[tool.ruff]
|
||||
fix = true
|
||||
|
||||
lint.select = [
|
||||
"C4", # flake8-comprehensions
|
||||
"E", # pycodestyle errors
|
||||
"EM", # flake8-errmsg
|
||||
"F", # pyflakes errors
|
||||
"I", # isort
|
||||
"ISC", # flake8-implicit-str-concat
|
||||
"LOG", # flake8-logging
|
||||
"PGH", # pygrep-hooks
|
||||
"RUF022", # unsorted-dunder-all
|
||||
"RUF100", # unused noqa (yesqa)
|
||||
"UP", # pyupgrade
|
||||
"W", # pycodestyle warnings
|
||||
"YTT", # flake8-2020
|
||||
]
|
||||
lint.extend-ignore = [
|
||||
"E203", # Whitespace before ':'
|
||||
"E221", # Multiple spaces before operator
|
||||
"E226", # Missing whitespace around arithmetic operator
|
||||
"E241", # Multiple spaces after ','
|
||||
]
|
||||
lint.isort.known-first-party = [
|
||||
"pylast",
|
||||
]
|
||||
lint.isort.required-imports = [
|
||||
"from __future__ import annotations",
|
||||
]
|
||||
|
||||
[tool.pyproject-fmt]
|
||||
max_supported_python = "3.13"
|
|
@ -2,3 +2,5 @@
|
|||
filterwarnings =
|
||||
once::DeprecationWarning
|
||||
once::PendingDeprecationWarning
|
||||
|
||||
xfail_strict=true
|
||||
|
|
46
setup.py
46
setup.py
|
@ -1,46 +0,0 @@
|
|||
from setuptools import find_packages, setup
|
||||
|
||||
with open("README.md") as f:
|
||||
long_description = f.read()
|
||||
|
||||
|
||||
def local_scheme(version):
|
||||
"""Skip the local version (eg. +xyz of 0.6.1.dev4+gdf99fe2)
|
||||
to be able to upload to Test PyPI"""
|
||||
return ""
|
||||
|
||||
|
||||
setup(
|
||||
name="pylast",
|
||||
description="A Python interface to Last.fm and Libre.fm",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
author="Amr Hassan <amr.hassan@gmail.com> and Contributors",
|
||||
author_email="amr.hassan@gmail.com",
|
||||
url="https://github.com/pylast/pylast",
|
||||
license="Apache2",
|
||||
keywords=["Last.fm", "music", "scrobble", "scrobbling"],
|
||||
packages=find_packages(where="src"),
|
||||
package_dir={"": "src"},
|
||||
use_scm_version={"local_scheme": local_scheme},
|
||||
setup_requires=["setuptools_scm"],
|
||||
extras_require={
|
||||
"tests": ["flaky", "pytest", "pytest-cov", "pytest-random-order", "pyyaml"]
|
||||
},
|
||||
python_requires=">=3.6",
|
||||
classifiers=[
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"License :: OSI Approved :: Apache Software License",
|
||||
"Topic :: Internet",
|
||||
"Topic :: Multimedia :: Sound/Audio",
|
||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
"Programming Language :: Python :: Implementation :: PyPy",
|
||||
],
|
||||
)
|
File diff suppressed because it is too large
Load diff
|
@ -2,13 +2,15 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pylast
|
||||
|
||||
from .test_pylast import TestPyLastWithLastFm
|
||||
|
||||
|
||||
class TestPyLastAlbum(TestPyLastWithLastFm):
|
||||
def test_album_tags_are_topitems(self):
|
||||
def test_album_tags_are_topitems(self) -> None:
|
||||
# Arrange
|
||||
album = self.network.get_album("Test Artist", "Test Album")
|
||||
|
||||
|
@ -19,14 +21,14 @@ class TestPyLastAlbum(TestPyLastWithLastFm):
|
|||
assert len(tags) > 0
|
||||
assert isinstance(tags[0], pylast.TopItem)
|
||||
|
||||
def test_album_is_hashable(self):
|
||||
def test_album_is_hashable(self) -> None:
|
||||
# Arrange
|
||||
album = self.network.get_album("Test Artist", "Test Album")
|
||||
|
||||
# Act/Assert
|
||||
self.helper_is_thing_hashable(album)
|
||||
|
||||
def test_album_in_recent_tracks(self):
|
||||
def test_album_in_recent_tracks(self) -> None:
|
||||
# Arrange
|
||||
lastfm_user = self.network.get_user(self.username)
|
||||
|
||||
|
@ -37,7 +39,7 @@ class TestPyLastAlbum(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert hasattr(track, "album")
|
||||
|
||||
def test_album_wiki_content(self):
|
||||
def test_album_wiki_content(self) -> None:
|
||||
# Arrange
|
||||
album = pylast.Album("Test Artist", "Test Album", self.network)
|
||||
|
||||
|
@ -48,7 +50,7 @@ class TestPyLastAlbum(TestPyLastWithLastFm):
|
|||
assert wiki is not None
|
||||
assert len(wiki) >= 1
|
||||
|
||||
def test_album_wiki_published_date(self):
|
||||
def test_album_wiki_published_date(self) -> None:
|
||||
# Arrange
|
||||
album = pylast.Album("Test Artist", "Test Album", self.network)
|
||||
|
||||
|
@ -59,7 +61,7 @@ class TestPyLastAlbum(TestPyLastWithLastFm):
|
|||
assert wiki is not None
|
||||
assert len(wiki) >= 1
|
||||
|
||||
def test_album_wiki_summary(self):
|
||||
def test_album_wiki_summary(self) -> None:
|
||||
# Arrange
|
||||
album = pylast.Album("Test Artist", "Test Album", self.network)
|
||||
|
||||
|
@ -70,7 +72,7 @@ class TestPyLastAlbum(TestPyLastWithLastFm):
|
|||
assert wiki is not None
|
||||
assert len(wiki) >= 1
|
||||
|
||||
def test_album_eq_none_is_false(self):
|
||||
def test_album_eq_none_is_false(self) -> None:
|
||||
# Arrange
|
||||
album1 = None
|
||||
album2 = pylast.Album("Test Artist", "Test Album", self.network)
|
||||
|
@ -78,7 +80,7 @@ class TestPyLastAlbum(TestPyLastWithLastFm):
|
|||
# Act / Assert
|
||||
assert album1 != album2
|
||||
|
||||
def test_album_ne_none_is_true(self):
|
||||
def test_album_ne_none_is_true(self) -> None:
|
||||
# Arrange
|
||||
album1 = None
|
||||
album2 = pylast.Album("Test Artist", "Test Album", self.network)
|
||||
|
@ -86,7 +88,7 @@ class TestPyLastAlbum(TestPyLastWithLastFm):
|
|||
# Act / Assert
|
||||
assert album1 != album2
|
||||
|
||||
def test_get_cover_image(self):
|
||||
def test_get_cover_image(self) -> None:
|
||||
# Arrange
|
||||
album = self.network.get_album("Test Artist", "Test Album")
|
||||
|
||||
|
@ -94,5 +96,25 @@ class TestPyLastAlbum(TestPyLastWithLastFm):
|
|||
image = album.get_cover_image()
|
||||
|
||||
# Assert
|
||||
self.assert_startswith(image, "https://")
|
||||
self.assert_endswith(image, ".png")
|
||||
assert image.startswith("https://")
|
||||
assert image.endswith(".gif") or image.endswith(".png")
|
||||
|
||||
def test_mbid(self) -> None:
|
||||
# Arrange
|
||||
album = self.network.get_album("Radiohead", "OK Computer")
|
||||
|
||||
# Act
|
||||
mbid = album.get_mbid()
|
||||
|
||||
# Assert
|
||||
assert mbid == "0b6b4ba0-d36f-47bd-b4ea-6a5b91842d29"
|
||||
|
||||
def test_no_mbid(self) -> None:
|
||||
# Arrange
|
||||
album = self.network.get_album("Test Artist", "Test Album")
|
||||
|
||||
# Act
|
||||
mbid = album.get_mbid()
|
||||
|
||||
# Assert
|
||||
assert mbid is None
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
import pylast
|
||||
|
@ -10,7 +12,7 @@ from .test_pylast import WRITE_TEST, TestPyLastWithLastFm
|
|||
|
||||
|
||||
class TestPyLastArtist(TestPyLastWithLastFm):
|
||||
def test_repr(self):
|
||||
def test_repr(self) -> None:
|
||||
# Arrange
|
||||
artist = pylast.Artist("Test Artist", self.network)
|
||||
|
||||
|
@ -20,16 +22,16 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert representation.startswith("pylast.Artist('Test Artist',")
|
||||
|
||||
def test_artist_is_hashable(self):
|
||||
def test_artist_is_hashable(self) -> None:
|
||||
# Arrange
|
||||
test_artist = self.network.get_artist("Test Artist")
|
||||
test_artist = self.network.get_artist("Radiohead")
|
||||
artist = test_artist.get_similar(limit=2)[0].item
|
||||
assert isinstance(artist, pylast.Artist)
|
||||
|
||||
# Act/Assert
|
||||
self.helper_is_thing_hashable(artist)
|
||||
|
||||
def test_bio_published_date(self):
|
||||
def test_bio_published_date(self) -> None:
|
||||
# Arrange
|
||||
artist = pylast.Artist("Test Artist", self.network)
|
||||
|
||||
|
@ -40,7 +42,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
assert bio is not None
|
||||
assert len(bio) >= 1
|
||||
|
||||
def test_bio_content(self):
|
||||
def test_bio_content(self) -> None:
|
||||
# Arrange
|
||||
artist = pylast.Artist("Test Artist", self.network)
|
||||
|
||||
|
@ -51,7 +53,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
assert bio is not None
|
||||
assert len(bio) >= 1
|
||||
|
||||
def test_bio_content_none(self):
|
||||
def test_bio_content_none(self) -> None:
|
||||
# Arrange
|
||||
# An artist with no biography, with "<content/>" in the API XML
|
||||
artist = pylast.Artist("Mr Sizef + Unquote", self.network)
|
||||
|
@ -62,7 +64,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert bio is None
|
||||
|
||||
def test_bio_summary(self):
|
||||
def test_bio_summary(self) -> None:
|
||||
# Arrange
|
||||
artist = pylast.Artist("Test Artist", self.network)
|
||||
|
||||
|
@ -73,7 +75,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
assert bio is not None
|
||||
assert len(bio) >= 1
|
||||
|
||||
def test_artist_top_tracks(self):
|
||||
def test_artist_top_tracks(self) -> None:
|
||||
# Arrange
|
||||
# Pick an artist with plenty of plays
|
||||
artist = self.network.get_top_artists(limit=1)[0].item
|
||||
|
@ -84,7 +86,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
self.helper_two_different_things_in_top_list(things, pylast.Track)
|
||||
|
||||
def test_artist_top_albums(self):
|
||||
def test_artist_top_albums(self) -> None:
|
||||
# Arrange
|
||||
# Pick an artist with plenty of plays
|
||||
artist = self.network.get_top_artists(limit=1)[0].item
|
||||
|
@ -107,7 +109,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert len(things) == test_limit
|
||||
|
||||
def test_artist_top_albums_limit_default(self):
|
||||
def test_artist_top_albums_limit_default(self) -> None:
|
||||
# Arrange
|
||||
# Pick an artist with plenty of plays
|
||||
artist = self.network.get_top_artists(limit=1)[0].item
|
||||
|
@ -118,7 +120,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert len(things) == 50
|
||||
|
||||
def test_artist_listener_count(self):
|
||||
def test_artist_listener_count(self) -> None:
|
||||
# Arrange
|
||||
artist = self.network.get_artist("Test Artist")
|
||||
|
||||
|
@ -130,7 +132,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
assert count > 0
|
||||
|
||||
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
|
||||
def test_tag_artist(self):
|
||||
def test_tag_artist(self) -> None:
|
||||
# Arrange
|
||||
artist = self.network.get_artist("Test Artist")
|
||||
# artist.clear_tags()
|
||||
|
@ -145,7 +147,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
assert found
|
||||
|
||||
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
|
||||
def test_remove_tag_of_type_text(self):
|
||||
def test_remove_tag_of_type_text(self) -> None:
|
||||
# Arrange
|
||||
tag = "testing" # text
|
||||
artist = self.network.get_artist("Test Artist")
|
||||
|
@ -160,7 +162,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
assert not found
|
||||
|
||||
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
|
||||
def test_remove_tag_of_type_tag(self):
|
||||
def test_remove_tag_of_type_tag(self) -> None:
|
||||
# Arrange
|
||||
tag = pylast.Tag("testing", self.network) # Tag
|
||||
artist = self.network.get_artist("Test Artist")
|
||||
|
@ -175,7 +177,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
assert not found
|
||||
|
||||
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
|
||||
def test_remove_tags(self):
|
||||
def test_remove_tags(self) -> None:
|
||||
# Arrange
|
||||
tags = ["removetag1", "removetag2"]
|
||||
artist = self.network.get_artist("Test Artist")
|
||||
|
@ -195,7 +197,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
assert not found2
|
||||
|
||||
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
|
||||
def test_set_tags(self):
|
||||
def test_set_tags(self) -> None:
|
||||
# Arrange
|
||||
tags = ["sometag1", "sometag2"]
|
||||
artist = self.network.get_artist("Test Artist 2")
|
||||
|
@ -219,7 +221,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
assert found1
|
||||
assert found2
|
||||
|
||||
def test_artists(self):
|
||||
def test_artists(self) -> None:
|
||||
# Arrange
|
||||
artist1 = self.network.get_artist("Radiohead")
|
||||
artist2 = self.network.get_artist("Portishead")
|
||||
|
@ -229,7 +231,6 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
mbid = artist1.get_mbid()
|
||||
|
||||
playcount = artist1.get_playcount()
|
||||
streamable = artist1.is_streamable()
|
||||
name = artist1.get_name(properly_capitalized=False)
|
||||
name_cap = artist1.get_name(properly_capitalized=True)
|
||||
|
||||
|
@ -239,9 +240,8 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
assert name.lower() == name_cap.lower()
|
||||
assert url == "https://www.last.fm/music/radiohead"
|
||||
assert mbid == "a74b1b7f-71a5-4011-9441-d0b5e4122711"
|
||||
assert isinstance(streamable, bool)
|
||||
|
||||
def test_artist_eq_none_is_false(self):
|
||||
def test_artist_eq_none_is_false(self) -> None:
|
||||
# Arrange
|
||||
artist1 = None
|
||||
artist2 = pylast.Artist("Test Artist", self.network)
|
||||
|
@ -249,7 +249,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
# Act / Assert
|
||||
assert artist1 != artist2
|
||||
|
||||
def test_artist_ne_none_is_true(self):
|
||||
def test_artist_ne_none_is_true(self) -> None:
|
||||
# Arrange
|
||||
artist1 = None
|
||||
artist2 = pylast.Artist("Test Artist", self.network)
|
||||
|
@ -257,7 +257,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
# Act / Assert
|
||||
assert artist1 != artist2
|
||||
|
||||
def test_artist_get_correction(self):
|
||||
def test_artist_get_correction(self) -> None:
|
||||
# Arrange
|
||||
artist = pylast.Artist("guns and roses", self.network)
|
||||
|
||||
|
@ -267,8 +267,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert corrected_artist_name == "Guns N' Roses"
|
||||
|
||||
@pytest.mark.xfail
|
||||
def test_get_userplaycount(self):
|
||||
def test_get_userplaycount(self) -> None:
|
||||
# Arrange
|
||||
artist = pylast.Artist("John Lennon", self.network, username=self.username)
|
||||
|
||||
|
@ -276,4 +275,4 @@ class TestPyLastArtist(TestPyLastWithLastFm):
|
|||
playcount = artist.get_userplaycount()
|
||||
|
||||
# Assert
|
||||
assert playcount >= 0 # whilst xfail: # pragma: no cover
|
||||
assert playcount >= 0
|
||||
|
|
|
@ -2,20 +2,22 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pylast
|
||||
|
||||
from .test_pylast import TestPyLastWithLastFm
|
||||
|
||||
|
||||
class TestPyLastCountry(TestPyLastWithLastFm):
|
||||
def test_country_is_hashable(self):
|
||||
def test_country_is_hashable(self) -> None:
|
||||
# Arrange
|
||||
country = self.network.get_country("Italy")
|
||||
|
||||
# Act/Assert
|
||||
self.helper_is_thing_hashable(country)
|
||||
|
||||
def test_countries(self):
|
||||
def test_countries(self) -> None:
|
||||
# Arrange
|
||||
country1 = pylast.Country("Italy", self.network)
|
||||
country2 = pylast.Country("Finland", self.network)
|
||||
|
|
|
@ -2,13 +2,15 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pylast
|
||||
|
||||
from .test_pylast import TestPyLastWithLastFm
|
||||
|
||||
|
||||
class TestPyLastLibrary(TestPyLastWithLastFm):
|
||||
def test_repr(self):
|
||||
def test_repr(self) -> None:
|
||||
# Arrange
|
||||
library = pylast.Library(user=self.username, network=self.network)
|
||||
|
||||
|
@ -16,9 +18,9 @@ class TestPyLastLibrary(TestPyLastWithLastFm):
|
|||
representation = repr(library)
|
||||
|
||||
# Assert
|
||||
self.assert_startswith(representation, "pylast.Library(")
|
||||
assert representation.startswith("pylast.Library(")
|
||||
|
||||
def test_str(self):
|
||||
def test_str(self) -> None:
|
||||
# Arrange
|
||||
library = pylast.Library(user=self.username, network=self.network)
|
||||
|
||||
|
@ -26,23 +28,23 @@ class TestPyLastLibrary(TestPyLastWithLastFm):
|
|||
string = str(library)
|
||||
|
||||
# Assert
|
||||
self.assert_endswith(string, "'s Library")
|
||||
assert string.endswith("'s Library")
|
||||
|
||||
def test_library_is_hashable(self):
|
||||
def test_library_is_hashable(self) -> None:
|
||||
# Arrange
|
||||
library = pylast.Library(user=self.username, network=self.network)
|
||||
|
||||
# Act/Assert
|
||||
self.helper_is_thing_hashable(library)
|
||||
|
||||
def test_cacheable_library(self):
|
||||
def test_cacheable_library(self) -> None:
|
||||
# Arrange
|
||||
library = pylast.Library(self.username, self.network)
|
||||
|
||||
# Act/Assert
|
||||
self.helper_validate_cacheable(library, "get_artists")
|
||||
|
||||
def test_get_user(self):
|
||||
def test_get_user(self) -> None:
|
||||
# Arrange
|
||||
library = pylast.Library(user=self.username, network=self.network)
|
||||
user_to_get = self.network.get_user(self.username)
|
||||
|
|
|
@ -2,18 +2,20 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from flaky import flaky
|
||||
|
||||
import pylast
|
||||
|
||||
from .test_pylast import PyLastTestCase, load_secrets
|
||||
from .test_pylast import load_secrets
|
||||
|
||||
|
||||
@flaky(max_runs=3, min_passes=1)
|
||||
class TestPyLastWithLibreFm(PyLastTestCase):
|
||||
class TestPyLastWithLibreFm:
|
||||
"""Own class for Libre.fm because we don't need the Last.fm setUp"""
|
||||
|
||||
def test_libre_fm(self):
|
||||
def test_libre_fm(self) -> None:
|
||||
# Arrange
|
||||
secrets = load_secrets()
|
||||
username = secrets["username"]
|
||||
|
@ -27,7 +29,7 @@ class TestPyLastWithLibreFm(PyLastTestCase):
|
|||
# Assert
|
||||
assert name == "Radiohead"
|
||||
|
||||
def test_repr(self):
|
||||
def test_repr(self) -> None:
|
||||
# Arrange
|
||||
secrets = load_secrets()
|
||||
username = secrets["username"]
|
||||
|
@ -38,4 +40,4 @@ class TestPyLastWithLibreFm(PyLastTestCase):
|
|||
representation = repr(network)
|
||||
|
||||
# Assert
|
||||
self.assert_startswith(representation, "pylast.LibreFMNetwork(")
|
||||
assert representation.startswith("pylast.LibreFMNetwork(")
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import time
|
||||
|
||||
|
@ -14,7 +16,7 @@ from .test_pylast import WRITE_TEST, TestPyLastWithLastFm
|
|||
|
||||
class TestPyLastNetwork(TestPyLastWithLastFm):
|
||||
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
|
||||
def test_scrobble(self):
|
||||
def test_scrobble(self) -> None:
|
||||
# Arrange
|
||||
artist = "test artist"
|
||||
title = "test title"
|
||||
|
@ -32,7 +34,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
assert str(last_scrobble.track.title).lower() == title
|
||||
|
||||
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
|
||||
def test_update_now_playing(self):
|
||||
def test_update_now_playing(self) -> None:
|
||||
# Arrange
|
||||
artist = "Test Artist"
|
||||
title = "test title"
|
||||
|
@ -56,7 +58,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
assert len(current_track.info["image"])
|
||||
assert re.search(r"^http.+$", current_track.info["image"][pylast.SIZE_LARGE])
|
||||
|
||||
def test_enable_rate_limiting(self):
|
||||
def test_enable_rate_limiting(self) -> None:
|
||||
# Arrange
|
||||
assert not self.network.is_rate_limited()
|
||||
|
||||
|
@ -73,7 +75,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
assert self.network.is_rate_limited()
|
||||
assert now - then >= 0.2
|
||||
|
||||
def test_disable_rate_limiting(self):
|
||||
def test_disable_rate_limiting(self) -> None:
|
||||
# Arrange
|
||||
self.network.enable_rate_limit()
|
||||
assert self.network.is_rate_limited()
|
||||
|
@ -88,14 +90,14 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert not self.network.is_rate_limited()
|
||||
|
||||
def test_lastfm_network_name(self):
|
||||
def test_lastfm_network_name(self) -> None:
|
||||
# Act
|
||||
name = str(self.network)
|
||||
|
||||
# Assert
|
||||
assert name == "Last.fm Network"
|
||||
|
||||
def test_geo_get_top_artists(self):
|
||||
def test_geo_get_top_artists(self) -> None:
|
||||
# Arrange
|
||||
# Act
|
||||
artists = self.network.get_geo_top_artists(country="United Kingdom", limit=1)
|
||||
|
@ -105,7 +107,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
assert isinstance(artists[0], pylast.TopItem)
|
||||
assert isinstance(artists[0].item, pylast.Artist)
|
||||
|
||||
def test_geo_get_top_tracks(self):
|
||||
def test_geo_get_top_tracks(self) -> None:
|
||||
# Arrange
|
||||
# Act
|
||||
tracks = self.network.get_geo_top_tracks(
|
||||
|
@ -117,7 +119,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
assert isinstance(tracks[0], pylast.TopItem)
|
||||
assert isinstance(tracks[0].item, pylast.Track)
|
||||
|
||||
def test_network_get_top_artists_with_limit(self):
|
||||
def test_network_get_top_artists_with_limit(self) -> None:
|
||||
# Arrange
|
||||
# Act
|
||||
artists = self.network.get_top_artists(limit=1)
|
||||
|
@ -125,7 +127,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
self.helper_only_one_thing_in_top_list(artists, pylast.Artist)
|
||||
|
||||
def test_network_get_top_tags_with_limit(self):
|
||||
def test_network_get_top_tags_with_limit(self) -> None:
|
||||
# Arrange
|
||||
# Act
|
||||
tags = self.network.get_top_tags(limit=1)
|
||||
|
@ -133,7 +135,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
self.helper_only_one_thing_in_top_list(tags, pylast.Tag)
|
||||
|
||||
def test_network_get_top_tags_with_no_limit(self):
|
||||
def test_network_get_top_tags_with_no_limit(self) -> None:
|
||||
# Arrange
|
||||
# Act
|
||||
tags = self.network.get_top_tags()
|
||||
|
@ -141,7 +143,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
self.helper_at_least_one_thing_in_top_list(tags, pylast.Tag)
|
||||
|
||||
def test_network_get_top_tracks_with_limit(self):
|
||||
def test_network_get_top_tracks_with_limit(self) -> None:
|
||||
# Arrange
|
||||
# Act
|
||||
tracks = self.network.get_top_tracks(limit=1)
|
||||
|
@ -149,7 +151,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
self.helper_only_one_thing_in_top_list(tracks, pylast.Track)
|
||||
|
||||
def test_country_top_tracks(self):
|
||||
def test_country_top_tracks(self) -> None:
|
||||
# Arrange
|
||||
country = self.network.get_country("Croatia")
|
||||
|
||||
|
@ -159,7 +161,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
self.helper_two_different_things_in_top_list(things, pylast.Track)
|
||||
|
||||
def test_country_network_top_tracks(self):
|
||||
def test_country_network_top_tracks(self) -> None:
|
||||
# Arrange
|
||||
# Act
|
||||
things = self.network.get_geo_top_tracks("Croatia", limit=2)
|
||||
|
@ -167,7 +169,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
self.helper_two_different_things_in_top_list(things, pylast.Track)
|
||||
|
||||
def test_tag_top_tracks(self):
|
||||
def test_tag_top_tracks(self) -> None:
|
||||
# Arrange
|
||||
tag = self.network.get_tag("blues")
|
||||
|
||||
|
@ -177,7 +179,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
self.helper_two_different_things_in_top_list(things, pylast.Track)
|
||||
|
||||
def test_album_data(self):
|
||||
def test_album_data(self) -> None:
|
||||
# Arrange
|
||||
thing = self.network.get_album("Test Artist", "Test Album")
|
||||
|
||||
|
@ -197,7 +199,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
assert playcount > 1
|
||||
assert "https://www.last.fm/music/test%2bartist/test%2balbum" == url
|
||||
|
||||
def test_track_data(self):
|
||||
def test_track_data(self) -> None:
|
||||
# Arrange
|
||||
thing = self.network.get_track("Test Artist", "test title")
|
||||
|
||||
|
@ -218,7 +220,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
assert playcount > 1
|
||||
assert "https://www.last.fm/fr/music/test%2bartist/_/test%2btitle" == url
|
||||
|
||||
def test_country_top_artists(self):
|
||||
def test_country_top_artists(self) -> None:
|
||||
# Arrange
|
||||
country = self.network.get_country("Ukraine")
|
||||
|
||||
|
@ -228,7 +230,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
self.helper_only_one_thing_in_top_list(artists, pylast.Artist)
|
||||
|
||||
def test_caching(self):
|
||||
def test_caching(self) -> None:
|
||||
# Arrange
|
||||
user = self.network.get_user("RJ")
|
||||
|
||||
|
@ -243,9 +245,9 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
self.network.disable_caching()
|
||||
assert not self.network.is_caching_enabled()
|
||||
|
||||
def test_album_mbid(self):
|
||||
def test_album_mbid(self) -> None:
|
||||
# Arrange
|
||||
mbid = "a6a265bf-9f81-4055-8224-f7ac0aa6b937"
|
||||
mbid = "03c91c40-49a6-44a7-90e7-a700edf97a62"
|
||||
|
||||
# Act
|
||||
album = self.network.get_album_by_mbid(mbid)
|
||||
|
@ -253,10 +255,10 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
|
||||
# Assert
|
||||
assert isinstance(album, pylast.Album)
|
||||
assert album.title.lower() == "test"
|
||||
assert album.title == "Believe"
|
||||
assert album_mbid == mbid
|
||||
|
||||
def test_artist_mbid(self):
|
||||
def test_artist_mbid(self) -> None:
|
||||
# Arrange
|
||||
mbid = "7e84f845-ac16-41fe-9ff8-df12eb32af55"
|
||||
|
||||
|
@ -265,9 +267,9 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
|
||||
# Assert
|
||||
assert isinstance(artist, pylast.Artist)
|
||||
assert artist.name == "MusicBrainz Test Artist"
|
||||
assert artist.name in ("MusicBrainz Test Artist", "MusicBrainzz Test Artist")
|
||||
|
||||
def test_track_mbid(self):
|
||||
def test_track_mbid(self) -> None:
|
||||
# Arrange
|
||||
mbid = "ebc037b1-cc9c-44f2-a21f-83c219f0e1e0"
|
||||
|
||||
|
@ -280,7 +282,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
assert track.title == "first"
|
||||
assert track_mbid == mbid
|
||||
|
||||
def test_init_with_token(self):
|
||||
def test_init_with_token(self) -> None:
|
||||
# Arrange/Act
|
||||
msg = None
|
||||
try:
|
||||
|
@ -295,20 +297,19 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert msg == "Unauthorized Token - This token has not been issued"
|
||||
|
||||
def test_proxy(self):
|
||||
def test_proxy(self) -> None:
|
||||
# Arrange
|
||||
host = "https://example.com"
|
||||
port = 1234
|
||||
proxy = "http://example.com:1234"
|
||||
|
||||
# Act / Assert
|
||||
self.network.enable_proxy(host, port)
|
||||
self.network.enable_proxy(proxy)
|
||||
assert self.network.is_proxy_enabled()
|
||||
assert self.network._get_proxy() == ["https://example.com", 1234]
|
||||
assert self.network.proxy == "http://example.com:1234"
|
||||
|
||||
self.network.disable_proxy()
|
||||
assert not self.network.is_proxy_enabled()
|
||||
|
||||
def test_album_search(self):
|
||||
def test_album_search(self) -> None:
|
||||
# Arrange
|
||||
album = "Nevermind"
|
||||
|
||||
|
@ -320,7 +321,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
assert isinstance(results, list)
|
||||
assert isinstance(results[0], pylast.Album)
|
||||
|
||||
def test_album_search_images(self):
|
||||
def test_album_search_images(self) -> None:
|
||||
# Arrange
|
||||
album = "Nevermind"
|
||||
search = self.network.search_for_album(album)
|
||||
|
@ -332,15 +333,15 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert len(images) == 4
|
||||
|
||||
self.assert_startswith(images[pylast.SIZE_SMALL], "https://")
|
||||
self.assert_endswith(images[pylast.SIZE_SMALL], ".png")
|
||||
assert images[pylast.SIZE_SMALL].startswith("https://")
|
||||
assert images[pylast.SIZE_SMALL].endswith(".png")
|
||||
assert "/34s/" in images[pylast.SIZE_SMALL]
|
||||
|
||||
self.assert_startswith(images[pylast.SIZE_EXTRA_LARGE], "https://")
|
||||
self.assert_endswith(images[pylast.SIZE_EXTRA_LARGE], ".png")
|
||||
assert images[pylast.SIZE_EXTRA_LARGE].startswith("https://")
|
||||
assert images[pylast.SIZE_EXTRA_LARGE].endswith(".png")
|
||||
assert "/300x300/" in images[pylast.SIZE_EXTRA_LARGE]
|
||||
|
||||
def test_artist_search(self):
|
||||
def test_artist_search(self) -> None:
|
||||
# Arrange
|
||||
artist = "Nirvana"
|
||||
|
||||
|
@ -352,7 +353,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
assert isinstance(results, list)
|
||||
assert isinstance(results[0], pylast.Artist)
|
||||
|
||||
def test_artist_search_images(self):
|
||||
def test_artist_search_images(self) -> None:
|
||||
# Arrange
|
||||
artist = "Nirvana"
|
||||
search = self.network.search_for_artist(artist)
|
||||
|
@ -364,15 +365,15 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert len(images) == 5
|
||||
|
||||
self.assert_startswith(images[pylast.SIZE_SMALL], "https://")
|
||||
self.assert_endswith(images[pylast.SIZE_SMALL], ".png")
|
||||
assert images[pylast.SIZE_SMALL].startswith("https://")
|
||||
assert images[pylast.SIZE_SMALL].endswith(".png")
|
||||
assert "/34s/" in images[pylast.SIZE_SMALL]
|
||||
|
||||
self.assert_startswith(images[pylast.SIZE_EXTRA_LARGE], "https://")
|
||||
self.assert_endswith(images[pylast.SIZE_EXTRA_LARGE], ".png")
|
||||
assert images[pylast.SIZE_EXTRA_LARGE].startswith("https://")
|
||||
assert images[pylast.SIZE_EXTRA_LARGE].endswith(".png")
|
||||
assert "/300x300/" in images[pylast.SIZE_EXTRA_LARGE]
|
||||
|
||||
def test_track_search(self):
|
||||
def test_track_search(self) -> None:
|
||||
# Arrange
|
||||
artist = "Nirvana"
|
||||
track = "Smells Like Teen Spirit"
|
||||
|
@ -385,7 +386,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
assert isinstance(results, list)
|
||||
assert isinstance(results[0], pylast.Track)
|
||||
|
||||
def test_track_search_images(self):
|
||||
def test_track_search_images(self) -> None:
|
||||
# Arrange
|
||||
artist = "Nirvana"
|
||||
track = "Smells Like Teen Spirit"
|
||||
|
@ -398,15 +399,15 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert len(images) == 4
|
||||
|
||||
self.assert_startswith(images[pylast.SIZE_SMALL], "https://")
|
||||
self.assert_endswith(images[pylast.SIZE_SMALL], ".png")
|
||||
assert images[pylast.SIZE_SMALL].startswith("https://")
|
||||
assert images[pylast.SIZE_SMALL].endswith(".png")
|
||||
assert "/34s/" in images[pylast.SIZE_SMALL]
|
||||
|
||||
self.assert_startswith(images[pylast.SIZE_EXTRA_LARGE], "https://")
|
||||
self.assert_endswith(images[pylast.SIZE_EXTRA_LARGE], ".png")
|
||||
assert images[pylast.SIZE_EXTRA_LARGE].startswith("https://")
|
||||
assert images[pylast.SIZE_EXTRA_LARGE].endswith(".png")
|
||||
assert "/300x300/" in images[pylast.SIZE_EXTRA_LARGE]
|
||||
|
||||
def test_search_get_total_result_count(self):
|
||||
def test_search_get_total_result_count(self) -> None:
|
||||
# Arrange
|
||||
artist = "Nirvana"
|
||||
track = "Smells Like Teen Spirit"
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
@ -11,7 +12,7 @@ from flaky import flaky
|
|||
|
||||
import pylast
|
||||
|
||||
WRITE_TEST = sys.version_info[:2] == (3, 9)
|
||||
WRITE_TEST = False
|
||||
|
||||
|
||||
def load_secrets(): # pragma: no cover
|
||||
|
@ -33,29 +34,21 @@ def load_secrets(): # pragma: no cover
|
|||
return doc
|
||||
|
||||
|
||||
class PyLastTestCase:
|
||||
def assert_startswith(self, s, prefix, start=None, end=None):
|
||||
assert s.startswith(prefix, start, end)
|
||||
|
||||
def assert_endswith(self, s, suffix, start=None, end=None):
|
||||
assert s.endswith(suffix, start, end)
|
||||
|
||||
|
||||
def _no_xfail_rerun_filter(err, name, test, plugin):
|
||||
def _no_xfail_rerun_filter(err, name, test, plugin) -> bool:
|
||||
for _ in test.iter_markers(name="xfail"):
|
||||
return False
|
||||
|
||||
|
||||
@flaky(max_runs=3, min_passes=1, rerun_filter=_no_xfail_rerun_filter)
|
||||
class TestPyLastWithLastFm(PyLastTestCase):
|
||||
|
||||
class TestPyLastWithLastFm:
|
||||
secrets = None
|
||||
|
||||
def unix_timestamp(self):
|
||||
@staticmethod
|
||||
def unix_timestamp() -> int:
|
||||
return int(time.time())
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
def setup_class(cls) -> None:
|
||||
if cls.secrets is None:
|
||||
cls.secrets = load_secrets()
|
||||
|
||||
|
@ -72,7 +65,8 @@ class TestPyLastWithLastFm(PyLastTestCase):
|
|||
password_hash=password_hash,
|
||||
)
|
||||
|
||||
def helper_is_thing_hashable(self, thing):
|
||||
@staticmethod
|
||||
def helper_is_thing_hashable(thing) -> None:
|
||||
# Arrange
|
||||
things = set()
|
||||
|
||||
|
@ -83,7 +77,8 @@ class TestPyLastWithLastFm(PyLastTestCase):
|
|||
assert thing is not None
|
||||
assert len(things) == 1
|
||||
|
||||
def helper_validate_results(self, a, b, c):
|
||||
@staticmethod
|
||||
def helper_validate_results(a, b, c) -> None:
|
||||
# Assert
|
||||
assert a is not None
|
||||
assert b is not None
|
||||
|
@ -94,7 +89,7 @@ class TestPyLastWithLastFm(PyLastTestCase):
|
|||
assert a == b
|
||||
assert b == c
|
||||
|
||||
def helper_validate_cacheable(self, thing, function_name):
|
||||
def helper_validate_cacheable(self, thing, function_name) -> None:
|
||||
# Arrange
|
||||
# get thing.function_name()
|
||||
func = getattr(thing, function_name, None)
|
||||
|
@ -107,27 +102,31 @@ class TestPyLastWithLastFm(PyLastTestCase):
|
|||
# Assert
|
||||
self.helper_validate_results(result1, result2, result3)
|
||||
|
||||
def helper_at_least_one_thing_in_top_list(self, things, expected_type):
|
||||
@staticmethod
|
||||
def helper_at_least_one_thing_in_top_list(things, expected_type) -> None:
|
||||
# Assert
|
||||
assert len(things) > 1
|
||||
assert isinstance(things, list)
|
||||
assert isinstance(things[0], pylast.TopItem)
|
||||
assert isinstance(things[0].item, expected_type)
|
||||
|
||||
def helper_only_one_thing_in_top_list(self, things, expected_type):
|
||||
@staticmethod
|
||||
def helper_only_one_thing_in_top_list(things, expected_type) -> None:
|
||||
# Assert
|
||||
assert len(things) == 1
|
||||
assert isinstance(things, list)
|
||||
assert isinstance(things[0], pylast.TopItem)
|
||||
assert isinstance(things[0].item, expected_type)
|
||||
|
||||
def helper_only_one_thing_in_list(self, things, expected_type):
|
||||
@staticmethod
|
||||
def helper_only_one_thing_in_list(things, expected_type) -> None:
|
||||
# Assert
|
||||
assert len(things) == 1
|
||||
assert isinstance(things, list)
|
||||
assert isinstance(things[0], expected_type)
|
||||
|
||||
def helper_two_different_things_in_top_list(self, things, expected_type):
|
||||
@staticmethod
|
||||
def helper_two_different_things_in_top_list(things, expected_type) -> None:
|
||||
# Assert
|
||||
assert len(things) == 2
|
||||
thing1 = things[0]
|
||||
|
|
|
@ -2,20 +2,22 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import pylast
|
||||
|
||||
from .test_pylast import TestPyLastWithLastFm
|
||||
|
||||
|
||||
class TestPyLastTag(TestPyLastWithLastFm):
|
||||
def test_tag_is_hashable(self):
|
||||
def test_tag_is_hashable(self) -> None:
|
||||
# Arrange
|
||||
tag = self.network.get_top_tags(limit=1)[0]
|
||||
|
||||
# Act/Assert
|
||||
self.helper_is_thing_hashable(tag)
|
||||
|
||||
def test_tag_top_artists(self):
|
||||
def test_tag_top_artists(self) -> None:
|
||||
# Arrange
|
||||
tag = self.network.get_tag("blues")
|
||||
|
||||
|
@ -25,7 +27,7 @@ class TestPyLastTag(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
self.helper_only_one_thing_in_top_list(artists, pylast.Artist)
|
||||
|
||||
def test_tag_top_albums(self):
|
||||
def test_tag_top_albums(self) -> None:
|
||||
# Arrange
|
||||
tag = self.network.get_tag("blues")
|
||||
|
||||
|
@ -35,7 +37,7 @@ class TestPyLastTag(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
self.helper_only_one_thing_in_top_list(albums, pylast.Album)
|
||||
|
||||
def test_tags(self):
|
||||
def test_tags(self) -> None:
|
||||
# Arrange
|
||||
tag1 = self.network.get_tag("blues")
|
||||
tag2 = self.network.get_tag("rock")
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
@ -13,7 +15,7 @@ from .test_pylast import WRITE_TEST, TestPyLastWithLastFm
|
|||
|
||||
class TestPyLastTrack(TestPyLastWithLastFm):
|
||||
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
|
||||
def test_love(self):
|
||||
def test_love(self) -> None:
|
||||
# Arrange
|
||||
artist = "Test Artist"
|
||||
title = "test title"
|
||||
|
@ -29,7 +31,7 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
|||
assert str(loved[0].track.title).lower() == "test title"
|
||||
|
||||
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
|
||||
def test_unlove(self):
|
||||
def test_unlove(self) -> None:
|
||||
# Arrange
|
||||
artist = pylast.Artist("Test Artist", self.network)
|
||||
title = "test title"
|
||||
|
@ -47,7 +49,7 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
|||
assert str(loved[0].track.artist) != "Test Artist"
|
||||
assert str(loved[0].track.title) != "test title"
|
||||
|
||||
def test_user_play_count_in_track_info(self):
|
||||
def test_user_play_count_in_track_info(self) -> None:
|
||||
# Arrange
|
||||
artist = "Test Artist"
|
||||
title = "test title"
|
||||
|
@ -61,7 +63,7 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert count >= 0
|
||||
|
||||
def test_user_loved_in_track_info(self):
|
||||
def test_user_loved_in_track_info(self) -> None:
|
||||
# Arrange
|
||||
artist = "Test Artist"
|
||||
title = "test title"
|
||||
|
@ -77,7 +79,7 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
|||
assert isinstance(loved, bool)
|
||||
assert not isinstance(loved, str)
|
||||
|
||||
def test_track_is_hashable(self):
|
||||
def test_track_is_hashable(self) -> None:
|
||||
# Arrange
|
||||
artist = self.network.get_artist("Test Artist")
|
||||
track = artist.get_top_tracks(stream=False)[0].item
|
||||
|
@ -86,7 +88,7 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
|||
# Act/Assert
|
||||
self.helper_is_thing_hashable(track)
|
||||
|
||||
def test_track_wiki_content(self):
|
||||
def test_track_wiki_content(self) -> None:
|
||||
# Arrange
|
||||
track = pylast.Track("Test Artist", "test title", self.network)
|
||||
|
||||
|
@ -97,7 +99,7 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
|||
assert wiki is not None
|
||||
assert len(wiki) >= 1
|
||||
|
||||
def test_track_wiki_summary(self):
|
||||
def test_track_wiki_summary(self) -> None:
|
||||
# Arrange
|
||||
track = pylast.Track("Test Artist", "test title", self.network)
|
||||
|
||||
|
@ -108,37 +110,17 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
|||
assert wiki is not None
|
||||
assert len(wiki) >= 1
|
||||
|
||||
def test_track_get_duration(self):
|
||||
def test_track_get_duration(self) -> None:
|
||||
# Arrange
|
||||
track = pylast.Track("Nirvana", "Lithium", self.network)
|
||||
track = pylast.Track("Daft Punk", "Something About Us", self.network)
|
||||
|
||||
# Act
|
||||
duration = track.get_duration()
|
||||
|
||||
# Assert
|
||||
assert duration >= 200000
|
||||
assert duration >= 100000
|
||||
|
||||
def test_track_is_streamable(self):
|
||||
# Arrange
|
||||
track = pylast.Track("Nirvana", "Lithium", self.network)
|
||||
|
||||
# Act
|
||||
streamable = track.is_streamable()
|
||||
|
||||
# Assert
|
||||
assert not streamable
|
||||
|
||||
def test_track_is_fulltrack_available(self):
|
||||
# Arrange
|
||||
track = pylast.Track("Nirvana", "Lithium", self.network)
|
||||
|
||||
# Act
|
||||
fulltrack_available = track.is_fulltrack_available()
|
||||
|
||||
# Assert
|
||||
assert not fulltrack_available
|
||||
|
||||
def test_track_get_album(self):
|
||||
def test_track_get_album(self) -> None:
|
||||
# Arrange
|
||||
track = pylast.Track("Nirvana", "Lithium", self.network)
|
||||
|
||||
|
@ -148,7 +130,7 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert str(album) == "Nirvana - Nevermind"
|
||||
|
||||
def test_track_get_similar(self):
|
||||
def test_track_get_similar(self) -> None:
|
||||
# Arrange
|
||||
track = pylast.Track("Cher", "Believe", self.network)
|
||||
|
||||
|
@ -156,14 +138,10 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
|||
similar = track.get_similar()
|
||||
|
||||
# Assert
|
||||
found = False
|
||||
for track in similar:
|
||||
if str(track.item) == "Madonna - Vogue":
|
||||
found = True
|
||||
break
|
||||
found = any(str(track.item) == "Cher - Strong Enough" for track in similar)
|
||||
assert found
|
||||
|
||||
def test_track_get_similar_limits(self):
|
||||
def test_track_get_similar_limits(self) -> None:
|
||||
# Arrange
|
||||
track = pylast.Track("Cher", "Believe", self.network)
|
||||
|
||||
|
@ -173,7 +151,7 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
|||
assert len(track.get_similar(limit=None)) >= 23
|
||||
assert len(track.get_similar(limit=0)) >= 23
|
||||
|
||||
def test_tracks_notequal(self):
|
||||
def test_tracks_notequal(self) -> None:
|
||||
# Arrange
|
||||
track1 = pylast.Track("Test Artist", "test title", self.network)
|
||||
track2 = pylast.Track("Test Artist", "Test Track", self.network)
|
||||
|
@ -182,7 +160,7 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert track1 != track2
|
||||
|
||||
def test_track_title_prop_caps(self):
|
||||
def test_track_title_prop_caps(self) -> None:
|
||||
# Arrange
|
||||
track = pylast.Track("test artist", "test title", self.network)
|
||||
|
||||
|
@ -192,7 +170,7 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert title == "Test Title"
|
||||
|
||||
def test_track_listener_count(self):
|
||||
def test_track_listener_count(self) -> None:
|
||||
# Arrange
|
||||
track = pylast.Track("test artist", "test title", self.network)
|
||||
|
||||
|
@ -202,7 +180,7 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert count > 21
|
||||
|
||||
def test_album_tracks(self):
|
||||
def test_album_tracks(self) -> None:
|
||||
# Arrange
|
||||
album = pylast.Album("Test Artist", "Test", self.network)
|
||||
|
||||
|
@ -216,7 +194,7 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
|||
assert len(tracks) == 1
|
||||
assert url.startswith("https://www.last.fm/music/test")
|
||||
|
||||
def test_track_eq_none_is_false(self):
|
||||
def test_track_eq_none_is_false(self) -> None:
|
||||
# Arrange
|
||||
track1 = None
|
||||
track2 = pylast.Track("Test Artist", "test title", self.network)
|
||||
|
@ -224,7 +202,7 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
|||
# Act / Assert
|
||||
assert track1 != track2
|
||||
|
||||
def test_track_ne_none_is_true(self):
|
||||
def test_track_ne_none_is_true(self) -> None:
|
||||
# Arrange
|
||||
track1 = None
|
||||
track2 = pylast.Track("Test Artist", "test title", self.network)
|
||||
|
@ -232,7 +210,7 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
|||
# Act / Assert
|
||||
assert track1 != track2
|
||||
|
||||
def test_track_get_correction(self):
|
||||
def test_track_get_correction(self) -> None:
|
||||
# Arrange
|
||||
track = pylast.Track("Guns N' Roses", "mrbrownstone", self.network)
|
||||
|
||||
|
@ -242,7 +220,7 @@ class TestPyLastTrack(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert corrected_track_name == "Mr. Brownstone"
|
||||
|
||||
def test_track_with_no_mbid(self):
|
||||
def test_track_with_no_mbid(self) -> None:
|
||||
# Arrange
|
||||
track = pylast.Track("Static-X", "Set It Off", self.network)
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
"""
|
||||
Integration (not unit) tests for pylast.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import calendar
|
||||
import datetime as dt
|
||||
import inspect
|
||||
|
@ -16,7 +18,7 @@ from .test_pylast import TestPyLastWithLastFm
|
|||
|
||||
|
||||
class TestPyLastUser(TestPyLastWithLastFm):
|
||||
def test_repr(self):
|
||||
def test_repr(self) -> None:
|
||||
# Arrange
|
||||
user = self.network.get_user("RJ")
|
||||
|
||||
|
@ -24,9 +26,9 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
representation = repr(user)
|
||||
|
||||
# Assert
|
||||
self.assert_startswith(representation, "pylast.User('RJ',")
|
||||
assert representation.startswith("pylast.User('RJ',")
|
||||
|
||||
def test_str(self):
|
||||
def test_str(self) -> None:
|
||||
# Arrange
|
||||
user = self.network.get_user("RJ")
|
||||
|
||||
|
@ -36,7 +38,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert string == "RJ"
|
||||
|
||||
def test_equality(self):
|
||||
def test_equality(self) -> None:
|
||||
# Arrange
|
||||
user_1a = self.network.get_user("RJ")
|
||||
user_1b = self.network.get_user("RJ")
|
||||
|
@ -48,7 +50,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
assert user_1a != user_2
|
||||
assert user_1a != not_a_user
|
||||
|
||||
def test_get_name(self):
|
||||
def test_get_name(self) -> None:
|
||||
# Arrange
|
||||
user = self.network.get_user("RJ")
|
||||
|
||||
|
@ -58,7 +60,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert name == "RJ"
|
||||
|
||||
def test_get_user_registration(self):
|
||||
def test_get_user_registration(self) -> None:
|
||||
# Arrange
|
||||
user = self.network.get_user("RJ")
|
||||
|
||||
|
@ -74,7 +76,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Just check date because of timezones
|
||||
assert "2002-11-20 " in registered
|
||||
|
||||
def test_get_user_unixtime_registration(self):
|
||||
def test_get_user_unixtime_registration(self) -> None:
|
||||
# Arrange
|
||||
user = self.network.get_user("RJ")
|
||||
|
||||
|
@ -85,7 +87,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Just check date because of timezones
|
||||
assert unixtime_registered == 1037793040
|
||||
|
||||
def test_get_countryless_user(self):
|
||||
def test_get_countryless_user(self) -> None:
|
||||
# Arrange
|
||||
# Currently test_user has no country set:
|
||||
lastfm_user = self.network.get_user("test_user")
|
||||
|
@ -96,7 +98,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert country is None
|
||||
|
||||
def test_user_get_country(self):
|
||||
def test_user_get_country(self) -> None:
|
||||
# Arrange
|
||||
lastfm_user = self.network.get_user("RJ")
|
||||
|
||||
|
@ -106,7 +108,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert str(country) == "United Kingdom"
|
||||
|
||||
def test_user_equals_none(self):
|
||||
def test_user_equals_none(self) -> None:
|
||||
# Arrange
|
||||
lastfm_user = self.network.get_user(self.username)
|
||||
|
||||
|
@ -116,7 +118,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert not value
|
||||
|
||||
def test_user_not_equal_to_none(self):
|
||||
def test_user_not_equal_to_none(self) -> None:
|
||||
# Arrange
|
||||
lastfm_user = self.network.get_user(self.username)
|
||||
|
||||
|
@ -126,7 +128,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert value
|
||||
|
||||
def test_now_playing_user_with_no_scrobbles(self):
|
||||
def test_now_playing_user_with_no_scrobbles(self) -> None:
|
||||
# Arrange
|
||||
# Currently test-account has no scrobbles:
|
||||
user = self.network.get_user("test-account")
|
||||
|
@ -137,7 +139,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert current_track is None
|
||||
|
||||
def test_love_limits(self):
|
||||
def test_love_limits(self) -> None:
|
||||
# Arrange
|
||||
# Currently test-account has at least 23 loved tracks:
|
||||
user = self.network.get_user("test-user")
|
||||
|
@ -148,7 +150,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
assert len(user.get_loved_tracks(limit=None)) >= 23
|
||||
assert len(user.get_loved_tracks(limit=0)) >= 23
|
||||
|
||||
def test_user_is_hashable(self):
|
||||
def test_user_is_hashable(self) -> None:
|
||||
# Arrange
|
||||
user = self.network.get_user(self.username)
|
||||
|
||||
|
@ -169,7 +171,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# # Assert
|
||||
# self.assertGreaterEqual(len(tracks), 0)
|
||||
|
||||
def test_pickle(self):
|
||||
def test_pickle(self) -> None:
|
||||
# Arrange
|
||||
import pickle
|
||||
|
||||
|
@ -187,7 +189,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
assert lastfm_user == loaded_user
|
||||
|
||||
@pytest.mark.xfail
|
||||
def test_cacheable_user(self):
|
||||
def test_cacheable_user(self) -> None:
|
||||
# Arrange
|
||||
lastfm_user = self.network.get_authenticated_user()
|
||||
|
||||
|
@ -201,7 +203,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
lastfm_user, "get_recent_tracks"
|
||||
)
|
||||
|
||||
def test_user_get_top_tags_with_limit(self):
|
||||
def test_user_get_top_tags_with_limit(self) -> None:
|
||||
# Arrange
|
||||
user = self.network.get_user("RJ")
|
||||
|
||||
|
@ -211,7 +213,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
self.helper_only_one_thing_in_top_list(tags, pylast.Tag)
|
||||
|
||||
def test_user_top_tracks(self):
|
||||
def test_user_top_tracks(self) -> None:
|
||||
# Arrange
|
||||
lastfm_user = self.network.get_user("RJ")
|
||||
|
||||
|
@ -221,14 +223,14 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
self.helper_two_different_things_in_top_list(things, pylast.Track)
|
||||
|
||||
def helper_assert_chart(self, chart, expected_type):
|
||||
def helper_assert_chart(self, chart, expected_type) -> None:
|
||||
# Assert
|
||||
assert chart is not None
|
||||
assert len(chart) > 0
|
||||
assert isinstance(chart[0], pylast.TopItem)
|
||||
assert isinstance(chart[0].item, expected_type)
|
||||
|
||||
def helper_get_assert_charts(self, thing, date):
|
||||
def helper_get_assert_charts(self, thing, date) -> None:
|
||||
# Arrange
|
||||
album_chart, track_chart = None, None
|
||||
(from_date, to_date) = date
|
||||
|
@ -245,14 +247,14 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
self.helper_assert_chart(album_chart, pylast.Album)
|
||||
self.helper_assert_chart(track_chart, pylast.Track)
|
||||
|
||||
def helper_dates_valid(self, dates):
|
||||
def helper_dates_valid(self, dates) -> None:
|
||||
# Assert
|
||||
assert len(dates) >= 1
|
||||
assert isinstance(dates[0], tuple)
|
||||
(start, end) = dates[0]
|
||||
assert start < end
|
||||
|
||||
def test_user_charts(self):
|
||||
def test_user_charts(self) -> None:
|
||||
# Arrange
|
||||
lastfm_user = self.network.get_user("RJ")
|
||||
dates = lastfm_user.get_weekly_chart_dates()
|
||||
|
@ -261,7 +263,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Act/Assert
|
||||
self.helper_get_assert_charts(lastfm_user, dates[0])
|
||||
|
||||
def test_user_top_artists(self):
|
||||
def test_user_top_artists(self) -> None:
|
||||
# Arrange
|
||||
lastfm_user = self.network.get_user(self.username)
|
||||
|
||||
|
@ -271,7 +273,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
self.helper_only_one_thing_in_top_list(artists, pylast.Artist)
|
||||
|
||||
def test_user_top_albums(self):
|
||||
def test_user_top_albums(self) -> None:
|
||||
# Arrange
|
||||
user = self.network.get_user("RJ")
|
||||
|
||||
|
@ -285,7 +287,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
assert len(top_album.info["image"])
|
||||
assert re.search(r"^http.+$", top_album.info["image"][pylast.SIZE_LARGE])
|
||||
|
||||
def test_user_tagged_artists(self):
|
||||
def test_user_tagged_artists(self) -> None:
|
||||
# Arrange
|
||||
lastfm_user = self.network.get_user(self.username)
|
||||
tags = ["artisttagola"]
|
||||
|
@ -298,7 +300,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
self.helper_only_one_thing_in_list(artists, pylast.Artist)
|
||||
|
||||
def test_user_tagged_albums(self):
|
||||
def test_user_tagged_albums(self) -> None:
|
||||
# Arrange
|
||||
lastfm_user = self.network.get_user(self.username)
|
||||
tags = ["albumtagola"]
|
||||
|
@ -311,7 +313,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
self.helper_only_one_thing_in_list(albums, pylast.Album)
|
||||
|
||||
def test_user_tagged_tracks(self):
|
||||
def test_user_tagged_tracks(self) -> None:
|
||||
# Arrange
|
||||
lastfm_user = self.network.get_user(self.username)
|
||||
tags = ["tracktagola"]
|
||||
|
@ -324,7 +326,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
self.helper_only_one_thing_in_list(tracks, pylast.Track)
|
||||
|
||||
def test_user_subscriber(self):
|
||||
def test_user_subscriber(self) -> None:
|
||||
# Arrange
|
||||
subscriber = self.network.get_user("RJ")
|
||||
non_subscriber = self.network.get_user("Test User")
|
||||
|
@ -337,7 +339,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
assert subscriber_is_subscriber
|
||||
assert not non_subscriber_is_subscriber
|
||||
|
||||
def test_user_get_image(self):
|
||||
def test_user_get_image(self) -> None:
|
||||
# Arrange
|
||||
user = self.network.get_user("RJ")
|
||||
|
||||
|
@ -345,9 +347,9 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
url = user.get_image()
|
||||
|
||||
# Assert
|
||||
self.assert_startswith(url, "https://")
|
||||
assert url.startswith("https://")
|
||||
|
||||
def test_user_get_library(self):
|
||||
def test_user_get_library(self) -> None:
|
||||
# Arrange
|
||||
user = self.network.get_user(self.username)
|
||||
|
||||
|
@ -357,7 +359,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert isinstance(library, pylast.Library)
|
||||
|
||||
def test_get_recent_tracks_from_to(self):
|
||||
def test_get_recent_tracks_from_to(self) -> None:
|
||||
# Arrange
|
||||
lastfm_user = self.network.get_user("RJ")
|
||||
start = dt.datetime(2011, 7, 21, 15, 10)
|
||||
|
@ -374,7 +376,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
assert str(tracks[0].track.artist) == "Johnny Cash"
|
||||
assert str(tracks[0].track.title) == "Ring of Fire"
|
||||
|
||||
def test_get_recent_tracks_limit_none(self):
|
||||
def test_get_recent_tracks_limit_none(self) -> None:
|
||||
# Arrange
|
||||
lastfm_user = self.network.get_user("bbc6music")
|
||||
start = dt.datetime(2020, 2, 15, 15, 00)
|
||||
|
@ -393,7 +395,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
assert str(tracks[0].track.artist) == "Seun Kuti & Egypt 80"
|
||||
assert str(tracks[0].track.title) == "Struggles Sounds"
|
||||
|
||||
def test_get_recent_tracks_is_streamable(self):
|
||||
def test_get_recent_tracks_is_streamable(self) -> None:
|
||||
# Arrange
|
||||
lastfm_user = self.network.get_user("bbc6music")
|
||||
start = dt.datetime(2020, 2, 15, 15, 00)
|
||||
|
@ -410,7 +412,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert inspect.isgenerator(tracks)
|
||||
|
||||
def test_get_playcount(self):
|
||||
def test_get_playcount(self) -> None:
|
||||
# Arrange
|
||||
user = self.network.get_user("RJ")
|
||||
|
||||
|
@ -420,7 +422,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert playcount >= 128387
|
||||
|
||||
def test_get_image(self):
|
||||
def test_get_image(self) -> None:
|
||||
# Arrange
|
||||
user = self.network.get_user("RJ")
|
||||
|
||||
|
@ -428,10 +430,10 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
image = user.get_image()
|
||||
|
||||
# Assert
|
||||
self.assert_startswith(image, "https://")
|
||||
self.assert_endswith(image, ".png")
|
||||
assert image.startswith("https://")
|
||||
assert image.endswith(".png")
|
||||
|
||||
def test_get_url(self):
|
||||
def test_get_url(self) -> None:
|
||||
# Arrange
|
||||
user = self.network.get_user("RJ")
|
||||
|
||||
|
@ -441,7 +443,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
# Assert
|
||||
assert url == "https://www.last.fm/user/rj"
|
||||
|
||||
def test_get_weekly_artist_charts(self):
|
||||
def test_get_weekly_artist_charts(self) -> None:
|
||||
# Arrange
|
||||
user = self.network.get_user("bbc6music")
|
||||
|
||||
|
@ -453,7 +455,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
assert artist is not None
|
||||
assert isinstance(artist.network, pylast.LastFMNetwork)
|
||||
|
||||
def test_get_weekly_track_charts(self):
|
||||
def test_get_weekly_track_charts(self) -> None:
|
||||
# Arrange
|
||||
user = self.network.get_user("bbc6music")
|
||||
|
||||
|
@ -465,7 +467,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
assert track is not None
|
||||
assert isinstance(track.network, pylast.LastFMNetwork)
|
||||
|
||||
def test_user_get_track_scrobbles(self):
|
||||
def test_user_get_track_scrobbles(self) -> None:
|
||||
# Arrange
|
||||
artist = "France Gall"
|
||||
title = "Laisse Tomber Les Filles"
|
||||
|
@ -479,7 +481,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
|
|||
assert str(scrobbles[0].track.artist) == "France Gall"
|
||||
assert scrobbles[0].track.title == "Laisse Tomber Les Filles"
|
||||
|
||||
def test_cacheable_user_get_track_scrobbles(self):
|
||||
def test_cacheable_user_get_track_scrobbles(self) -> None:
|
||||
# Arrange
|
||||
artist = "France Gall"
|
||||
title = "Laisse Tomber Les Filles"
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
@ -18,12 +20,51 @@ def mock_network():
|
|||
"fdasfdsafsaf not unicode",
|
||||
],
|
||||
)
|
||||
def test_get_cache_key(artist):
|
||||
def test_get_cache_key(artist) -> None:
|
||||
request = pylast._Request(mock_network(), "some_method", params={"artist": artist})
|
||||
request._get_cache_key()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("obj", [pylast.Artist("B\xe9l", mock_network())])
|
||||
def test_cast_and_hash(obj):
|
||||
assert type(str(obj)) is str
|
||||
def test_cast_and_hash(obj) -> None:
|
||||
assert isinstance(str(obj), str)
|
||||
assert isinstance(hash(obj), int)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"test_input, expected",
|
||||
[
|
||||
(
|
||||
# Plain text
|
||||
'<album mbid="">test album name</album>',
|
||||
'<album mbid="">test album name</album>',
|
||||
),
|
||||
(
|
||||
# Contains Unicode ENQ Enquiry control character
|
||||
'<album mbid="">test album \u0005name</album>',
|
||||
'<album mbid="">test album name</album>',
|
||||
),
|
||||
],
|
||||
)
|
||||
def test__remove_invalid_xml_chars(test_input: str, expected: str) -> None:
|
||||
assert pylast._remove_invalid_xml_chars(test_input) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"test_input, expected",
|
||||
[
|
||||
(
|
||||
# Plain text
|
||||
'<album mbid="">test album name</album>',
|
||||
'<?xml version="1.0" ?><album mbid="">test album name</album>',
|
||||
),
|
||||
(
|
||||
# Contains Unicode ENQ Enquiry control character
|
||||
'<album mbid="">test album \u0005name</album>',
|
||||
'<?xml version="1.0" ?><album mbid="">test album name</album>',
|
||||
),
|
||||
],
|
||||
)
|
||||
def test__parse_response(test_input: str, expected: str) -> None:
|
||||
doc = pylast._parse_response(test_input)
|
||||
assert doc.toxml() == expected
|
||||
|
|
41
tox.ini
41
tox.ini
|
@ -1,29 +1,40 @@
|
|||
[tox]
|
||||
envlist =
|
||||
py{py3, 310, 39, 38, 37, 36}
|
||||
requires =
|
||||
tox>=4.2
|
||||
env_list =
|
||||
lint
|
||||
py{py3, 313, 312, 311, 310, 39, 38}
|
||||
|
||||
[testenv]
|
||||
passenv =
|
||||
extras =
|
||||
tests
|
||||
pass_env =
|
||||
FORCE_COLOR
|
||||
PYLAST_API_KEY
|
||||
PYLAST_API_SECRET
|
||||
PYLAST_PASSWORD_HASH
|
||||
PYLAST_USERNAME
|
||||
extras =
|
||||
tests
|
||||
commands =
|
||||
pytest -v -s -W all --cov pylast --cov tests --cov-report term-missing --random-order {posargs}
|
||||
{envpython} -m pytest -v -s -W all \
|
||||
--cov pylast \
|
||||
--cov tests \
|
||||
--cov-report html \
|
||||
--cov-report term-missing \
|
||||
--cov-report xml \
|
||||
--random-order \
|
||||
{posargs}
|
||||
|
||||
[testenv:lint]
|
||||
skip_install = true
|
||||
deps =
|
||||
pre-commit
|
||||
pass_env =
|
||||
PRE_COMMIT_COLOR
|
||||
commands =
|
||||
pre-commit run --all-files --show-diff-on-failure
|
||||
|
||||
[testenv:venv]
|
||||
deps =
|
||||
ipdb
|
||||
commands =
|
||||
{posargs}
|
||||
|
||||
[testenv:lint]
|
||||
passenv =
|
||||
PRE_COMMIT_COLOR
|
||||
skip_install = true
|
||||
deps =
|
||||
pre-commit
|
||||
commands =
|
||||
pre-commit run --all-files --show-diff-on-failure
|
||||
|
|
Loading…
Reference in a new issue