Merge pull request #134 from MarshalX/development

0.0.14
このコミットが含まれているのは:
Il'ya 2019-11-10 03:53:03 +03:00 committed by GitHub
コミット d8f5f49161
この署名に対応する既知のキーがデータベースに存在しません
GPGキーID: 4AEE18F83AFDEB23
192個のファイルの変更5599行の追加259行の削除

26
.github/ISSUE_TEMPLATE/bug-report.md vendored ノーマルファイル
ファイルの表示

@ -0,0 +1,26 @@
---
name: Bug report
about: Создать отчёт об ошибке
title: ''
labels: bug
assignees: MarshalX
---
**Опишите ошибку**
Четкое и краткое описание бага.
**Воспроизведение**
Шаги для воспроизведения бага:
1. Создать объект '...'
2. Вызвать метод '....'
3. Увидеть ошибку
**Ожидаемое поведение**
Четкое и краткое описание того, что должно произойти при корректном выполнении.
**Логи**
Если это возможно, прикрепите сообщения об ошибке и полученный стектрэйс.
**Дополнительная информация**
Добавьте любой другой контекст о проблеме здесь.

38
.github/workflows/codecov.yml vendored ノーマルファイル
ファイルの表示

@ -0,0 +1,38 @@
name: Codecov
on:
push:
branches:
- master
jobs:
pytest:
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.8]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pipenv
pipenv install --dev --deploy --system
shell: bash
- name: Test with pytest and generate coverage
run: |
pytest -v --cov=./
shell: bash
- name: Submit coverage
run: |
if [ "$CODECOV_TOKEN" != "" ]; then
codecov -F github -t $CODECOV_TOKEN --name "${{ matrix.os }}-${{ matrix.python-version }}"
fi
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
shell: bash

30
.github/workflows/full_test.yml vendored ノーマルファイル
ファイルの表示

@ -0,0 +1,30 @@
name: Full test
on:
pull_request:
branches:
- master
jobs:
pytest:
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: [3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pipenv
pipenv install --dev --deploy --system
shell: bash
- name: Test with pytest
run: |
pytest -vv
shell: bash

29
.github/workflows/pypi.yml vendored ノーマルファイル
ファイルの表示

@ -0,0 +1,29 @@
name: Upload to PyPI
on:
release:
types: [created]
jobs:
deploy:
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: [3.8]
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pipenv
pipenv install --dev --deploy --system
shell: bash
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
shell: bash

33
.github/workflows/test.yml vendored ノーマルファイル
ファイルの表示

@ -0,0 +1,33 @@
name: Test
on:
pull_request:
branches:
- development
push:
branches:
- '**'
jobs:
pytest:
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.8]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pipenv
pipenv install --dev --deploy --system
shell: bash
- name: Test with pytest
run: |
pytest -vv
shell: bash

38
CHANGES.rst ノーマルファイル
ファイルの表示

@ -0,0 +1,38 @@
================
Список изменений
================
Версия 0.0.14
=============
**10.11.2019**
**Переломные изменения**
- Практически у всех классов был обновлён список полей участвующих при сравнении объектов.
- Если в атрибутах для стравнения объектов присутствуют списки, то они будут преобразованы к frozenset.
- Убрано конвертирование даты из строки в объект. Теперь все даты представляны строками в ISO формате.
- Классы ``AlbumSearchResult``, ``ArtistSearchResult``, ``PlaylistSearchResult``, ``TrackSearchResult``, ``VideoSearchResult`` были объединены в один - ``SearchResult``.
**Крупные изменения**
- Добавлен метод получения треков исполнителя (`#123`_).
- Добавлены классы-обёртки над пагинацией (``Pager``) и списка треков артиста (``ArtistsTracks``).
- Добавлено **554** unit-теста для всех классов-обёрток над объектами API.
- Добавлен codecov и workflows для GitHub Actions.
.. _`#123`: https://github.com/MarshalX/yandex-music-api/pull/123
**Незначительные изменения и/или исправления**
- Поле ``cover_uri`` класса ``Album`` теперь опциональное.
- Поле ``region`` у класса Account теперь не обязательное.
- Исправлен баг в ``.to_dict()`` методе, связанный с десериализцией объектов списков и словарей.
- Исправлен баг в ``.to_dict()`` методе, связанный с не рекурсивной десериализацией.
- Исправлена десериализация ``similar_artists`` в ``BriefInfo``.
- Исправлен баг с десериализацией ``artist`` в классе ``ArtistEvent``.
- Исправлен баг десериализации списка альбомов и артистов у класса ``Track`` (`#122`_).
- Исправлена загрузка обложки у трека.
- Исправлены сравнения объектов.
.. _`#122`: https://github.com/MarshalX/yandex-music-api/pull/122

ファイルの表示

@ -7,6 +7,9 @@ verify_ssl = true
coverage = "*"
sphinx = "*"
sphinx_rtd_theme = "*"
pytest = "*"
pytest-cov = "*"
codecov = "*"
[packages]
requests = "*"

147
Pipfile.lock generated
ファイルの表示

@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "f9430ebaa1035fbd08d344d843fe5c5f021c7bdc2bd1ad2b4ea28bf06ba376c8"
"sha256": "c889ddb9cbefe66436c2a82bf83cac14e9a8f1a85ad8b2e9d0d8aa891f33a5fc"
},
"pipfile-spec": 6,
"requires": {
@ -18,10 +18,10 @@
"default": {
"certifi": {
"hashes": [
"sha256:046832c04d4e752f37383b628bc601a7ea7211496b4638f6514d0e5b9acc4939",
"sha256:945e3ba63a0b9f577b1395204e13c3a231f9bc0223888be653286534e5873695"
"sha256:e4f3620cfea4f83eedc95b24abd9cd56f3c4b146dd0177e83a21b4eb49e21e50",
"sha256:fd7c7c74727ddcf00e9acd26bba8da604ffec95bf1c2144e67aff7a8b50e6cef"
],
"version": "==2019.6.16"
"version": "==2019.9.11"
},
"chardet": {
"hashes": [
@ -47,10 +47,10 @@
},
"urllib3": {
"hashes": [
"sha256:b246607a25ac80bedac05c6f282e3cdaf3afb65420fd024ac94435cabe6e18d1",
"sha256:dbe59173209418ae49d485b87d1681aefa36252ee85884c31346debd19463232"
"sha256:3de946ffbed6e6746608990594d08faac602528ac7015ac28d33cee6a45b7398",
"sha256:9a107b99a5393caf59c7aa3c1249c16e6879447533d0887f4336dde834c7be86"
],
"version": "==1.25.3"
"version": "==1.25.6"
}
},
"develop": {
@ -61,12 +61,19 @@
],
"version": "==0.7.12"
},
"atomicwrites": {
"hashes": [
"sha256:03472c30eb2c5d1ba9227e4c2ca66ab8287fbfbbda3888aa93dc2e28fc6811b4",
"sha256:75a9445bac02d8d058d5e1fe689654ba5a6556a1dfd8ce6ec55a0ed79866cfa6"
],
"version": "==1.3.0"
},
"attrs": {
"hashes": [
"sha256:69c0dbf2ed392de1cb5ec704444b08a5ef81680a61cb899dc08127123af36a79",
"sha256:f0b870f674851ecbfbbbd364d6b5cbdff9dcedbc7f3f5e18a6891057f21fe399"
"sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c",
"sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72"
],
"version": "==19.1.0"
"version": "==19.3.0"
},
"babel": {
"hashes": [
@ -77,10 +84,10 @@
},
"certifi": {
"hashes": [
"sha256:046832c04d4e752f37383b628bc601a7ea7211496b4638f6514d0e5b9acc4939",
"sha256:945e3ba63a0b9f577b1395204e13c3a231f9bc0223888be653286534e5873695"
"sha256:e4f3620cfea4f83eedc95b24abd9cd56f3c4b146dd0177e83a21b4eb49e21e50",
"sha256:fd7c7c74727ddcf00e9acd26bba8da604ffec95bf1c2144e67aff7a8b50e6cef"
],
"version": "==2019.6.16"
"version": "==2019.9.11"
},
"chardet": {
"hashes": [
@ -89,6 +96,14 @@
],
"version": "==3.0.4"
},
"codecov": {
"hashes": [
"sha256:8ed8b7c6791010d359baed66f84f061bba5bd41174bf324c31311e8737602788",
"sha256:ae00d68e18d8a20e9c3288ba3875ae03db3a8e892115bf9b83ef20507732bed4"
],
"index": "pypi",
"version": "==2.0.15"
},
"coverage": {
"hashes": [
"sha256:08907593569fe59baca0bf152c43f3863201efb6113ecb38ce7e97ce339805a6",
@ -149,12 +164,20 @@
],
"version": "==1.1.0"
},
"importlib-metadata": {
"hashes": [
"sha256:aa18d7378b00b40847790e7c27e11673d7fed219354109d0e7b9e5b25dc3ad26",
"sha256:d5f18a79777f3aa179c145737780282e27b508fc8fd688cb17c7a813e8bd39af"
],
"markers": "python_version < '3.8'",
"version": "==0.23"
},
"jinja2": {
"hashes": [
"sha256:065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013",
"sha256:14dd6caf1527abb21f08f86c784eac40853ba93edb79552aa1e4b8aef1b61c7b"
"sha256:74320bb91f31270f9551d46522e33af46a80c3d619f4a4bf42b3164d30b5911f",
"sha256:9fe95f19286cfefaa917656583d020be14e7859c6b0252588391e47db34527de"
],
"version": "==2.10.1"
"version": "==2.10.3"
},
"markupsafe": {
"hashes": [
@ -189,12 +212,33 @@
],
"version": "==1.1.1"
},
"more-itertools": {
"hashes": [
"sha256:409cd48d4db7052af495b09dec721011634af3753ae1ef92d2b32f73a745f832",
"sha256:92b8c4b06dac4f0611c0729b2f2ede52b2e1bac1ab48f089c7ddc12e26bb60c4"
],
"version": "==7.2.0"
},
"packaging": {
"hashes": [
"sha256:a7ac867b97fdc07ee80a8058fe4435ccd274ecc3b0ed61d852d7d53055528cf9",
"sha256:c491ca87294da7cc01902edbe30a5bc6c4c28172b5138ab4e4aa1b9d7bfaeafe"
"sha256:28b924174df7a2fa32c1953825ff29c61e2f5e082343165438812f00d3a7fc47",
"sha256:d9551545c6d761f3def1677baf08ab2a3ca17c56879e70fecba2fc4dde4ed108"
],
"version": "==19.1"
"version": "==19.2"
},
"pluggy": {
"hashes": [
"sha256:0db4b7601aae1d35b4a033282da476845aa19185c1e6964b25cf324b5e4ec3e6",
"sha256:fa5fa1622fa6dd5c030e9cad086fa19ef6a0cf6d7a2d12318e10cb49d6d68f34"
],
"version": "==0.13.0"
},
"py": {
"hashes": [
"sha256:64f65755aee5b381cea27766a3a147c3f15b9b6b9ac88676de66ba2ae36793fa",
"sha256:dc639b046a6e2cff5bbe40194ad65936d6ba360b52b3c3fe1d08a82dd50b5e53"
],
"version": "==1.8.0"
},
"pygments": {
"hashes": [
@ -205,17 +249,33 @@
},
"pyparsing": {
"hashes": [
"sha256:6f98a7b9397e206d78cc01df10131398f1c8b8510a2f4d97d9abd82e1aacdd80",
"sha256:d9338df12903bbf5d65a0e4e87c2161968b10d2e489652bb47001d82a9b028b4"
"sha256:4acadc9a2b96c19fe00932a38ca63e601180c39a189a696abce1eaab641447e1",
"sha256:61b5ed888beab19ddccab3478910e2076a6b5a0295dffc43021890e136edf764"
],
"version": "==2.4.2"
"version": "==2.4.4"
},
"pytest": {
"hashes": [
"sha256:27abc3fef618a01bebb1f0d6d303d2816a99aa87a5968ebc32fe971be91eb1e6",
"sha256:58cee9e09242937e136dbb3dab466116ba20d6b7828c7620f23947f37eb4dae4"
],
"index": "pypi",
"version": "==5.2.2"
},
"pytest-cov": {
"hashes": [
"sha256:cc6742d8bac45070217169f5f72ceee1e0e55b0221f54bcf24845972d3a47f2b",
"sha256:cdbdef4f870408ebdbfeb44e63e07eb18bb4619fae852f6e760645fa36172626"
],
"index": "pypi",
"version": "==2.8.1"
},
"pytz": {
"hashes": [
"sha256:26c0b32e437e54a18161324a2fca3c4b9846b74a8dccddd843113109e1116b32",
"sha256:c894d57500a4cd2d5c71114aaab77dbab5eabd9022308ce5ac9bb93a60a6f0c7"
"sha256:1c557d7d0e871de1f5ccd5833f60fb2550652da6be2693c1e02300743d21500d",
"sha256:b02c06db6cf09c12dd25137e563b31700d3b80fcc4ad23abb7a315f2789819be"
],
"version": "==2019.2"
"version": "==2019.3"
},
"requests": {
"hashes": [
@ -227,24 +287,25 @@
},
"six": {
"hashes": [
"sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c",
"sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"
"sha256:1f1b7d42e254082a9db6279deae68afb421ceba6158efa6131de7b3003ee93fd",
"sha256:30f610279e8b2578cab6db20741130331735c781b56053c59c4076da27f06b66"
],
"version": "==1.12.0"
"version": "==1.13.0"
},
"snowballstemmer": {
"hashes": [
"sha256:9f3b9ffe0809d174f7047e121431acf99c89a7040f0ca84f94ba53a498e6d0c9"
"sha256:209f257d7533fdb3cb73bdbd24f436239ca3b2fa67d56f6ff88e86be08cc5ef0",
"sha256:df3bac3df4c2c01363f3dd2cfa78cce2840a79b9f1c2d2de9ce8d31683992f52"
],
"version": "==1.9.0"
"version": "==2.0.0"
},
"sphinx": {
"hashes": [
"sha256:0d586b0f8c2fc3cc6559c5e8fd6124628110514fda0e5d7c82e682d749d2e845",
"sha256:839a3ed6f6b092bb60f492024489cc9e6991360fb9f52ed6361acd510d261069"
"sha256:31088dfb95359384b1005619827eaee3056243798c62724fd3fa4b84ee4d71bd",
"sha256:52286a0b9d7caa31efee301ec4300dbdab23c3b05da1c9024b4e84896fb73d79"
],
"index": "pypi",
"version": "==2.2.0"
"version": "==2.2.1"
},
"sphinx-rtd-theme": {
"hashes": [
@ -298,10 +359,24 @@
},
"urllib3": {
"hashes": [
"sha256:b246607a25ac80bedac05c6f282e3cdaf3afb65420fd024ac94435cabe6e18d1",
"sha256:dbe59173209418ae49d485b87d1681aefa36252ee85884c31346debd19463232"
"sha256:3de946ffbed6e6746608990594d08faac602528ac7015ac28d33cee6a45b7398",
"sha256:9a107b99a5393caf59c7aa3c1249c16e6879447533d0887f4336dde834c7be86"
],
"version": "==1.25.3"
"version": "==1.25.6"
},
"wcwidth": {
"hashes": [
"sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e",
"sha256:f4ebe71925af7b40a864553f761ed559b43544f8f71746c2d756c7fe788ade7c"
],
"version": "==0.1.7"
},
"zipp": {
"hashes": [
"sha256:3718b1cbcd963c7d4c5511a8240812904164b7f381b647143a89d3b98f9bcd8e",
"sha256:f06903e9f1f43b12d371004b4ac7b06ab39a44adc747266928ae6debfa7b3335"
],
"version": "==0.6.0"
}
}
}

ファイルの表示

@ -1,24 +1,42 @@
[Pre-Alpha] Неофициальная Python библиотека для API Yandex Music
================================================================
Делаю то, что по каким-то причинам не сделала компания Yandex.
Делаю то, что по определённым причинам не сделала компания Yandex.
Маленькое сообщество разработчиков общаются и помогают друг другу в `Telegram чатике <https://t.me/yandex_music_api>`_, присоединяйтесь!
.. image:: https://img.shields.io/pypi/v/yandex-music.svg
:target: https://pypi.org/project/yandex-music/
:alt: Версия пакета PyPi
.. image:: https://img.shields.io/badge/python-3.7%2B-blue.svg
.. image:: https://img.shields.io/badge/python-3.6%20|%203.7%20|%203.8-blue.svg
:target: https://pypi.org/project/yandex-music/
:alt: Поддерживаемые Python версии
.. image:: https://codecov.io/gh/MarshalX/yandex-music-api/branch/development/graph/badge.svg
:target: https://codecov.io/gh/MarshalX/yandex-music-api
:alt: Покрытие кода тестами
.. image:: https://api.codacy.com/project/badge/Grade/27011a5a8d9f4b278d1bfe2fe8725fed
:target: https://www.codacy.com/manual/MarshalX/yandex-music-api
:alt: Качество кода
.. image:: https://github.com/MarshalX/yandex-music-api/workflows/Full%20test/badge.svg
:target: https://github.com/MarshalX/yandex-music-api/actions?query=workflow%3A%22Full+test%22
:alt: Статус тестов
.. image:: https://readthedocs.org/projects/yandex-music/badge/?version=latest
:target: https://yandex-music.readthedocs.io/ru/latest/?badge=latest
:alt: Статус документации
:target: https://yandex-music.readthedocs.io/ru/latest/?badge=latest
:alt: Статус документации
.. image:: https://img.shields.io/badge/license-LGPLv3-lightgrey.svg
:target: https://www.gnu.org/licenses/lgpl-3.0.html
:alt: Лицензия LGPLv3
.. image:: https://img.shields.io/badge/telegram-чат-blue.svg
:target: https://t.me/yandex_music_api
:alt: Telegram чат
==========
Содержание
@ -38,6 +56,8 @@
#. `Документация`_
- `Получение помощи`_
- `Благодарность`_
- `Лицензия`_
@ -49,7 +69,7 @@
Эта библиотека предоставляется Python интерфейс для никем
незадокументированного и сделанного только для себя API Яндекс Музыки.
Она совместима с версиями Python 3.7+.
Она совместима с версиями Python 3.6+.
В дополнение к реализации чистого API данная библиотека имеет ряд
классов-обёрток объектов высокого уровня дабы сделать разработку клиентов
@ -205,6 +225,16 @@ music.yandex.ru/album/**1193829**/track/**10994777**
Документация ``yandex-music-api`` находится в стадии написания и расположена на
`readthedocs.io <https://yandex-music.readthedocs.io/>`_.
================
Получение помощи
================
Получить помощь можно несколькими путями:
- Задать вопрос в `Telegram чатике <https://t.me/yandex_music_api>`_, где мы помогаем друг другу, присоединяйтесь!
- Сообщить о баге, предложить новую фичу или задать вопрос можно `создав issue <https://github.com/MarshalX/yandex-music-api/issues/new/choose>`_.
- Найти ответ на вопрос в `документации библиотеки <https://yandex-music.readthedocs.io/ru/latest/>`_.
=============
Благодарность
=============

13
SECURITY.md ノーマルファイル
ファイルの表示

@ -0,0 +1,13 @@
# Политика безопасности
## Поддерживаемые версии
| Версия | Поддержка |
| ------- | ------------------ |
| 0.0.13 | :white_check_mark: |
| < 0.0.13 | :x: |
## Сообщение об уязвимости
Все отчёты об уязвимостях в проекте или в его зависимостях отправляйте на почту Ilya@marshal.by.
Обратная связь и получение обновлений о состоянии уязвимости через неё.

1
docs/source/changes.rst ノーマルファイル
ファイルの表示

@ -0,0 +1 @@
.. include:: ../../CHANGES.rst

ファイルの表示

@ -10,3 +10,4 @@
readme
yandex_music
changes

ファイルの表示

@ -0,0 +1,7 @@
yandex_music.ArtistTracks
=========================
.. autoclass:: yandex_music.ArtistTracks
:members:
:undoc-members:
:show-inheritance:

7
docs/source/yandex_music.artist.pager.rst ノーマルファイル
ファイルの表示

@ -0,0 +1,7 @@
yandex_music.Pager
==================
.. autoclass:: yandex_music.Pager
:members:
:undoc-members:
:show-inheritance:

ファイルの表示

@ -9,3 +9,6 @@
yandex_music.artist.ratings
yandex_music.artist.vinyl
yandex_music.artist.description
yandex_music.artist.brief_info
yandex_music.artist.artist_tracks
yandex_music.artist.pager

4
requirements-dev.txt ノーマルファイル
ファイルの表示

@ -0,0 +1,4 @@
requests
pytest
codecov
pytest-cov

ファイルの表示

@ -16,13 +16,13 @@ packages = find_packages(exclude=['tests*'])
with open('README.rst', 'r', encoding='utf-8') as f:
setup(name='yandex-music',
version='0.0.13',
version='0.0.14',
author='Il`ya Semyonov',
author_email='Ilya@marshal.by',
license='LGPLv3',
url='https://github.com/MarshalX/yandex-music-api/',
keywords='python yandex music api wrapper library питон яндекс музыка апи обёртка библиотека',
description="Делаю то, что по каким-то причинам не сделала компания Yandex.",
description="Делаю то, что по определённым причинам не сделала компания Yandex.",
long_description=f.read(),
packages=packages,
install_requires=requirements(),
@ -37,6 +37,7 @@ with open('README.rst', 'r', encoding='utf-8') as f:
'Topic :: Multimedia :: Sound/Audio',
'Topic :: Internet',
'Programming Language :: Python',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8'
],)

71
tests/__init__.py ノーマルファイル
ファイルの表示

@ -0,0 +1,71 @@
from .test_account import TestAccount
from .test_ad_params import TestAdParams
from .test_album import TestAlbum
from .test_album_event import TestAlbumEvent
from .test_artist import TestArtist
from .test_artist_event import TestArtistEvent
from .test_auto_renewable import TestAutoRenewable
from .test_best import TestBest
from .test_block import TestBlock
from .test_block_entity import TestBlockEntity
from .test_case_forms import TestCaseForms
from .test_chart import TestChart
from .test_counts import TestCounts
from .test_cover import TestCover
from .test_day import TestDay
from .test_description import TestDescription
from .test_discrete_scale import TestDiscreteScale
from .test_enum import TestEnum
from .test_event import TestEvent
from .test_generated_playlist import TestGeneratedPlaylist
from .test_genre import TestGenre
from .test_icon import TestIcon
from .test_id import TestId
from .test_images import TestImages
from .test_invocation_info import TestInvocationInfo
from .test_label import TestLabel
from .test_link import TestLink
from .test_link import TestLink
from .test_lyrics import TestLyrics
from .test_made_for import TestMadeFor
from .test_major import TestMajor
from .test_mix_link import TestMixLink
from .test_normalization import TestNormalization
from .test_pager import TestPager
from .test_passport_phone import TestPassportPhone
from .test_permissions import TestPermissions
from .test_personal_playlists_data import TestPersonalPlaylistsData
from .test_play_context import TestPlayContext
from .test_play_contexts_data import TestPlayContextsData
from .test_play_counter import TestPlayCounter
from .test_playlist import TestPlaylist
from .test_playlist_id import TestPlaylistId
from .test_playlist_id import TestPlaylistId
from .test_plus import TestPlus
from .test_price import TestPrice
from .test_product import TestProduct
from .test_promotion import TestPromotion
from .test_ratings import TestRatings
from .test_restrictions import TestRestrictions
from .test_rotor_settings import TestRotorSettings
from .test_search_result import TestSearchResult
from .test_sequence import TestSequence
from .test_settings import TestSettings
from .test_station import TestStation
from .test_station_result import TestStationResult
from .test_status import TestStatus
from .test_subscription import TestSubscription
from .test_suggestions import TestSuggestions
from .test_title import TestTitle
from .test_track import TestTrack
from .test_track_id import TestTrackId
from .test_track_position import TestTrackPosition
from .test_track_short import TestTrackShort
from .test_track_short_old import TestTrackShortOld
from .test_track_with_ads import TestTrackWithAds
from .test_user import TestUser
from .test_value import TestValue
from .test_value import TestValue
from .test_video import TestVideo
from .test_video_supplement import TestVideoSupplement
from .test_vinyl import TestVinyl

536
tests/conftest.py ノーマルファイル
ファイルの表示

@ -0,0 +1,536 @@
import pytest
from yandex_music import Counts, TrackId, CaseForms, Ratings, Icon, Album, Lyrics, Track, InvocationInfo, Playlist, \
AutoRenewable, Station, MadeFor, Normalization, Major, TrackPosition, Best, Chart, Restrictions, Permissions, \
Product, Cover, PlayCounter, Sequence, Price, Artist, AdParams, Description, Subscription, Id, Images, Pager, \
Account, Client, TrackShort, Value, DiscreteScale, PlaylistId, MixLink, Link, PassportPhone, User, Promotion, \
PersonalPlaylistsData, RotorSettings, TrackShortOld, PlayContextsData, Status, Settings, StationResult, Enum, \
TrackWithAds, VideoSupplement, ArtistEvent, ChartItem, Event, AlbumEvent, Day, PlayContext, Plus, Title, Label, \
GeneratedPlaylist, Video, Vinyl, SearchResult, BlockEntity, Block
from . import TestCounts, TestTrackId, TestCaseForms, TestRatings, TestIcon, TestAlbum, TestLyrics, \
TestTrack, TestInvocationInfo, TestPlaylist, TestAutoRenewable, TestStation, TestNormalization, TestMajor, \
TestTrackPosition, TestBest, TestChart, TestPermissions, TestPlus, TestProduct, TestCover, TestPlayCounter, \
TestSequence, TestPrice, TestArtist, TestAdParams, TestDescription, TestSubscription, TestId, TestImages, \
TestDiscreteScale, TestAccount, TestTrackShort, TestEnum, TestValue, TestPlaylistId, TestMixLink, TestLink, \
TestUser, TestPassportPhone, TestPromotion, TestTitle, TestPersonalPlaylistsData, TestRotorSettings, \
TestTrackShortOld, TestPager, TestStatus, TestSettings, TestStationResult, TestLabel, TestTrackWithAds, \
TestVideoSupplement, TestEvent, TestDay, TestPlayContext, TestGeneratedPlaylist, TestVideo, TestVinyl, \
TestSearchResult, TestBlockEntity, TestBlock
@pytest.fixture(scope='session')
def artist_factory(cover, counts, ratings, link, description):
class ArtistFactory:
def get(self, popular_tracks):
return Artist(TestArtist.id, TestArtist.name, TestArtist.various, TestArtist.composer, cover,
TestArtist.genres, TestArtist.op_image, TestArtist.no_pictures_from_search, counts,
TestArtist.available, ratings, [link], TestArtist.tickets_available, TestArtist.likes_count,
popular_tracks, TestArtist.regions, TestArtist.decomposed, TestArtist.full_names, description,
TestArtist.countries, TestArtist.en_wikipedia_link, TestArtist.db_aliases, TestArtist.aliases,
TestArtist.init_date, TestArtist.end_date)
return ArtistFactory()
@pytest.fixture(scope='session')
def artist(artist_factory, track_without_artists_and_albums):
return artist_factory.get([track_without_artists_and_albums])
@pytest.fixture(scope='session')
def artist_without_tracks(artist_factory):
return artist_factory.get([])
@pytest.fixture(scope='session')
def track_factory(major, normalization):
class TrackFactory:
def get(self, artists, albums):
return Track(TestTrack.id, TestTrack.title, TestTrack.available, TestTrack.available_for_premium_users,
artists, albums, TestTrack.lyrics_available, TestTrack.real_id, TestTrack.og_image,
TestTrack.type, TestTrack.cover_uri, major, TestTrack.duration_ms, TestTrack.storage_dir,
TestTrack.file_size, normalization, TestTrack.error, TestTrack.regions,
TestTrack.available_as_rbt, TestTrack.content_warning, TestTrack.explicit,
TestTrack.preview_duration_ms, TestTrack.available_full_without_permission)
return TrackFactory()
@pytest.fixture(scope='session')
def track(track_factory, artist, album):
return track_factory.get([artist], [album])
@pytest.fixture(scope='session')
def track_without_artists(track_factory, album):
return track_factory.get([], [album])
@pytest.fixture(scope='session')
def track_without_albums(track_factory, artist):
return track_factory.get([artist], [])
@pytest.fixture(scope='session')
def track_without_artists_and_albums(track_factory):
return track_factory.get([], [])
@pytest.fixture(scope='session')
def album_factory(label, track_position):
class AlbumFactory:
def get(self, artists, volumes):
return Album(TestAlbum.id, TestAlbum.title, TestAlbum.track_count, artists, [label],
TestAlbum.available, TestAlbum.available_for_premium_users, TestAlbum.cover_uri,
TestAlbum.content_warning, TestAlbum.original_release_year, TestAlbum.genre,
TestAlbum.og_image, TestAlbum.buy, TestAlbum.recent, TestAlbum.very_important,
TestAlbum.available_for_mobile, TestAlbum.available_partially, TestAlbum.bests,
TestAlbum.prerolls, volumes, TestAlbum.year, TestAlbum.release_date, TestAlbum.type,
track_position, TestAlbum.regions)
return AlbumFactory()
@pytest.fixture(scope='session')
def album(album_factory, artist_without_tracks, track_without_albums):
return album_factory.get([artist_without_tracks], [[track_without_albums]])
@pytest.fixture(scope='session')
def album_without_tracks(album_factory, artist_without_tracks):
return album_factory.get([artist_without_tracks], [])
@pytest.fixture(scope='session')
def playlist_factory(user, cover, made_for, track_short, play_counter):
class PlaylistFactory:
def get(self):
return Playlist(user, TestPlaylist.uid, TestPlaylist.kind, TestPlaylist.title, TestPlaylist.track_count,
cover, made_for, play_counter, TestPlaylist.tags, TestPlaylist.revision,
TestPlaylist.snapshot, TestPlaylist.visibility, TestPlaylist.collective,
TestPlaylist.created, TestPlaylist.modified, TestPlaylist.available, TestPlaylist.is_banner,
TestPlaylist.is_premiere, TestPlaylist.duration_ms, TestPlaylist.og_image, [track_short],
TestPlaylist.prerolls, TestPlaylist.likes_count, TestPlaylist.generated_playlist_type,
TestPlaylist.animated_cover_uri, TestPlaylist.ever_played, TestPlaylist.description,
TestPlaylist.description_formatted, TestPlaylist.is_for_from, TestPlaylist.regions)
return PlaylistFactory()
@pytest.fixture(scope='session')
def playlist(playlist_factory):
return playlist_factory.get()
@pytest.fixture(scope='session')
def generated_playlist(playlist):
return GeneratedPlaylist(TestGeneratedPlaylist.type, TestGeneratedPlaylist.ready,
TestGeneratedPlaylist.notify, playlist)
@pytest.fixture(scope='session')
def client():
return Client()
@pytest.fixture(scope='session')
def track_with_ads(track):
return TrackWithAds(TestTrackWithAds.type, track)
@pytest.fixture(scope='session')
def day(event, track_with_ads, track):
return Day(TestDay.day, [event], [track_with_ads], [track])
@pytest.fixture(scope='session')
def track_short():
return TrackShort(TestTrackShort.id, TestTrackShort.timestamp, TestTrackShort.album_id)
@pytest.fixture(scope='session')
def track_short_old(track_id):
return TrackShortOld(track_id, TestTrackShortOld.timestamp)
@pytest.fixture(scope='session')
def video():
return Video(TestVideo.title, TestVideo.cover, TestVideo.embed_url, TestVideo.provider, TestVideo.provider_video_id,
TestVideo.youtube_url, TestVideo.thumbnail_url, TestVideo.duration, TestVideo.text,
TestVideo.html_auto_play_video_player, TestVideo.regions)
@pytest.fixture(scope='session')
def vinyl():
return Vinyl(TestVinyl.url, TestVinyl.picture, TestVinyl.title, TestVinyl.year, TestVinyl.price, TestVinyl.media)
@pytest.fixture(scope='session')
def play_context(track_short_old):
return PlayContext(TestPlayContext.client_, TestPlayContext.context,
TestPlayContext.context_item, [track_short_old])
@pytest.fixture(scope='session')
def play_contexts_data(track_short_old):
return PlayContextsData([track_short_old])
@pytest.fixture(scope='session')
def enum(value):
return Enum(TestEnum.type, TestEnum.name, [value])
@pytest.fixture(scope='session')
def icon():
return Icon(TestIcon.background_color, TestIcon.image_url)
@pytest.fixture(scope='session')
def cover():
return Cover(TestCover.type, TestCover.uri, TestCover.items_uri, TestCover.dir,
TestCover.version, TestCover.custom, TestCover.prefix, TestCover.error)
@pytest.fixture(scope='session')
def link():
return Link(TestLink.title, TestLink.href, TestLink.type, TestLink.social_network)
@pytest.fixture(scope='session')
def invocation_info():
return InvocationInfo(TestInvocationInfo.hostname, TestInvocationInfo.req_id,
TestInvocationInfo.exec_duration_millis)
@pytest.fixture(scope='session')
def settings(product, price):
return Settings([product], [product], TestSettings.web_payment_url, TestSettings.promo_codes_enabled, price)
@pytest.fixture(scope='session')
def counts():
return Counts(TestCounts.tracks, TestCounts.direct_albums, TestCounts.also_albums, TestCounts.also_tracks)
@pytest.fixture(scope='session')
def description():
return Description(TestDescription.text, TestDescription.url)
@pytest.fixture(scope='session')
def pager():
return Pager(TestPager.total, TestPager.page, TestPager.per_page)
@pytest.fixture(scope='session')
def artist_event(artist, track):
return ArtistEvent(artist, [track], [artist])
@pytest.fixture(scope='session')
def album_event(album, track):
return AlbumEvent(album, [track])
@pytest.fixture(scope='session')
def video_supplement():
return VideoSupplement(TestVideoSupplement.cover, TestVideoSupplement.title, TestVideoSupplement.provider,
TestVideoSupplement.provider_video_id, TestVideoSupplement.url,
TestVideoSupplement.embed_url, TestVideoSupplement.embed)
@pytest.fixture(scope='session')
def ratings():
return Ratings(TestRatings.week, TestRatings.month, TestRatings.day)
@pytest.fixture(scope='session')
def made_for(user, case_forms):
return MadeFor(user, case_forms)
@pytest.fixture(scope='session')
def play_counter():
return PlayCounter(TestPlayCounter.value, TestPlayCounter.description, TestPlayCounter.updated)
@pytest.fixture(scope='session')
def results(playlist):
return [playlist]
@pytest.fixture(scope='session')
def case_forms():
return CaseForms(TestCaseForms.nominative, TestCaseForms.genitive, TestCaseForms.dative,
TestCaseForms.accusative, TestCaseForms.instrumental, TestCaseForms.prepositional)
@pytest.fixture(scope='session')
def lyrics():
return Lyrics(TestLyrics.id, TestLyrics.lyrics, TestLyrics.full_lyrics, TestLyrics.has_rights,
TestLyrics.text_language, TestLyrics.show_translation)
@pytest.fixture(scope='session')
def images():
return Images(TestImages._208x208, TestImages._300x300)
@pytest.fixture(scope='session')
def normalization():
return Normalization(TestNormalization.gain, TestNormalization.peak)
@pytest.fixture(scope='session')
def mix_link():
return MixLink(TestMixLink.title, TestMixLink.url, TestMixLink.url_scheme, TestMixLink.text_color,
TestMixLink.background_color, TestMixLink.background_image_uri, TestMixLink.cover_white)
@pytest.fixture(scope='session')
def title():
return Title(TestTitle.title, TestTitle.full_title)
@pytest.fixture(scope='session')
def personal_playlists_data():
return PersonalPlaylistsData(TestPersonalPlaylistsData.is_wizard_passed)
@pytest.fixture(scope='session')
def promotion():
return Promotion(TestPromotion.promo_id, TestPromotion.title, TestPromotion.subtitle, TestPromotion.heading,
TestPromotion.url, TestPromotion.url_scheme, TestPromotion.text_color, TestPromotion.gradient,
TestPromotion.image)
@pytest.fixture(scope='session')
def discrete_scale(value):
return DiscreteScale(TestDiscreteScale.type, TestDiscreteScale.name, value, value)
@pytest.fixture(scope='session')
def major():
return Major(TestMajor.id, TestMajor.name)
@pytest.fixture(scope='session')
def permissions():
return Permissions(TestPermissions.until, TestPermissions.values, TestPermissions.default)
@pytest.fixture(scope='session')
def auto_renewable(product):
return AutoRenewable(TestAutoRenewable.expires, TestAutoRenewable.vendor, TestAutoRenewable.vendor_help_url,
TestAutoRenewable.product_id, product, TestAutoRenewable.finished, TestAutoRenewable.order_id)
@pytest.fixture(scope='session')
def passport_phone():
return PassportPhone(TestPassportPhone.phone)
@pytest.fixture(scope='session')
def user():
return User(TestUser.uid, TestUser.login, TestUser.name, TestUser.sex, TestUser.verified)
@pytest.fixture(scope='session')
def account(passport_phone):
return Account(TestAccount.now, TestAccount.service_available, TestAccount.region, TestAccount.uid,
TestAccount.login, TestAccount.full_name, TestAccount.second_name, TestAccount.first_name,
TestAccount.display_name, TestAccount.hosted_user, TestAccount.birthday, [passport_phone],
TestAccount.registered_at, TestAccount.has_info_for_app_metrica)
@pytest.fixture(scope='session')
def plus():
return Plus(TestPlus.has_plus, TestPlus.is_tutorial_completed)
@pytest.fixture(scope='session')
def price():
return Price(TestPrice.amount, TestPrice.currency)
@pytest.fixture(scope='session')
def subscription(auto_renewable):
return Subscription([auto_renewable], TestSubscription.can_start_trial, TestSubscription.mcdonalds,
TestSubscription.end)
@pytest.fixture(scope='session')
def rotor_settings():
return RotorSettings(TestRotorSettings.language, TestRotorSettings.diversity, TestRotorSettings.mood,
TestRotorSettings.energy, TestRotorSettings.mood_energy)
@pytest.fixture(scope='session')
def product(price):
return Product(TestProduct.product_id, TestProduct.type, TestProduct.common_period_duration, TestProduct.duration,
TestProduct.trial_duration, price, TestProduct.feature, TestProduct.debug, TestProduct.features,
TestProduct.description, TestProduct.available, TestProduct.trial_available,
TestProduct.vendor_trial_available, TestProduct.button_text, TestProduct.button_additional_text,
TestProduct.payment_method_types)
@pytest.fixture(scope='session')
def playlist_id():
return PlaylistId(TestPlaylistId.uid, TestPlaylistId.kind)
@pytest.fixture(scope='session')
def label():
return Label(TestLabel.id, TestLabel.name)
@pytest.fixture(scope='session')
def track_position():
return TrackPosition(TestTrackPosition.volume, TestTrackPosition.index)
@pytest.fixture(scope='session')
def status(account, permissions, subscription, plus):
return Status(account, permissions, subscription, TestStatus.cache_limit, TestStatus.subeditor,
TestStatus.subeditor_level, plus, TestStatus.default_email, TestStatus.skips_per_hour,
TestStatus.station_exists, TestStatus.premium_region)
@pytest.fixture(scope='session')
def chart(track_id):
return Chart(TestChart.position, TestChart.progress, TestChart.listeners, TestChart.shift, track_id)
@pytest.fixture(scope='session')
def event(track, artist_event, album_event):
return Event(TestEvent.id, TestEvent.type, TestEvent.type_for_from, TestEvent.title, [track], [artist_event],
[album_event], TestEvent.message, TestEvent.device, TestEvent.tracks_count)
@pytest.fixture(scope='session')
def track_id():
return TrackId(TestTrackId.id, TestTrackId.album_id)
@pytest.fixture(scope='session')
def value():
return Value(TestValue.value, TestValue.name)
@pytest.fixture(scope='session')
def id():
return Id(TestId.type, TestId.tag)
@pytest.fixture(scope='session')
def sequence(track):
return Sequence(TestSequence.type, track, TestSequence.liked)
@pytest.fixture(scope='session')
def station(id, icon, restrictions):
return Station(id, TestStation.name, icon, icon, icon, TestStation.id_for_from, restrictions, restrictions, id)
@pytest.fixture(scope='session')
def chart_item(track, chart):
return ChartItem(track, chart)
@pytest.fixture(scope='session')
def station_result(station, rotor_settings, ad_params):
return StationResult(station, rotor_settings, rotor_settings, ad_params, TestStationResult.explanation,
TestStationResult.prerolls)
@pytest.fixture(scope='session')
def ad_params():
return AdParams(TestAdParams.partner_id, TestAdParams.category_id, TestAdParams.page_ref, TestAdParams.target_ref,
TestAdParams.other_params, TestAdParams.ad_volume, TestAdParams.genre_id, TestAdParams.genre_name)
@pytest.fixture(scope='session')
def restrictions(enum, discrete_scale):
return Restrictions(enum, enum, discrete_scale, discrete_scale, enum)
@pytest.fixture(scope='session')
def results(track, artist, album, playlist, video, generated_playlist, promotion, chart_item, play_context, mix_link,
personal_playlists_data, play_contexts_data):
return {
1: track,
2: artist,
3: album,
4: playlist,
5: video,
6: generated_playlist,
7: promotion,
8: chart_item,
9: play_context,
10: mix_link,
11: personal_playlists_data,
12: play_contexts_data
}
@pytest.fixture(scope='session')
def types():
return {
1: 'track',
2: 'artist',
3: 'album',
4: 'playlist',
5: 'video',
6: 'personal-playlist',
7: 'promotion',
8: 'chart-item',
9: 'play-context',
10: 'mix-link',
11: 'personal-playlists',
12: 'play-contexts'
}
@pytest.fixture(scope='session', params=[1, 2, 3, 4, 5])
def result_with_type(request, results, types):
return results[request.param], types[request.param]
@pytest.fixture(scope='session', params=[1, 2, 3, 4, 5])
def best(request, results, types):
return Best(types[request.param], results[request.param], TestBest.text)
@pytest.fixture(scope='session', params=[1, 2, 3, 4, 5])
def best_with_result(request, results, types):
return Best(types[request.param], results[request.param], TestBest.text), results[request.param]
@pytest.fixture(scope='session', params=[3, 4, 6, 7, 8, 9, 10])
def block_entity(request, results, types):
return BlockEntity(TestBlockEntity.id, types[request.param], results[request.param])
@pytest.fixture(scope='session')
def block(block_entity, data_with_type):
data, type = data_with_type
return Block(TestBlock.id, type, TestBlock.type_for_from, TestBlock.title, [block_entity],
TestBlock.description, data)
@pytest.fixture(scope='session', params=[11, 12])
def data(request, results):
return results[request.param]
@pytest.fixture(scope='session', params=[11, 12])
def data_with_type(request, results, types):
return results[request.param], types[request.param]
@pytest.fixture(scope='session', params=[1, 2, 3, 4, 5])
def search_result_with_results(request, results):
return SearchResult(TestSearchResult.total, TestSearchResult.per_page,
TestSearchResult.order, [results[request.param]]), [results[request.param]]

70
tests/test_account.py ノーマルファイル
ファイルの表示

@ -0,0 +1,70 @@
from yandex_music import Account
class TestAccount:
now = '2019-11-07T21:49:54+00:00'
region = 149
service_available = True
uid = 1130000002804451
login = 'Ilya@marshal.by'
full_name = 'Семёнов Илья'
second_name = 'Семёнов'
first_name = 'Илья'
display_name = 'Il`ya (Marshal)'
hosted_user = False
birthday = '1999-08-10'
registered_at = '2018-06-10T09:34:22+00:00'
has_info_for_app_metrica = False
def test_expected_values(self, account, passport_phone):
assert account.now == self.now
assert account.region == self.region
assert account.service_available == self.service_available
assert account.uid == self.uid
assert account.login == self.login
assert account.full_name == self.full_name
assert account.second_name == self.second_name
assert account.first_name == self.first_name
assert account.display_name == self.display_name
assert account.hosted_user == self.hosted_user
assert account.birthday == self.birthday
assert account.passport_phones == [passport_phone]
assert account.registered_at == self.registered_at
assert account.has_info_for_app_metrica == self.has_info_for_app_metrica
def test_de_json_required(self, client):
json_dict = {'now': self.now, 'service_available': self.service_available}
account = Account.de_json(json_dict, client)
assert account.now == self.now
assert account.service_available == self.service_available
def test_de_json_all(self, client, passport_phone):
json_dict = {'now': self.now, 'region': self.region, 'service_available': self.service_available,
'uid': self.uid, 'login': self.login, 'full_name': self.full_name, 'second_name': self.second_name,
'first_name': self.first_name, 'display_name': self.display_name, 'hosted_user': self.hosted_user,
'birthday': self.birthday, 'passport_phones': [passport_phone.to_dict()], 'registered_at': self.registered_at,
'has_info_for_app_metrica': self.has_info_for_app_metrica}
account = Account.de_json(json_dict, client)
assert account.now == self.now
assert account.region == self.region
assert account.service_available == self.service_available
assert account.uid == self.uid
assert account.login == self.login
assert account.full_name == self.full_name
assert account.second_name == self.second_name
assert account.first_name == self.first_name
assert account.display_name == self.display_name
assert account.hosted_user == self.hosted_user
assert account.birthday == self.birthday
assert account.passport_phones == [passport_phone]
assert account.registered_at == self.registered_at
assert account.has_info_for_app_metrica == self.has_info_for_app_metrica
def test_equality(self, user):
a = Account(self.now, self.service_available)
assert a != user
assert hash(a) != hash(user)
assert a is not user

63
tests/test_ad_params.py ノーマルファイル
ファイルの表示

@ -0,0 +1,63 @@
from yandex_music import AdParams
class TestAdParams:
partner_id = '146552'
category_id = '0'
page_ref = 'http://music.yandex.ru'
target_ref = 'http://music.yandex.ru'
other_params = 'user:561231028'
ad_volume = -15
genre_id = None
genre_name = None
def test_expected_values(self, ad_params):
assert ad_params.partner_id == self.partner_id
assert ad_params.category_id == self.category_id
assert ad_params.page_ref == self.page_ref
assert ad_params.target_ref == self.target_ref
assert ad_params.other_params == self.other_params
assert ad_params.ad_volume == self.ad_volume
assert ad_params.genre_id == self.genre_id
assert ad_params.genre_name == self.genre_name
def test_de_json_required(self, client):
json_dict = {'partner_id': self.partner_id, 'category_id': self.category_id, 'page_ref': self.page_ref,
'target_ref': self.target_ref, 'other_params': self.other_params, 'ad_volume': self.ad_volume}
ad_params = AdParams.de_json(json_dict, client)
assert ad_params.partner_id == self.partner_id
assert ad_params.category_id == self.category_id
assert ad_params.page_ref == self.page_ref
assert ad_params.target_ref == self.target_ref
assert ad_params.other_params == self.other_params
assert ad_params.ad_volume == self.ad_volume
def test_de_json_all(self, client):
json_dict = {'partner_id': self.partner_id, 'category_id': self.category_id, 'page_ref': self.page_ref,
'target_ref': self.target_ref, 'other_params': self.other_params, 'ad_volume': self.ad_volume,
'genre_id': self.genre_id, 'genre_name': self.genre_name}
ad_params = AdParams.de_json(json_dict, client)
assert ad_params.partner_id == self.partner_id
assert ad_params.category_id == self.category_id
assert ad_params.page_ref == self.page_ref
assert ad_params.target_ref == self.target_ref
assert ad_params.other_params == self.other_params
assert ad_params.ad_volume == self.ad_volume
assert ad_params.genre_id == self.genre_id
assert ad_params.genre_name == self.genre_name
def test_equality(self):
a = AdParams(self.partner_id, self.category_id, self.page_ref, self.target_ref, self.other_params,
self.ad_volume)
b = AdParams(self.partner_id, '10', self.page_ref, self.target_ref, self.other_params, self.ad_volume)
c = AdParams(self.partner_id, self.category_id, '', self.target_ref, self.other_params, -30)
d = AdParams(self.partner_id, self.category_id, self.page_ref, self.target_ref, self.other_params,
self.ad_volume)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

120
tests/test_album.py ノーマルファイル
ファイルの表示

@ -0,0 +1,120 @@
from yandex_music import Album
class TestAlbum:
id = 5239478
title = 'In the End'
cover_uri = 'avatars.yandex.net/get-music-content/95061/89c14a7d.a.5239478-1/%%'
track_count = 3
available = True
available_for_premium_users = True
content_warning = None
original_release_year = None
genre = 'alternative'
og_image = 'avatars.yandex.net/get-music-content/95061/89c14a7d.a.5239478-1/%%'
buy = []
recent = False
very_important = False
available_for_mobile = True
available_partially = False
bests = [51241318]
prerolls = None
year = 2019
release_date = '2019-03-22T00:00:00+03:00'
type = 'single'
regions = None
def test_expected_values(self, album, artist_without_tracks, label, track_position, track_without_albums):
assert album.id == self.id
assert album.title == self.title
assert album.cover_uri == self.cover_uri
assert album.track_count == self.track_count
assert album.artists == [artist_without_tracks]
assert album.labels == [label]
assert album.available == self.available
assert album.available_for_premium_users == self.available_for_premium_users
assert album.content_warning == self.content_warning
assert album.original_release_year == self.original_release_year
assert album.genre == self.genre
assert album.og_image == self.og_image
assert album.buy == self.buy
assert album.recent == self.recent
assert album.very_important == self.very_important
assert album.available_for_mobile == self.available_for_mobile
assert album.available_partially == self.available_partially
assert album.bests == self.bests
assert album.prerolls == self.prerolls
assert album.volumes == [[track_without_albums]]
assert album.year == self.year
assert album.release_date == self.release_date
assert album.type == self.type
assert album.track_position == track_position
assert album.regions == self.regions
def test_de_json_required(self, client, artist, label):
json_dict = {'id': self.id, 'title': self.title, 'cover_uri': self.cover_uri, 'track_count': self.track_count,
'artists': [artist.to_dict()], 'labels': [label.to_dict()],
'available': self.available,
'available_for_premium_users': self.available_for_premium_users}
album = Album.de_json(json_dict, client)
assert album.id == self.id
assert album.title == self.title
assert album.cover_uri == self.cover_uri
assert album.track_count == self.track_count
assert album.artists == [artist]
assert album.labels == [label]
assert album.available == self.available
assert album.available_for_premium_users == self.available_for_premium_users
def test_de_json_all(self, client, artist, label, track_position, track):
json_dict = {'id': self.id, 'title': self.title, 'cover_uri': self.cover_uri, 'track_count': self.track_count,
'artists': [artist.to_dict()], 'labels': [label.to_dict()], 'available': self.available,
'available_for_premium_users': self.available_for_premium_users,
'content_warning': self.content_warning, 'original_release_year': self.original_release_year,
'genre': self.genre, 'og_image': self.og_image, 'buy': self.buy, 'recent': self.recent,
'very_important': self.very_important, 'available_for_mobile': self.available_for_mobile,
'available_partially': self.available_partially, 'bests': self.bests, 'prerolls': self.prerolls,
'volumes': [[track.to_dict()]], 'year': self.year,
'release_date': self.release_date,
'type': self.type, 'track_position': track_position.to_dict(), 'regions': self.regions}
album = Album.de_json(json_dict, client)
assert album.id == self.id
assert album.title == self.title
assert album.cover_uri == self.cover_uri
assert album.track_count == self.track_count
assert album.artists == [artist]
assert album.labels == [label]
assert album.available == self.available
assert album.available_for_premium_users == self.available_for_premium_users
assert album.content_warning == self.content_warning
assert album.original_release_year == self.original_release_year
assert album.genre == self.genre
assert album.og_image == self.og_image
assert album.buy == self.buy
assert album.recent == self.recent
assert album.very_important == self.very_important
assert album.available_for_mobile == self.available_for_mobile
assert album.available_partially == self.available_partially
assert album.bests == self.bests
assert album.prerolls == self.prerolls
assert album.volumes == [[track]]
assert album.year == self.year
assert album.release_date == self.release_date
assert album.type == self.type
assert album.track_position == track_position
assert album.regions == self.regions
def test_equality(self, artist, label):
a = Album(self.id, self.title, self.track_count, [artist], [label], self.available,
self.available_for_premium_users)
b = Album(10, '', 99, [artist], [label], self.available, self.available_for_premium_users)
c = Album(self.id, self.title, self.track_count, [artist], [label], self.available,
self.available_for_premium_users)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

32
tests/test_album_event.py ノーマルファイル
ファイルの表示

@ -0,0 +1,32 @@
from yandex_music import AlbumEvent
class TestAlbumEvent:
def test_expected_values(self, album_event, album, track):
assert album_event.album == album
assert album_event.tracks == [track]
def test_de_json_required(self, client, album, track):
json_dict = {'album': album.to_dict(), 'tracks': [track.to_dict()]}
album_event = AlbumEvent.de_json(json_dict, client)
assert album_event.album == album
assert album_event.tracks == [track]
def test_de_json_all(self, client, album, track):
json_dict = {'album': album.to_dict(), 'tracks': [track.to_dict()]}
album_event = AlbumEvent.de_json(json_dict, client)
assert album_event.album == album
assert album_event.tracks == [track]
def test_equality(self, album, track, artist_event):
a = AlbumEvent(album, track)
b = AlbumEvent(None, track)
c = AlbumEvent(album, track)
assert a != b != artist_event
assert hash(a) != hash(b) != hash(artist_event)
assert a is not b is not artist_event
assert a == c

43
tests/test_albums_likes.py ノーマルファイル
ファイルの表示

@ -0,0 +1,43 @@
import pytest
from yandex_music import AlbumsLikes
@pytest.fixture(scope='class')
def albums_likes(album):
return AlbumsLikes(TestAlbumsLikes.timestamp, TestAlbumsLikes.id, album)
class TestAlbumsLikes:
id = 5246018
timestamp = '2019-09-03T19:59:56+00:00'
def test_expected_values(self, albums_likes, album):
assert albums_likes.timestamp == self.timestamp
assert albums_likes.id == self.id
assert albums_likes.album == album
def test_de_json_required(self, client):
json_dict = {'timestamp': self.timestamp}
albums_likes = AlbumsLikes.de_json(json_dict, client)
assert albums_likes.timestamp == self.timestamp
def test_de_json_all(self, client, album):
json_dict = {'timestamp': self.timestamp, 'id': self.id, 'album': album.to_dict()}
albums_likes = AlbumsLikes.de_json(json_dict, client)
assert albums_likes.timestamp == self.timestamp
assert albums_likes.id == self.id
assert albums_likes.album == album
def test_equality(self, album):
a = AlbumsLikes(self.timestamp, self.id, album)
b = AlbumsLikes(self.timestamp, self.id, None)
c = AlbumsLikes(self.timestamp, self.id, album)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

111
tests/test_artist.py ノーマルファイル
ファイルの表示

@ -0,0 +1,111 @@
from yandex_music import Artist
class TestArtist:
id = 10987
name = 'Elvis Presley'
various = False
composer = None
genres = None
op_image = None
no_pictures_from_search = None
available = None
tickets_available = False
likes_count = 657469
regions = None
decomposed = None
full_names = None
countries = None
en_wikipedia_link = None
db_aliases = None
aliases = None
init_date = '1935-01-08'
end_date = None
def test_expected_values(self, artist, cover, counts, ratings, link, track_without_artists_and_albums, description):
assert artist.id == self.id
assert artist.name == self.name
assert artist.various == self.various
assert artist.composer == self.composer
assert artist.cover == cover
assert artist.genres == self.genres
assert artist.op_image == self.op_image
assert artist.no_pictures_from_search == self.no_pictures_from_search
assert artist.counts == counts
assert artist.available == self.available
assert artist.ratings == ratings
assert artist.links == [link]
assert artist.tickets_available == self.tickets_available
assert artist.likes_count == self.likes_count
assert artist.popular_tracks == [track_without_artists_and_albums]
assert artist.regions == self.regions
assert artist.decomposed == self.decomposed
assert artist.full_names == self.full_names
assert artist.description == description
assert artist.countries == self.countries
assert artist.en_wikipedia_link == self.en_wikipedia_link
assert artist.db_aliases == self.db_aliases
assert artist.aliases == self.aliases
assert artist.init_date == self.init_date
assert artist.end_date == self.end_date
def test_de_json_required(self, client, cover):
json_dict = {'id': self.id, 'name': self.name, 'various': self.various, 'composer': self.composer,
'cover': cover.to_dict()}
artist = Artist.de_json(json_dict, client)
assert artist.id == self.id
assert artist.name == self.name
assert artist.various == self.various
assert artist.composer == self.composer
assert artist.cover == cover
def test_de_json_all(self, client, cover, counts, ratings, link, track_without_artists, description):
json_dict = {'id': self.id, 'name': self.name, 'various': self.various, 'composer': self.composer,
'cover': cover.to_dict(), 'genres': self.genres, 'op_image': self.op_image,
'no_pictures_from_search': self.no_pictures_from_search, 'counts': counts.to_dict(),
'available': self.available, 'ratings': ratings.to_dict(), 'links': [link.to_dict()],
'tickets_available': self.tickets_available, 'likes_count': self.likes_count,
'popular_tracks': [track_without_artists.to_dict()], 'regions': self.regions,
'decomposed': self.decomposed, 'full_names': self.full_names, 'description': description.to_dict(),
'countries': self.countries, 'en_wikipedia_link': self.en_wikipedia_link,
'db_aliases': self.db_aliases, 'aliases': self.aliases, 'init_date': self.init_date,
'end_date': self.end_date}
artist = Artist.de_json(json_dict, client)
assert artist.id == self.id
assert artist.name == self.name
assert artist.various == self.various
assert artist.composer == self.composer
assert artist.cover == cover
assert artist.genres == self.genres
assert artist.op_image == self.op_image
assert artist.no_pictures_from_search == self.no_pictures_from_search
assert artist.counts == counts
assert artist.available == self.available
assert artist.ratings == ratings
assert artist.links == [link]
assert artist.tickets_available == self.tickets_available
assert artist.likes_count == self.likes_count
assert artist.popular_tracks == [track_without_artists]
assert artist.regions == self.regions
assert artist.decomposed == self.decomposed
assert artist.full_names == self.full_names
assert artist.description == description
assert artist.countries == self.countries
assert artist.en_wikipedia_link == self.en_wikipedia_link
assert artist.db_aliases == self.db_aliases
assert artist.aliases == self.aliases
assert artist.init_date == self.init_date
assert artist.end_date == self.end_date
def test_equality(self, cover):
a = Artist(self.id, self.name, self.various, self.composer, cover)
b = Artist(self.id, '', self.various, self.composer, None)
c = Artist(self.id, self.name, self.various, self.composer, cover)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

37
tests/test_artist_event.py ノーマルファイル
ファイルの表示

@ -0,0 +1,37 @@
from yandex_music import ArtistEvent
class TestArtistEvent:
def test_expected_values(self, artist_event, artist, track):
assert artist_event.artist == artist
assert artist_event.tracks == [track]
assert artist_event.similar_to_artists_from_history == [artist]
def test_de_json_required(self, client, artist, track):
json_dict = {'artist': artist.to_dict(), 'tracks': [track.to_dict()],
'similar_to_artists_from_history': [artist.to_dict()]}
artist_event = ArtistEvent.de_json(json_dict, client)
assert artist_event.artist == artist
assert artist_event.tracks == [track]
assert artist_event.similar_to_artists_from_history == [artist]
def test_de_json_all(self, client, artist, track):
json_dict = {'artist': artist.to_dict(), 'tracks': [track.to_dict()],
'similar_to_artists_from_history': [artist.to_dict()]}
artist_event = ArtistEvent.de_json(json_dict, client)
assert artist_event.artist == artist
assert artist_event.tracks == [track]
assert artist_event.similar_to_artists_from_history == [artist]
def test_equality(self, artist, track):
a = ArtistEvent(artist, [track], [artist])
b = ArtistEvent(None, [track], [artist])
c = ArtistEvent(artist, [track], [artist])
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

39
tests/test_artist_tracks.py ノーマルファイル
ファイルの表示

@ -0,0 +1,39 @@
import pytest
from yandex_music import ArtistTracks
@pytest.fixture(scope='class')
def artist_tracks(track, pager):
return ArtistTracks([track], pager)
class TestArtistTracks:
def test_expected_values(self, artist_tracks, track, pager):
assert artist_tracks.tracks == [track]
assert artist_tracks.pager == pager
def test_de_json_required(self, client, track, pager):
json_dict = {'tracks': [track.to_dict()], 'pager': pager.to_dict()}
artist_tracks = ArtistTracks.de_json(json_dict, client)
assert artist_tracks.tracks == [track]
assert artist_tracks.pager == pager
def test_de_json_all(self, client, track, pager):
json_dict = {'tracks': [track.to_dict()], 'pager': pager.to_dict()}
artist_tracks = ArtistTracks.de_json(json_dict, client)
assert artist_tracks.tracks == [track]
assert artist_tracks.pager == pager
def test_equality(self, track, pager):
a = ArtistTracks([track], pager)
b = ArtistTracks([], pager)
c = ArtistTracks([track], pager)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

41
tests/test_artists_likes.py ノーマルファイル
ファイルの表示

@ -0,0 +1,41 @@
import pytest
from yandex_music import ArtistsLikes
@pytest.fixture(scope='class')
def artists_likes(artist):
return ArtistsLikes(TestArtistsLikes.id, artist, TestArtistsLikes.timestamp)
class TestArtistsLikes:
id = None
timestamp = '2019-11-09T10:28:39+00:00'
def test_expected_values(self, artists_likes, artist):
assert artists_likes.id == self.id
assert artists_likes.artist == artist
assert artists_likes.timestamp == self.timestamp
def test_de_json_required(self, client):
json_dict = {}
artists_likes = ArtistsLikes.de_json(json_dict, client)
def test_de_json_all(self, client, artist):
json_dict = {'id': self.id, 'artist': artist.to_dict(), 'timestamp': self.timestamp}
artists_likes = ArtistsLikes.de_json(json_dict, client)
assert artists_likes.id == self.id
assert artists_likes.artist == artist
assert artists_likes.timestamp == self.timestamp
def test_equality(self, artist):
a = ArtistsLikes(self.id, artist, self.timestamp)
b = ArtistsLikes(self.id, None, self.timestamp)
c = ArtistsLikes(self.id, artist, self.timestamp)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

56
tests/test_auto_renewable.py ノーマルファイル
ファイルの表示

@ -0,0 +1,56 @@
from yandex_music import AutoRenewable
class TestAutoRenewable:
expires = '2019-11-30T23:59:59+03:00'
vendor = 'Yandex'
vendor_help_url = 'https://www.yandex.ru/support/music-app/subscription.xml'
product_id = 'ru.yandex.mobile.music.1month.autorenewable.native.web.notrial.restricted.cache.99'
finished = False
order_id = 39385401
def test_expected_values(self, auto_renewable, product):
assert auto_renewable.expires == self.expires
assert auto_renewable.vendor == self.vendor
assert auto_renewable.vendor_help_url == self.vendor_help_url
assert auto_renewable.product_id == self.product_id
assert auto_renewable.product == product
assert auto_renewable.finished == self.finished
assert auto_renewable.order_id == self.order_id
def test_de_json_required(self, client, product):
json_dict = {'expires': self.expires, 'vendor': self.vendor, 'vendor_help_url': self.vendor_help_url,
'product_id': self.product_id, 'product': product.to_dict(), 'finished': self.finished}
auto_renewable = AutoRenewable.de_json(json_dict, client)
assert auto_renewable.expires == self.expires
assert auto_renewable.vendor == self.vendor
assert auto_renewable.vendor_help_url == self.vendor_help_url
assert auto_renewable.product_id == self.product_id
assert auto_renewable.product == product
assert auto_renewable.finished == self.finished
def test_de_json_all(self, client, product):
json_dict = {'expires': self.expires, 'vendor': self.vendor, 'vendor_help_url': self.vendor_help_url,
'product_id': self.product_id, 'product': product.to_dict(), 'finished': self.finished,
'order_id': self.order_id}
auto_renewable = AutoRenewable.de_json(json_dict, client)
assert auto_renewable.expires == self.expires
assert auto_renewable.vendor == self.vendor
assert auto_renewable.vendor_help_url == self.vendor_help_url
assert auto_renewable.product_id == self.product_id
assert auto_renewable.product == product
assert auto_renewable.finished == self.finished
assert auto_renewable.order_id == self.order_id
def test_equality(self, product):
a = AutoRenewable(self.expires, self.vendor, self.vendor_help_url, self.product_id, product, self.finished)
b = AutoRenewable(self.expires, '', self.vendor_help_url, '', product, self.finished)
c = AutoRenewable(self.expires, self.vendor, self.vendor_help_url, self.product_id, product, self.finished)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

45
tests/test_best.py ノーマルファイル
ファイルの表示

@ -0,0 +1,45 @@
from yandex_music import Best
class TestBest:
type = 'artist'
text = 'empathy test'
def test_expected_values(self, best_with_result):
best, result = best_with_result
assert best.type == best.type
assert best.result == result
assert best.text == self.text
def test_de_json_required(self, client, best_with_result):
best_fixture, result = best_with_result
json_dict = {'type': best_fixture.type, 'result': result.to_dict()}
best = Best.de_json(json_dict, client)
assert best.type == best_fixture.type
assert best.result == result
def test_de_json_all(self, client, best_with_result):
best_fixture, result = best_with_result
json_dict = {'type': best_fixture.type, 'result': result.to_dict(), 'text': self.text}
best = Best.de_json(json_dict, client)
assert best.type == best_fixture.type
assert best.result == result
assert best.text == self.text
def test_equality(self, best_with_result):
best, result = best_with_result
a = Best(best.type, result)
b = Best(best.type, None)
c = Best(best.type, result)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

65
tests/test_block.py ノーマルファイル
ファイルの表示

@ -0,0 +1,65 @@
import pytest
from yandex_music import Block
@pytest.fixture(scope='class')
def block_with_entity_and_data(block_entity, data):
return Block(TestBlock.id, TestBlock.type, TestBlock.type_for_from, TestBlock.title, [block_entity],
TestBlock.description, data), block_entity, data
class TestBlock:
id = 'ObsM5DkU'
type = 'personal-playlists'
type_for_from = 'personal-playlists'
title = 'Собрано на основе ваших предпочтений'
description = None
def test_expected_values(self, block_with_entity_and_data):
block, block_entity, data = block_with_entity_and_data
assert block.id == self.id
assert block.type == self.type
assert block.type_for_from == self.type_for_from
assert block.title == self.title
assert block.entities == [block_entity]
assert block.description == self.description
assert block.data == data
def test_de_json_required(self, client, block_entity):
json_dict = {'id': self.id, 'type': self.type, 'type_for_from': self.type_for_from, 'title': self.title,
'entities': [block_entity.to_dict()]}
block = Block.de_json(json_dict, client)
assert block.id == self.id
assert block.type == self.type
assert block.type_for_from == self.type_for_from
assert block.title == self.title
assert block.entities == [block_entity]
def test_de_json_all(self, client, block_entity, data_with_type):
data, type = data_with_type
json_dict = {'id': self.id, 'type': type, 'type_for_from': self.type_for_from, 'title': self.title,
'entities': [block_entity.to_dict()], 'description': self.description, 'data': data.to_dict()}
block = Block.de_json(json_dict, client)
assert block.id == self.id
assert block.type == type
assert block.type_for_from == self.type_for_from
assert block.title == self.title
assert block.entities == [block_entity]
assert block.description == self.description
assert block.data == data
def test_equality(self, block_entity):
a = Block(self.id, self.type, self.type_for_from, self.title, [block_entity])
b = Block('', self.type, self.type_for_from, self.title, None)
c = Block(self.id, self.type, self.type_for_from, self.title, [block_entity])
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

60
tests/test_block_entity.py ノーマルファイル
ファイルの表示

@ -0,0 +1,60 @@
import pytest
from yandex_music import BlockEntity
@pytest.fixture(scope='class', params=[3, 4, 6, 7, 8, 9, 10])
def block_entity_data_with_type(request, results, types):
return results[request.param], types[request.param]
@pytest.fixture(scope='class', params=[3, 4, 6, 7, 8, 9, 10])
def block_entity_with_data_and_type(request, results, types):
return BlockEntity(TestBlockEntity.id, types[request.param], results[request.param]), \
results[request.param], types[request.param]
class TestBlockEntity:
id = 'lze0IVH4'
type = 'personal-playlist'
def test_expected_values(self, block_entity_with_data_and_type):
block_entity, data, type = block_entity_with_data_and_type
assert block_entity.id == self.id
assert block_entity.type == type
assert block_entity.data == data
def test_de_json_required(self, client, block_entity_data_with_type):
data, type = block_entity_data_with_type
json_dict = {'id': self.id, 'type': type, 'data': data.to_dict()}
block_entity = BlockEntity.de_json(json_dict, client)
assert block_entity.id == self.id
assert block_entity.type == type
assert block_entity.data == data
def test_de_json_all(self, client, block_entity_data_with_type):
data, type = block_entity_data_with_type
json_dict = {'id': self.id, 'type': type, 'data': data.to_dict()}
block_entity = BlockEntity.de_json(json_dict, client)
assert block_entity.id == self.id
assert block_entity.type == type
assert block_entity.data == data
def test_equality(self, block_entity_data_with_type):
data, type = block_entity_data_with_type
a = BlockEntity(self.id, type, data)
b = BlockEntity(self.id, None, data)
c = BlockEntity('', type, data)
d = BlockEntity(self.id, type, data)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

89
tests/test_brief_info.py ノーマルファイル
ファイルの表示

@ -0,0 +1,89 @@
import pytest
from yandex_music import BriefInfo
@pytest.fixture(scope='class')
def brief_info(artist, track, album, cover, playlist_id, video, chart, vinyl):
return BriefInfo(artist, [album], [album], TestBriefInfo.last_release_ids, [track], [artist], [cover],
TestBriefInfo.concerts, [video], [vinyl], TestBriefInfo.has_promotions, [playlist_id], [chart])
class TestBriefInfo:
last_release_ids = [8501194, 8302547, 8302836, 8302450]
concerts = None
has_promotions = False
def test_expected_values(self, brief_info, artist, track, album, cover, playlist_id, video, chart, vinyl):
assert brief_info.artist == artist
assert brief_info.albums == [album]
assert brief_info.also_albums == [album]
assert brief_info.last_release_ids == self.last_release_ids
assert brief_info.popular_tracks == [track]
assert brief_info.similar_artists == [artist]
assert brief_info.all_covers == [cover]
assert brief_info.concerts == self.concerts
assert brief_info.videos == [video]
assert brief_info.vinyls == [vinyl]
assert brief_info.has_promotions == self.has_promotions
assert brief_info.playlist_ids == [playlist_id]
assert brief_info.tracks_in_chart == [chart]
def test_de_json_required(self, client, artist, track, album, cover, playlist_id, video, vinyl):
json_dict = {'artist': artist.to_dict(), 'albums': [album.to_dict()], 'also_albums': [album.to_dict()],
'last_release_ids': self.last_release_ids, 'popular_tracks': [track.to_dict()],
'similar_artists': [artist.to_dict()], 'all_covers': [cover.to_dict()], 'concerts': self.concerts,
'videos': [video.to_dict()], 'vinyls': [vinyl.to_dict()], 'has_promotions': self.has_promotions,
'playlist_ids': [playlist_id.to_dict()]}
brief_info = BriefInfo.de_json(json_dict, client)
assert brief_info.artist == artist
assert brief_info.albums == [album]
assert brief_info.also_albums == [album]
assert brief_info.last_release_ids == self.last_release_ids
assert brief_info.popular_tracks == [track]
assert brief_info.similar_artists == [artist]
assert brief_info.all_covers == [cover]
assert brief_info.concerts == self.concerts
assert brief_info.videos == [video]
assert brief_info.vinyls == [vinyl]
assert brief_info.has_promotions == self.has_promotions
assert brief_info.playlist_ids == [playlist_id]
def test_de_json_all(self, client, artist, track, album, cover, playlist_id, video, chart, vinyl):
json_dict = {'artist': artist.to_dict(), 'albums': [album.to_dict()], 'also_albums': [album.to_dict()],
'last_release_ids': self.last_release_ids, 'popular_tracks': [track.to_dict()],
'similar_artists': [artist.to_dict()], 'all_covers': [cover.to_dict()], 'concerts': self.concerts,
'videos': [video.to_dict()], 'vinyls': [vinyl.to_dict()], 'has_promotions': self.has_promotions,
'playlist_ids': [playlist_id.to_dict()], 'tracks_in_chart': [chart.to_dict()]}
brief_info = BriefInfo.de_json(json_dict, client)
assert brief_info.artist == artist
assert brief_info.albums == [album]
assert brief_info.also_albums == [album]
assert brief_info.last_release_ids == self.last_release_ids
assert brief_info.popular_tracks == [track]
assert brief_info.similar_artists == [artist]
assert brief_info.all_covers == [cover]
assert brief_info.concerts == self.concerts
assert brief_info.videos == [video]
assert brief_info.vinyls == [vinyl]
assert brief_info.has_promotions == self.has_promotions
assert brief_info.playlist_ids == [playlist_id]
assert brief_info.tracks_in_chart == [chart]
def test_equality(self, artist, track, album, cover, playlist_id, video, vinyl):
a = BriefInfo(artist, [album], [album], self.last_release_ids, [track], [artist], [cover], self.concerts,
[video], [vinyl], self.has_promotions, [playlist_id])
b = BriefInfo(artist, [album], [album], self.last_release_ids, None, [artist], [cover], self.concerts,
[video], [vinyl], True, [playlist_id])
c = BriefInfo(artist, [album], [album], [1, 2, 3], [track], [artist], None, self.concerts,
[video], [vinyl], self.has_promotions, [playlist_id])
d = BriefInfo(artist, [album], [album], self.last_release_ids, [track], [artist], [cover], self.concerts,
[video], [vinyl], self.has_promotions, [playlist_id])
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

57
tests/test_case_forms.py ノーマルファイル
ファイルの表示

@ -0,0 +1,57 @@
from yandex_music import CaseForms
class TestCaseForms:
nominative = 'Илья'
genitive = 'Ильи'
dative = 'Илье'
accusative = 'Илью'
instrumental = 'Ильей'
prepositional = 'Илье'
def test_expected_values(self, case_forms):
assert case_forms.nominative == self.nominative
assert case_forms.genitive == self.genitive
assert case_forms.dative == self.dative
assert case_forms.accusative == self.accusative
assert case_forms.instrumental == self.instrumental
assert case_forms.prepositional == self.prepositional
def test_de_json_required(self, client):
json_dict = {'nominative': self.nominative, 'genitive': self.genitive, 'dative': self.dative,
'accusative': self.accusative, 'instrumental': self.instrumental,
'prepositional': self.prepositional}
case_forms = CaseForms.de_json(json_dict, client)
assert case_forms.nominative == self.nominative
assert case_forms.genitive == self.genitive
assert case_forms.dative == self.dative
assert case_forms.accusative == self.accusative
assert case_forms.instrumental == self.instrumental
assert case_forms.prepositional == self.prepositional
def test_de_json_all(self, client):
json_dict = {'nominative': self.nominative, 'genitive': self.genitive, 'dative': self.dative,
'accusative': self.accusative, 'instrumental': self.instrumental,
'prepositional': self.prepositional}
case_forms = CaseForms.de_json(json_dict, client)
assert case_forms.nominative == self.nominative
assert case_forms.genitive == self.genitive
assert case_forms.dative == self.dative
assert case_forms.accusative == self.accusative
assert case_forms.instrumental == self.instrumental
assert case_forms.prepositional == self.prepositional
def test_equality(self):
a = CaseForms(self.nominative, self.genitive, self.dative, self.accusative, self.instrumental,
self.prepositional)
b = CaseForms(self.nominative, '', self.dative, self.accusative, self.instrumental, self.prepositional)
c = CaseForms(self.nominative, self.genitive, self.dative, self.accusative, self.instrumental,
self.prepositional)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

48
tests/test_chart.py ノーマルファイル
ファイルの表示

@ -0,0 +1,48 @@
from yandex_music import Chart
class TestChart:
position = 2
progress = 'same'
listeners = 1433
shift = 0
def test_expected_values(self, chart, track_id):
assert chart.position == self.position
assert chart.progress == self.progress
assert chart.listeners == self.listeners
assert chart.shift == self.shift
assert chart.track_id == track_id
def test_de_json_required(self, client):
json_dict = {'position': self.position, 'progress': self.progress, 'listeners': self.listeners,
'shift': self.shift}
chart = Chart.de_json(json_dict, client)
assert chart.position == self.position
assert chart.progress == self.progress
assert chart.listeners == self.listeners
assert chart.shift == self.shift
def test_de_json_all(self, client, track_id):
json_dict = {'position': self.position, 'progress': self.progress, 'listeners': self.listeners,
'shift': self.shift, 'track_id': track_id.to_dict()}
chart = Chart.de_json(json_dict, client)
assert chart.position == self.position
assert chart.progress == self.progress
assert chart.listeners == self.listeners
assert chart.shift == self.shift
assert chart.track_id == track_id
def test_equality(self):
a = Chart(self.position, self.progress, self.listeners, self.shift)
b = Chart(10, self.progress, self.listeners, self.shift)
c = Chart(self.position, self.progress, 10, self.shift)
d = Chart(self.position, self.progress, self.listeners, self.shift)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

32
tests/test_chart_item.py ノーマルファイル
ファイルの表示

@ -0,0 +1,32 @@
from yandex_music import ChartItem
class TestChartItem:
def test_expected_values(self, chart_item, track, chart):
assert chart_item.track == track
assert chart_item.chart == chart
def test_de_json_required(self, client, track, chart):
json_dict = {'track': track.to_dict(), 'chart': chart.to_dict()}
chart_item = ChartItem.de_json(json_dict, client)
assert chart_item.track == track
assert chart_item.chart == chart
def test_de_json_all(self, client, track, chart):
json_dict = {'track': track.to_dict(), 'chart': chart.to_dict()}
chart_item = ChartItem.de_json(json_dict, client)
assert chart_item.track == track
assert chart_item.chart == chart
def test_equality(self, track, chart):
a = ChartItem(track, chart)
b = ChartItem(None, chart)
c = ChartItem(track, chart)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

46
tests/test_counts.py ノーマルファイル
ファイルの表示

@ -0,0 +1,46 @@
from yandex_music import Counts
class TestCounts:
tracks = 94
direct_albums = 9
also_albums = 0
also_tracks = 0
def test_expected_values(self, counts):
assert counts.tracks == self.tracks
assert counts.direct_albums == self.direct_albums
assert counts.also_albums == self.also_albums
assert counts.also_tracks == self.also_tracks
def test_de_json_required(self, client):
json_dict = {'tracks': self.tracks, 'direct_albums': self.direct_albums, 'also_albums': self.also_albums,
'also_tracks': self.also_tracks}
counts = Counts.de_json(json_dict, client)
assert counts.tracks == self.tracks
assert counts.direct_albums == self.direct_albums
assert counts.also_albums == self.also_albums
assert counts.also_tracks == self.also_tracks
def test_de_json_all(self, client):
json_dict = {'tracks': self.tracks, 'direct_albums': self.direct_albums, 'also_albums': self.also_albums,
'also_tracks': self.also_tracks}
counts = Counts.de_json(json_dict, client)
assert counts.tracks == self.tracks
assert counts.direct_albums == self.direct_albums
assert counts.also_albums == self.also_albums
assert counts.also_tracks == self.also_tracks
def test_equality(self):
a = Counts(self.tracks, self.direct_albums, self.also_albums, self.also_tracks)
b = Counts(40, self.direct_albums, 30, self.also_tracks)
c = Counts(self.tracks, self.direct_albums, 10, 10)
d = Counts(self.tracks, self.direct_albums, self.also_albums, self.also_tracks)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

47
tests/test_cover.py ノーマルファイル
ファイルの表示

@ -0,0 +1,47 @@
from yandex_music import Cover
class TestCover:
type = 'pic'
uri = 'avatars.yandex.net/get-music-user-playlist/38125/q0ahkhfQE3neTk/%%?1572609906461'
items_uri = None
dir = '/get-music-user-playlist/34120/pvg900XixWaHcr/'
version = '1572609906461'
custom = True
prefix = None
error = None
def test_expected_values(self, cover):
assert cover.type == self.type
assert cover.uri == self.uri
assert cover.items_uri == self.items_uri
assert cover.dir == self.dir
assert cover.version == self.version
assert cover.custom == self.custom
assert cover.prefix == self.prefix
assert cover.error == self.error
def test_de_json_required(self, client):
json_dict = {}
cover = Cover.de_json(json_dict, client)
def test_de_json_all(self, client):
json_dict = {'type': self.type, 'uri': self.uri, 'items_uri': self.items_uri, 'dir': self.dir,
'version': self.version, 'custom': self.custom, 'prefix': self.prefix, 'error': self.error}
cover = Cover.de_json(json_dict, client)
assert cover.type == self.type
assert cover.uri == self.uri
assert cover.items_uri == self.items_uri
assert cover.dir == self.dir
assert cover.version == self.version
assert cover.custom == self.custom
assert cover.prefix == self.prefix
assert cover.error == self.error
def test_equality(self, images):
a = Cover(self.type, self.uri, self.items_uri)
assert a != images
assert hash(a) != hash(images)
assert a is not images

45
tests/test_dashboard.py ノーマルファイル
ファイルの表示

@ -0,0 +1,45 @@
import pytest
from yandex_music import Dashboard
@pytest.fixture(scope='class')
def dashboard(station_result):
return Dashboard(TestDashboard.dashboard_id, [station_result], TestDashboard.pumpkin)
class TestDashboard:
dashboard_id = '1573229923780896-4168369461406125948'
pumpkin = False
def test_expected_values(self, dashboard, station_result):
assert dashboard.dashboard_id == self.dashboard_id
assert dashboard.stations == [station_result]
assert dashboard.pumpkin == self.pumpkin
def test_de_json_required(self, client, station_result):
json_dict = {'dashboard_id': self.dashboard_id, 'stations': [station_result.to_dict()], 'pumpkin': self.pumpkin}
dashboard = Dashboard.de_json(json_dict, client)
assert dashboard.dashboard_id == self.dashboard_id
assert dashboard.stations == [station_result]
assert dashboard.pumpkin == self.pumpkin
def test_de_json_all(self, client, station_result):
json_dict = {'dashboard_id': self.dashboard_id, 'stations': [station_result.to_dict()], 'pumpkin': self.pumpkin}
dashboard = Dashboard.de_json(json_dict, client)
assert dashboard.dashboard_id == self.dashboard_id
assert dashboard.stations == [station_result]
assert dashboard.pumpkin == self.pumpkin
def test_equality(self, station):
a = Dashboard(self.dashboard_id, [station], self.pumpkin)
b = Dashboard('', [station], True)
c = Dashboard(self.dashboard_id, [station], self.pumpkin)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

42
tests/test_day.py ノーマルファイル
ファイルの表示

@ -0,0 +1,42 @@
from yandex_music import Day
class TestDay:
day = '2019-11-09'
def test_expected_values(self, day, event, track_with_ads, track):
assert day.day == self.day
assert day.events == [event]
assert day.tracks_to_play_with_ads == [track_with_ads]
assert day.tracks_to_play == [track]
def test_de_json_required(self, client, event, track_with_ads, track):
json_dict = {'day': self.day, 'events': [event.to_dict()], 'tracks_to_play_with_ads': [track_with_ads.to_dict()],
'tracks_to_play': [track.to_dict()]}
day = Day.de_json(json_dict, client)
assert day.day == self.day
assert day.events == [event]
assert day.tracks_to_play_with_ads == [track_with_ads]
assert day.tracks_to_play == [track]
def test_de_json_all(self, client, event, track_with_ads, track):
json_dict = {'day': self.day, 'events': [event.to_dict()], 'tracks_to_play_with_ads': [track_with_ads.to_dict()],
'tracks_to_play': [track.to_dict()]}
day = Day.de_json(json_dict, client)
assert day.day == self.day
assert day.events == [event]
assert day.tracks_to_play_with_ads == [track_with_ads]
assert day.tracks_to_play == [track]
def test_equality(self, event, track_with_ads, track):
a = Day(self.day, [event], [track_with_ads], [track])
b = Day('', [event], [track_with_ads], [track])
c = Day(self.day, [event], [track_with_ads], [track])
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

38
tests/test_description.py ノーマルファイル
ファイルの表示

@ -0,0 +1,38 @@
from yandex_music import Description
class TestDescription:
text = 'Американский певец и актёр, один из самых коммерчески успешных исполнителей популярной музыки XX века. ' \
'Также известен как «король рок-н-ролла». Пресли популяризовал рок-н-ролл, хотя и не был первым ' \
'исполнителем этого жанра. '
url = 'http://ru.wikipedia.org/wiki/Пресли, Элвис'
def test_expected_values(self, description):
assert description.text == self.text
assert description.url == self.url
def test_de_json_required(self, client):
json_dict = {'text': self.text, 'url': self.url}
description = Description.de_json(json_dict, client)
assert description.text == self.text
assert description.url == self.url
def test_de_json_all(self, client):
json_dict = {'text': self.text, 'url': self.url}
description = Description.de_json(json_dict, client)
assert description.text == self.text
assert description.url == self.url
def test_equality(self):
a = Description(self.text, self.url)
b = Description('', self.url)
c = Description(self.text, '')
d = Description(self.text, self.url)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

42
tests/test_discrete_scale.py ノーマルファイル
ファイルの表示

@ -0,0 +1,42 @@
from yandex_music import DiscreteScale
class TestDiscreteScale:
type = 'discrete-scale'
name = 'Настроение'
def test_expected_values(self, discrete_scale, value):
assert discrete_scale.type == self.type
assert discrete_scale.name == self.name
assert discrete_scale.min == value
assert discrete_scale.max == value
def test_de_json_required(self, client, value):
json_dict = {'type': self.type, 'name': self.name, 'min': value.to_dict(), 'max': value.to_dict()}
discrete_scale = DiscreteScale.de_json(json_dict, client)
assert discrete_scale.type == self.type
assert discrete_scale.name == self.name
assert discrete_scale.min == value
assert discrete_scale.max == value
def test_de_json_all(self, client, value):
json_dict = {'type': self.type, 'name': self.name, 'min': value.to_dict(), 'max': value.to_dict()}
discrete_scale = DiscreteScale.de_json(json_dict, client)
assert discrete_scale.type == self.type
assert discrete_scale.name == self.name
assert discrete_scale.min == value
assert discrete_scale.max == value
def test_equality(self, value):
a = DiscreteScale(self.type, self.name, value, value)
b = DiscreteScale('', self.name, value, value)
c = DiscreteScale('', '', value, value)
d = DiscreteScale(self.type, self.name, value, value)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

58
tests/test_download_info.py ノーマルファイル
ファイルの表示

@ -0,0 +1,58 @@
import pytest
from yandex_music import DownloadInfo
@pytest.fixture(scope='class')
def download_info():
return DownloadInfo(TestDownloadInfo.codec, TestDownloadInfo.bitrate_in_kbps, TestDownloadInfo.gain,
TestDownloadInfo.preview, TestDownloadInfo.download_info_url)
class TestDownloadInfo:
codec = 'mp3'
bitrate_in_kbps = 'mp3'
gain = False
preview = False
download_info_url = 'https://storage.mds.yandex.net/file-download-info/136146_d158926e.14534319.6.10994777/320' \
'?sign=8caf5ea72c946d4753f15298e4033b961c7acb1bb4db48eb5e6b59621e387d64&ts=5dc4a6f2 '
def test_expected_values(self, download_info):
assert download_info.codec == self.codec
assert download_info.bitrate_in_kbps == self.bitrate_in_kbps
assert download_info.gain == self.gain
assert download_info.preview == self.preview
assert download_info.download_info_url == self.download_info_url
def test_de_json_required(self, client):
json_dict = {'codec': self.codec, 'bitrate_in_kbps': self.bitrate_in_kbps, 'gain': self.gain,
'preview': self.preview, 'download_info_url': self.download_info_url}
download_info = DownloadInfo.de_json(json_dict, client)
assert download_info.codec == self.codec
assert download_info.bitrate_in_kbps == self.bitrate_in_kbps
assert download_info.gain == self.gain
assert download_info.preview == self.preview
assert download_info.download_info_url == self.download_info_url
def test_de_json_all(self, client):
json_dict = {'codec': self.codec, 'bitrate_in_kbps': self.bitrate_in_kbps, 'gain': self.gain,
'preview': self.preview, 'download_info_url': self.download_info_url}
download_info = DownloadInfo.de_json(json_dict, client)
assert download_info.codec == self.codec
assert download_info.bitrate_in_kbps == self.bitrate_in_kbps
assert download_info.gain == self.gain
assert download_info.preview == self.preview
assert download_info.download_info_url == self.download_info_url
def test_equality(self):
a = DownloadInfo(self.codec, self.bitrate_in_kbps, self.gain, self.preview, self.download_info_url)
b = DownloadInfo(self.codec, 128, self.gain, True, self.download_info_url)
c = DownloadInfo(self.codec, self.bitrate_in_kbps, self.gain, self.preview, self.download_info_url)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

38
tests/test_enum.py ノーマルファイル
ファイルの表示

@ -0,0 +1,38 @@
from yandex_music import Enum
class TestEnum:
type = 'enum'
name = 'Язык'
def test_expected_values(self, enum, value):
assert enum.type == self.type
assert enum.name == self.name
assert enum.possible_values == [value]
def test_de_json_required(self, client, value):
json_dict = {'type': self.type, 'name': self.name, 'possible_values': [value.to_dict()]}
enum = Enum.de_json(json_dict, client)
assert enum.type == self.type
assert enum.name == self.name
assert enum.possible_values == [value]
def test_de_json_all(self, client, value):
json_dict = {'type': self.type, 'name': self.name, 'possible_values': [value.to_dict()]}
enum = Enum.de_json(json_dict, client)
assert enum.type == self.type
assert enum.name == self.name
assert enum.possible_values == [value]
def test_equality(self, value):
a = Enum(self.type, self.name, [value])
b = Enum(self.type, '', [value])
c = Enum(self.type, self.name, [value])
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

59
tests/test_event.py ノーマルファイル
ファイルの表示

@ -0,0 +1,59 @@
from yandex_music import Event
class TestEvent:
id = '9DAmz0UE'
type = 'tracks'
type_for_from = 'tracks-by-genre'
title = 'Нравится электроника? Попробуйте послушать это'
message = None
device = None
tracks_count = None
def test_expected_values(self, event, track, artist_event, album_event):
assert event.id == self.id
assert event.type == self.type
assert event.type_for_from == self.type_for_from
assert event.title == self.title
assert event.tracks == [track]
assert event.artists == [artist_event]
assert event.albums == [album_event]
assert event.message == self.message
assert event.device == self.device
assert event.tracks_count == self.tracks_count
def test_de_json_required(self, client):
json_dict = {'id': self.id, 'type': self.type}
event = Event.de_json(json_dict, client)
assert event.id == self.id
assert event.type == self.type
def test_de_json_all(self, client, track, artist_event, album_event):
json_dict = {'id': self.id, 'type': self.type, 'type_for_from': self.type_for_from, 'title': self.title,
'tracks': [track.to_dict()], 'artists': [artist_event.to_dict()],
'albums': [album_event.to_dict()], 'message': self.message, 'device': self.device,
'tracks_count': self.tracks_count}
event = Event.de_json(json_dict, client)
assert event.id == self.id
assert event.type == self.type
assert event.type_for_from == self.type_for_from
assert event.title == self.title
assert event.tracks == [track]
assert event.artists == [artist_event]
assert event.albums == [album_event]
assert event.message == self.message
assert event.device == self.device
assert event.tracks_count == self.tracks_count
def test_equality(self):
a = Event(self.id, self.type)
b = Event(self.id, '')
c = Event(self.id, self.type, self.type_for_from)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

71
tests/test_feed.py ノーマルファイル
ファイルの表示

@ -0,0 +1,71 @@
import pytest
from yandex_music import Feed
@pytest.fixture(scope='class')
def feed(generated_playlist, day):
return Feed(TestFeed.can_get_more_events, TestFeed.pumpkin, TestFeed.is_wizard_passed, [generated_playlist],
TestFeed.headlines, TestFeed.today, [day], TestFeed.next_revision)
class TestFeed:
can_get_more_events = True
pumpkin = False
is_wizard_passed = True
headlines = []
today = '2019-11-09'
next_revision = '2019-11-08'
def test_expected_values(self, feed, generated_playlist, day):
assert feed.can_get_more_events == self.can_get_more_events
assert feed.pumpkin == self.pumpkin
assert feed.is_wizard_passed == self.is_wizard_passed
assert feed.generated_playlists == [generated_playlist]
assert feed.headlines == self.headlines
assert feed.today == self.today
assert feed.days == [day]
assert feed.next_revision == self.next_revision
def test_de_json_required(self, client, generated_playlist, day):
json_dict = {'can_get_more_events': self.can_get_more_events, 'pumpkin': self.pumpkin,
'is_wizard_passed': self.is_wizard_passed, 'generated_playlists': [generated_playlist.to_dict()],
'headlines': self.headlines, 'today': self.today, 'days': [day.to_dict()]}
feed = Feed.de_json(json_dict, client)
assert feed.can_get_more_events == self.can_get_more_events
assert feed.pumpkin == self.pumpkin
assert feed.is_wizard_passed == self.is_wizard_passed
assert feed.generated_playlists == [generated_playlist]
assert feed.headlines == self.headlines
assert feed.today == self.today
assert feed.days == [day]
def test_de_json_all(self, client, generated_playlist, day):
json_dict = {'can_get_more_events': self.can_get_more_events, 'pumpkin': self.pumpkin,
'is_wizard_passed': self.is_wizard_passed, 'generated_playlists': [generated_playlist.to_dict()],
'headlines': self.headlines, 'today': self.today, 'days': [day.to_dict()],
'next_revision': self.next_revision}
feed = Feed.de_json(json_dict, client)
assert feed.can_get_more_events == self.can_get_more_events
assert feed.pumpkin == self.pumpkin
assert feed.is_wizard_passed == self.is_wizard_passed
assert feed.generated_playlists == [generated_playlist]
assert feed.headlines == self.headlines
assert feed.today == self.today
assert feed.days == [day]
assert feed.next_revision == self.next_revision
def test_equality(self, generated_playlist, day):
a = Feed(self.can_get_more_events, self.pumpkin, self.is_wizard_passed, [generated_playlist], self.headlines,
self.today, [day])
b = Feed(False, self.pumpkin, self.is_wizard_passed, None, self.headlines, self.today, [day])
c = Feed(self.can_get_more_events, self.pumpkin, self.is_wizard_passed, [generated_playlist], self.headlines,
self.today, [day])
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

42
tests/test_generated_playlist.py ノーマルファイル
ファイルの表示

@ -0,0 +1,42 @@
from yandex_music import GeneratedPlaylist
class TestGeneratedPlaylist:
type = 'playlistOfTheDay'
ready = True
notify = False
def test_expected_values(self, generated_playlist, playlist):
assert generated_playlist.type == self.type
assert generated_playlist.ready == self.ready
assert generated_playlist.notify == self.notify
assert generated_playlist.data == playlist
def test_de_json_required(self, client, playlist):
json_dict = {'type': self.type, 'ready': self.ready, 'notify': self.notify, 'data': playlist.to_dict()}
generated_playlist = GeneratedPlaylist.de_json(json_dict, client)
assert generated_playlist.type == self.type
assert generated_playlist.ready == self.ready
assert generated_playlist.notify == self.notify
assert generated_playlist.data == playlist
def test_de_json_all(self, client, playlist):
json_dict = {'type': self.type, 'ready': self.ready, 'notify': self.notify, 'data': playlist.to_dict()}
generated_playlist = GeneratedPlaylist.de_json(json_dict, client)
assert generated_playlist.type == self.type
assert generated_playlist.ready == self.ready
assert generated_playlist.notify == self.notify
assert generated_playlist.data == playlist
def test_equality(self, playlist):
a = GeneratedPlaylist(self.type, self.ready, self.notify, playlist)
b = GeneratedPlaylist(self.type, False, self.notify, None)
c = GeneratedPlaylist(self.type, self.ready, self.notify, playlist)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

90
tests/test_genre.py ノーマルファイル
ファイルの表示

@ -0,0 +1,90 @@
import pytest
from yandex_music import Genre
@pytest.fixture(scope='class')
def genre(title, images, icon, genre_without_sub_genre):
return Genre(TestGenre.id, TestGenre.weight, TestGenre.composer_top, TestGenre.title, {'uz': title}, images,
TestGenre.show_in_menu, TestGenre.full_title, TestGenre.url_part, TestGenre.color, icon,
[genre_without_sub_genre], TestGenre.hide_in_regions)
@pytest.fixture(scope='class')
def genre_without_sub_genre(title, images, icon):
return Genre(TestGenre.id, TestGenre.weight, TestGenre.composer_top, TestGenre.title, {'uz': title}, images,
TestGenre.show_in_menu)
class TestGenre:
id = 'all'
weight = 2
composer_top = False
title = None
show_in_menu = True
full_title = 'Музыка всех жанров'
url_part = None
color = None
hide_in_regions = None
def test_expected_values(self, genre, title, images, icon, genre_without_sub_genre):
assert genre.id == self.id
assert genre.weight == self.weight
assert genre.composer_top == self.composer_top
assert genre.title == self.title
assert genre.titles == {"uz": title}
assert genre.images == images
assert genre.show_in_menu == self.show_in_menu
assert genre.full_title == self.full_title
assert genre.url_part == self.url_part
assert genre.color == self.color
assert genre.radio_icon == icon
assert genre.sub_genres == [genre_without_sub_genre]
assert genre.hide_in_regions == self.hide_in_regions
def test_de_json_required(self, client, title, images):
json_dict = {'id': self.id, 'weight': self.weight, 'composer_top': self.composer_top, 'title': self.title,
'titles': {'uz': title.to_dict()}, 'images': images.to_dict(), 'show_in_menu': self.show_in_menu}
genre = Genre.de_json(json_dict, client)
assert genre.id == self.id
assert genre.weight == self.weight
assert genre.composer_top == self.composer_top
assert genre.title == self.title
assert genre.titles == {'uz': title}
assert genre.images == images
assert genre.show_in_menu == self.show_in_menu
def test_de_json_all(self, client, title, images, icon, genre_without_sub_genre):
json_dict = {'id': self.id, 'weight': self.weight, 'composer_top': self.composer_top, 'title': self.title,
'titles': {'uz': title.to_dict()}, 'images': images.to_dict(), 'show_in_menu': self.show_in_menu,
'full_title': self.full_title, 'url_part': self.url_part, 'color': self.color,
'radio_icon': icon.to_dict(), 'sub_genres': [genre_without_sub_genre.to_dict()],
'hide_in_regions': self.hide_in_regions}
genre = Genre.de_json(json_dict, client)
assert genre.id == self.id
assert genre.weight == self.weight
assert genre.composer_top == self.composer_top
assert genre.title == self.title
assert genre.titles == {'uz': title}
assert genre.images == images
assert genre.show_in_menu == self.show_in_menu
assert genre.full_title == self.full_title
assert genre.url_part == self.url_part
assert genre.color == self.color
assert genre.radio_icon == icon
assert genre.sub_genres == [genre_without_sub_genre]
assert genre.hide_in_regions == self.hide_in_regions
def test_equality(self, title, images):
a = Genre(self.id, self.weight, self.composer_top, self.title, {'uz': title}, images, self.show_in_menu)
b = Genre(self.id, self.weight, False, '', {'uz': title}, images, self.show_in_menu)
c = Genre(self.id, 30, self.composer_top, self.title, {'uz': title}, images, self.show_in_menu)
d = Genre(self.id, self.weight, self.composer_top, self.title, {'uz': title}, images, self.show_in_menu)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

36
tests/test_icon.py ノーマルファイル
ファイルの表示

@ -0,0 +1,36 @@
from yandex_music import Icon
class TestIcon:
background_color = '#ff6665'
image_url = 'avatars.yandex.net/get-music-misc/34161/rotor-genre-pop-icon/%%'
def test_expected_values(self, icon):
assert icon.background_color == self.background_color
assert icon.image_url == self.image_url
def test_de_json_required(self, client):
json_dict = {'background_color': self.background_color, 'image_url': self.image_url}
icon = Icon.de_json(json_dict, client)
assert icon.background_color == self.background_color
assert icon.image_url == self.image_url
def test_de_json_all(self, client):
json_dict = {'background_color': self.background_color, 'image_url': self.image_url}
icon = Icon.de_json(json_dict, client)
assert icon.background_color == self.background_color
assert icon.image_url == self.image_url
def test_equality(self):
a = Icon(self.background_color, self.image_url)
b = Icon('#000000', self.image_url)
c = Icon(self.background_color, '')
d = Icon(self.background_color, self.image_url)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

36
tests/test_id.py ノーマルファイル
ファイルの表示

@ -0,0 +1,36 @@
from yandex_music import Id
class TestId:
type = 'user'
tag = 'onyourwave'
def test_expected_values(self, id):
assert id.type == self.type
assert id.tag == self.tag
def test_de_json_required(self, client):
json_dict = {'type': self.type, 'tag': self.tag}
id = Id.de_json(json_dict, client)
assert id.type == self.type
assert id.tag == self.tag
def test_de_json_all(self, client):
json_dict = {'type': self.type, 'tag': self.tag}
id = Id.de_json(json_dict, client)
assert id.type == self.type
assert id.tag == self.tag
def test_equality(self):
a = Id(self.type, self.tag)
b = Id('', self.tag)
c = Id(self.type, '')
d = Id(self.type, self.tag)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

27
tests/test_images.py ノーマルファイル
ファイルの表示

@ -0,0 +1,27 @@
from yandex_music import Images
class TestImages:
_208x208 = 'http://avatars.mds.yandex.net/get-music-misc/28052/metagenre-pop-x208/orig'
_300x300 = 'http://avatars.mds.yandex.net/get-music-misc/28052/metagenre-pop-x300/orig'
def test_expected_values(self, images):
assert images._208x208 == self._208x208
assert images._300x300 == self._300x300
def test_de_json_required(self, client):
json_dict = {}
images = Images.de_json(json_dict, client)
def test_de_json_all(self, client):
json_dict = {'_208x208': self._208x208, '_300x300': self._300x300}
images = Images.de_json(json_dict, client)
assert images._208x208 == self._208x208
assert images._300x300 == self._300x300
def test_equality(self):
a = Images(self._208x208, self._300x300)
b = Images(self._208x208, self._300x300)
assert a == b

39
tests/test_invocation_info.py ノーマルファイル
ファイルの表示

@ -0,0 +1,39 @@
from yandex_music import InvocationInfo
class TestInvocationInfo:
hostname = 'myt1-0261-c2e-msk-myt-music-st-e72-18274.gencfg-c.yandex.net'
req_id = '1573172241066040-16981638052883278246'
exec_duration_millis = '0'
def test_expected_values(self, invocation_info):
assert invocation_info.hostname == self.hostname
assert invocation_info.req_id == self.req_id
assert invocation_info.exec_duration_millis == self.exec_duration_millis
def test_de_json_required(self, client):
json_dict = {'hostname': self.hostname, 'req_id': self.req_id}
invocation_info = InvocationInfo.de_json(json_dict, client)
assert invocation_info.hostname == self.hostname
assert invocation_info.req_id == self.req_id
def test_de_json_all(self, client):
json_dict = {'hostname': self.hostname, 'req_id': self.req_id,
'exec_duration_millis': self.exec_duration_millis}
invocation_info = InvocationInfo.de_json(json_dict, client)
assert invocation_info.hostname == self.hostname
assert invocation_info.req_id == self.req_id
assert invocation_info.exec_duration_millis == self.exec_duration_millis
def test_equality(self):
a = InvocationInfo(self.hostname, self.req_id)
b = InvocationInfo('', self.req_id, 0)
c = InvocationInfo(self.hostname, self.req_id, 20)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

36
tests/test_label.py ノーマルファイル
ファイルの表示

@ -0,0 +1,36 @@
from yandex_music import Label
class TestLabel:
id = 148217
name = 'tommee profitt STUDIOS'
def test_expected_values(self, label):
assert label.id == self.id
assert label.name == self.name
def test_de_json_required(self, client):
json_dict = {'id': self.id, 'name': self.name}
label = Label.de_json(json_dict, client)
assert label.id == self.id
assert label.name == self.name
def test_de_json_all(self, client):
json_dict = {'id': self.id, 'name': self.name}
label = Label.de_json(json_dict, client)
assert label.id == self.id
assert label.name == self.name
def test_equality(self):
a = Label(self.id, self.name)
b = Label(10, self.name)
c = Label(self.id, '')
d = Label(self.id, self.name)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

46
tests/test_landing.py ノーマルファイル
ファイルの表示

@ -0,0 +1,46 @@
import pytest
from yandex_music import Landing
@pytest.fixture(scope='class')
def landing(block):
return Landing(TestLanding.pumpkin, TestLanding.content_id, [block])
class TestLanding:
pumpkin = False
content_id = '-1159799446'
def test_expected_values(self, landing, block):
assert landing.pumpkin == self.pumpkin
assert landing.content_id == self.content_id
assert landing.blocks == [block]
def test_de_json_required(self, client, block):
json_dict = {'pumpkin': self.pumpkin, 'content_id': self.content_id, 'blocks': [block.to_dict()]}
landing = Landing.de_json(json_dict, client)
assert landing.pumpkin == self.pumpkin
assert landing.content_id == self.content_id
assert landing.blocks == [block]
def test_de_json_all(self, client, block):
json_dict = {'pumpkin': self.pumpkin, 'content_id': self.content_id, 'blocks': [block.to_dict()]}
landing = Landing.de_json(json_dict, client)
assert landing.pumpkin == self.pumpkin
assert landing.content_id == self.content_id
assert landing.blocks == [block]
def test_equality(self, block):
a = Landing(self.pumpkin, self.content_id, [block])
b = Landing(self.pumpkin, '', [block])
c = Landing(self.pumpkin, self.content_id, None)
d = Landing(self.pumpkin, self.content_id, [block])
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

43
tests/test_link.py ノーマルファイル
ファイルの表示

@ -0,0 +1,43 @@
from yandex_music import Link
class TestLink:
title = 'emmure'
href = 'https://www.facebook.com/emmure'
type = 'social'
social_network = 'facebook'
def test_expected_values(self, link):
assert link.title == self.title
assert link.href == self.href
assert link.type == self.type
assert link.social_network == self.social_network
def test_de_json_required(self, client):
json_dict = {'title': self.title, 'href': self.href, 'type': self.type}
link = Link.de_json(json_dict, client)
assert link.title == self.title
assert link.href == self.href
assert link.type == self.type
def test_de_json_all(self, client):
json_dict = {'title': self.title, 'href': self.href, 'type': self.type, 'social_network': self.social_network}
link = Link.de_json(json_dict, client)
assert link.title == self.title
assert link.href == self.href
assert link.type == self.type
assert link.social_network == self.social_network
def test_equality(self):
a = Link(self.title, self.href, self.type, self.social_network)
b = Link(self.title, '', self.type, self.social_network)
c = Link(self.title, self.href, '', self.social_network)
d = Link(self.title, self.href, self.type, self.social_network)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

71
tests/test_lyrics.py ノーマルファイル
ファイルの表示

@ -0,0 +1,71 @@
from yandex_music import Lyrics
class TestLyrics:
id = 103844
lyrics = 'Too big, too small?\nSize does matter, after all\nZu groß, zu klein?\nEr könnte etwas größer sein'
full_lyrics = 'Too big, too small?\nSize does matter, after all\nZu groß, zu klein?\nEr könnte etwas größer ' \
'sein\n\nMercedes-Benz und Autobahn\nAlleine in das Ausland fahren\nReise, ' \
'Reise! Fahrvergnügen\nIch will nur Spaß, mich nicht verlieben\n\nJust a little bit...\nJust a ' \
'little, bitch!\n\nYou\'ve got a pussy\nI have a dick, ah.\nSo what\'s the problem?\nLet\'s do it ' \
'quick!\n\nSo take me now, before it\'s too late\nLife\'s too short, so I can\'t wait\nTake me now! ' \
'Oh, don\'t you see?\nI can\'t get laid in Germany…\n\nToo short, too tall?\nDoesn\'t matter, ' \
'one size fits all\nZu groß, zu klein?\nDer Schlagbaum sollte oben sein\n\nSchönes Fräulein, ' \
'Lust auf mehr\nBlitzkrieg mit dem Fleischgewehr\nSchnaps im Kopf, du holde Braut\nSteck Bratwurst ' \
'in dein Sauerkraut\n\nJust a little bit...\nBe my little bitch!\n\nYou\'ve got a pussy\nI have a ' \
'dick, ah\nSo what\'s the problem?\nLet\'s do it quick!\n\nSo take me now, before it\'s too ' \
'late\nLife\'s too short, so I can\'t wait\nTake me now! Oh, don\'t you see?\nI can\'t get laid in ' \
'Germany…\n\nGermany! Germany!\n\nYou\'ve got a pussy\nI have a dick, ah\nSo what\'s the ' \
'problem?\nLet\'s do it quick!\n\nYou\'ve got a pussy\nI have a dick, ah\nSo what\'s the ' \
'problem?\nLet\'s do it quick!\n\nYou\'ve got a pussy\nI have a dick, ah\nSo what\'s the ' \
'problem?\nLet\'s do it quick!\n\nSo take me now, before it\'s too late\nLife\'s too short, ' \
'so I can\'t wait\nTake me now! Oh, don\'t you see?\nI can\'t get laid in Germany…\n '
has_rights = True
text_language = 'de'
show_translation = True
def test_expected_values(self, lyrics):
assert lyrics.id == self.id
assert lyrics.lyrics == self.lyrics
assert lyrics.full_lyrics == self.full_lyrics
assert lyrics.has_rights == self.has_rights
assert lyrics.text_language == self.text_language
assert lyrics.show_translation == self.show_translation
def test_de_json_required(self, client):
json_dict = {'id': self.id, 'lyrics': self.lyrics, 'full_lyrics': self.full_lyrics,
'has_rights': self.has_rights, 'text_language': self.text_language,
'show_translation': self.show_translation}
lyrics = Lyrics.de_json(json_dict, client)
assert lyrics.id == self.id
assert lyrics.lyrics == self.lyrics
assert lyrics.full_lyrics == self.full_lyrics
assert lyrics.has_rights == self.has_rights
assert lyrics.text_language == self.text_language
assert lyrics.show_translation == self.show_translation
def test_de_json_all(self, client):
json_dict = {'id': self.id, 'lyrics': self.lyrics, 'full_lyrics': self.full_lyrics,
'has_rights': self.has_rights, 'text_language': self.text_language,
'show_translation': self.show_translation}
lyrics = Lyrics.de_json(json_dict, client)
assert lyrics.id == self.id
assert lyrics.lyrics == self.lyrics
assert lyrics.full_lyrics == self.full_lyrics
assert lyrics.has_rights == self.has_rights
assert lyrics.text_language == self.text_language
assert lyrics.show_translation == self.show_translation
def test_equality(self):
a = Lyrics(self.id, self.lyrics, self.full_lyrics, self.has_rights, self.text_language, self.show_translation)
b = Lyrics(self.id, self.lyrics, '', self.has_rights, self.text_language, False)
c = Lyrics(10, self.lyrics, self.full_lyrics, self.has_rights, '', self.show_translation)
d = Lyrics(self.id, self.lyrics, self.full_lyrics, self.has_rights, self.text_language, self.show_translation)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

27
tests/test_made_for.py ノーマルファイル
ファイルの表示

@ -0,0 +1,27 @@
from yandex_music import MadeFor
class TestMadeFor:
def test_expected_values(self, made_for, user, case_forms):
assert made_for.user_info == user
assert made_for.case_forms == case_forms
def test_de_json_required(self, client, user, case_forms):
json_dict = {'user_info': user.to_dict(), 'case_forms': case_forms.to_dict()}
made_for = MadeFor.de_json(json_dict, client)
assert made_for.user_info == user
assert made_for.case_forms == case_forms
def test_de_json_all(self, client, user, case_forms):
json_dict = {'user_info': user.to_dict(), 'case_forms': case_forms.to_dict()}
made_for = MadeFor.de_json(json_dict, client)
assert made_for.user_info == user
assert made_for.case_forms == case_forms
def test_equality(self, user, case_forms):
a = MadeFor(user, case_forms)
assert a != user and a != case_forms
assert hash(a) != hash(user) != hash(case_forms)

35
tests/test_major.py ノーマルファイル
ファイルの表示

@ -0,0 +1,35 @@
from yandex_music import Major
class TestMajor:
id = 4
name = 'WARNER'
def test_expected_values(self, major):
assert major.id == self.id
assert major.name == self.name
def test_de_json_required(self, client):
json_dict = {'id': self.id, 'name': self.name}
major = Major.de_json(json_dict, client)
assert major.id == self.id
assert major.name == self.name
def test_de_json_all(self, client):
json_dict = {'id': self.id, 'name': self.name}
major = Major.de_json(json_dict, client)
assert major.id == self.id
assert major.name == self.name
def test_equality(self):
a = Major(self.id, self.name)
b = Major(10, self.name)
c = Major(self.id, self.name)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

64
tests/test_mix_link.py ノーマルファイル
ファイルの表示

@ -0,0 +1,64 @@
from yandex_music import MixLink
class TestMixLink:
title = 'Беларусь'
url = '/tag/belarus'
url_scheme = 'yandexmusic://tag/belarus'
text_color = '#6c65a9'
background_color = 'transparent'
background_image_uri = 'avatars.yandex.net/get-music-misc/28592/mix.5cf0bd5e58ea3a1e70caa07b.background-image.1559281047248/%%'
cover_white = 'avatars.yandex.net/get-music-misc/28052/mix.5cf0bd5e58ea3a1e70caa07b.cover-white.1559281049219/%%'
def test_expected_values(self, mix_link):
assert mix_link.title == self.title
assert mix_link.url == self.url
assert mix_link.url_scheme == self.url_scheme
assert mix_link.text_color == self.text_color
assert mix_link.background_color == self.background_color
assert mix_link.background_image_uri == self.background_image_uri
assert mix_link.cover_white == self.cover_white
def test_de_json_required(self, client):
json_dict = {'title': self.title, 'url': self.url, 'url_scheme': self.url_scheme, 'text_color': self.text_color,
'background_color': self.background_color, 'background_image_uri': self.background_image_uri,
'cover_white': self.cover_white}
mix_link = MixLink.de_json(json_dict, client)
assert mix_link.title == self.title
assert mix_link.url == self.url
assert mix_link.url_scheme == self.url_scheme
assert mix_link.text_color == self.text_color
assert mix_link.background_color == self.background_color
assert mix_link.background_image_uri == self.background_image_uri
assert mix_link.cover_white == self.cover_white
def test_de_json_all(self, client):
json_dict = {'title': self.title, 'url': self.url, 'url_scheme': self.url_scheme, 'text_color': self.text_color,
'background_color': self.background_color, 'background_image_uri': self.background_image_uri,
'cover_white': self.cover_white}
mix_link = MixLink.de_json(json_dict, client)
assert mix_link.title == self.title
assert mix_link.url == self.url
assert mix_link.url_scheme == self.url_scheme
assert mix_link.text_color == self.text_color
assert mix_link.background_color == self.background_color
assert mix_link.background_image_uri == self.background_image_uri
assert mix_link.cover_white == self.cover_white
def test_equality(self):
a = MixLink(self.title, self.url, self.url_scheme, self.text_color, self.background_color,
self.background_image_uri, self.cover_white)
b = MixLink(self.title, self.url, '', self.text_color, self.background_color,
self.background_image_uri, self.cover_white)
c = MixLink(self.title, self.url, self.url_scheme, '#000000', self.background_color,
self.background_image_uri, self.cover_white)
d = MixLink(self.title, self.url, self.url_scheme, self.text_color, self.background_color,
self.background_image_uri, self.cover_white)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

37
tests/test_normalization.py ノーマルファイル
ファイルの表示

@ -0,0 +1,37 @@
from yandex_music import Normalization
class TestNormalization:
gain = -3.89
peak = 29168
def test_expected_values(self, normalization):
assert normalization.gain == self.gain
assert normalization.peak == self.peak
def test_de_json_required(self, client):
json_dict = {'gain': self.gain, 'peak': self.peak}
normalization = Normalization.de_json(json_dict, client)
assert normalization.gain == self.gain
assert normalization.peak == self.peak
def test_de_json_all(self, client):
json_dict = {'gain': self.gain, 'peak': self.peak}
normalization = Normalization.de_json(json_dict, client)
assert normalization.gain == self.gain
assert normalization.peak == self.peak
def test_equality(self):
a = Normalization(self.gain, self.peak)
b = Normalization(10, self.peak)
c = Normalization(self.gain, 10)
d = Normalization(10, 10)
e = Normalization(self.gain, self.peak)
assert a != b != c != d
assert hash(a) != hash(b) != hash(c) != hash(d)
assert a is not b is not c is not d
assert a == e

40
tests/test_pager.py ノーマルファイル
ファイルの表示

@ -0,0 +1,40 @@
from yandex_music import Pager
class TestPager:
total = 4
page = 0
per_page = 4
def test_expected_values(self, pager):
assert pager.total == self.total
assert pager.page == self.page
assert pager.per_page == self.per_page
def test_de_json_required(self, client):
json_dict = {'total': self.total, 'page': self.page, 'per_page': self.per_page}
pager = Pager.de_json(json_dict, client)
assert pager.total == self.total
assert pager.page == self.page
assert pager.per_page == self.per_page
def test_de_json_all(self, client):
json_dict = {'total': self.total, 'page': self.page, 'per_page': self.per_page}
pager = Pager.de_json(json_dict, client)
assert pager.total == self.total
assert pager.page == self.page
assert pager.per_page == self.per_page
def test_equality(self):
a = Pager(self.total, self.page, self.per_page)
b = Pager(0, self.page, self.per_page)
c = Pager(self.total, 0, 0)
d = Pager(self.total, self.page, self.per_page)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

31
tests/test_passport_phone.py ノーマルファイル
ファイルの表示

@ -0,0 +1,31 @@
from yandex_music import PassportPhone
class TestPassportPhone:
phone = '+375295773423'
def test_expected_values(self, passport_phone):
assert passport_phone.phone == self.phone
def test_de_json_required(self, client):
json_dict = {'phone': self.phone}
passport_phone = PassportPhone.de_json(json_dict, client)
assert passport_phone.phone == self.phone
def test_de_json_all(self, client):
json_dict = {'phone': self.phone}
passport_phone = PassportPhone.de_json(json_dict, client)
assert passport_phone.phone == self.phone
def test_equality(self):
a = PassportPhone(self.phone)
b = PassportPhone('')
c = PassportPhone(self.phone)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

34
tests/test_permission_alerts.py ノーマルファイル
ファイルの表示

@ -0,0 +1,34 @@
import pytest
from yandex_music import PermissionAlerts
@pytest.fixture(scope='class')
def permission_alerts():
return PermissionAlerts(TestPermissionAlerts.alerts)
class TestPermissionAlerts:
alerts = []
def test_expected_values(self, permission_alerts):
assert permission_alerts.alerts == self.alerts
def test_de_json_required(self, client):
json_dict = {'alerts': self.alerts}
permission_alerts = PermissionAlerts.de_json(json_dict, client)
assert permission_alerts.alerts == self.alerts
def test_de_json_all(self, client):
json_dict = {'alerts': self.alerts}
permission_alerts = PermissionAlerts.de_json(json_dict, client)
assert permission_alerts.alerts == self.alerts
def test_equality(self, permissions):
a = PermissionAlerts([])
assert a != permissions
assert hash(a) != hash(permissions)
assert a is not permissions

39
tests/test_permissions.py ノーマルファイル
ファイルの表示

@ -0,0 +1,39 @@
from yandex_music import Permissions
class TestPermissions:
until = '2019-11-07T23:53:55+00:00'
values = ['landing-play', 'feed-play', 'mix-play']
default = ['landing-play', 'feed-play', 'mix-play']
def test_expected_values(self, permissions):
assert permissions.until == self.until
assert permissions.values == self.values
assert permissions.default == self.default
def test_de_json_required(self, client):
json_dict = {'until': self.until, 'values': self.values, 'default': self.default}
permissions = Permissions.de_json(json_dict, client)
assert permissions.until == self.until
assert permissions.values == self.values
assert permissions.default == self.default
def test_de_json_all(self, client):
json_dict = {'until': self.until, 'values': self.values, 'default': self.default}
permissions = Permissions.de_json(json_dict, client)
assert permissions.until == self.until
assert permissions.values == self.values
assert permissions.default == self.default
def test_equality(self):
a = Permissions(self.until, self.values, self.default)
b = Permissions('', self.values, self.default)
c = Permissions(self.until, self.values, self.default)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

31
tests/test_personal_playlists_data.py ノーマルファイル
ファイルの表示

@ -0,0 +1,31 @@
from yandex_music import PersonalPlaylistsData
class TestPersonalPlaylistsData:
is_wizard_passed = True
def test_expected_values(self, personal_playlists_data):
assert personal_playlists_data.is_wizard_passed == self.is_wizard_passed
def test_de_json_required(self, client):
json_dict = {'is_wizard_passed': self.is_wizard_passed}
personal_playlists_data = PersonalPlaylistsData.de_json(json_dict, client)
assert personal_playlists_data.is_wizard_passed == self.is_wizard_passed
def test_de_json_all(self, client):
json_dict = {'is_wizard_passed': self.is_wizard_passed}
personal_playlists_data = PersonalPlaylistsData.de_json(json_dict, client)
assert personal_playlists_data.is_wizard_passed == self.is_wizard_passed
def test_equality(self):
a = PersonalPlaylistsData(self.is_wizard_passed)
b = PersonalPlaylistsData(False)
c = PersonalPlaylistsData(self.is_wizard_passed)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

44
tests/test_play_context.py ノーマルファイル
ファイルの表示

@ -0,0 +1,44 @@
from yandex_music import PlayContext
class TestPlayContext:
client_ = 'android'
context = 'playlist'
context_item = '503646255:69814820'
def test_expected_values(self, play_context, track_short_old):
assert play_context.client_ == self.client_
assert play_context.context == self.context
assert play_context.context_item == self.context_item
assert play_context.tracks == [track_short_old]
def test_de_json_required(self, client, track_short_old):
json_dict = {'client_': self.client_, 'context': self.context, 'context_item': self.context_item,
'tracks': [track_short_old.to_dict()]}
play_context = PlayContext.de_json(json_dict, client)
assert play_context.client_ == self.client_
assert play_context.context == self.context
assert play_context.context_item == self.context_item
assert play_context.tracks == [track_short_old]
def test_de_json_all(self, client, track_short_old):
json_dict = {'client_': self.client_, 'context': self.context, 'context_item': self.context_item,
'tracks': [track_short_old.to_dict()]}
play_context = PlayContext.de_json(json_dict, client)
assert play_context.client_ == self.client_
assert play_context.context == self.context
assert play_context.context_item == self.context_item
assert play_context.tracks == [track_short_old]
def test_equality(self, track_short_old):
a = PlayContext(self.client_, self.context, self.context_item, [track_short_old])
b = PlayContext('', self.context, self.context_item, [])
c = PlayContext(self.client_, self.context, self.context_item, [track_short_old])
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

26
tests/test_play_contexts_data.py ノーマルファイル
ファイルの表示

@ -0,0 +1,26 @@
from yandex_music import PlayContextsData
class TestPlayContextsData:
def test_expected_values(self, play_contexts_data, track_short_old):
assert play_contexts_data.other_tracks == [track_short_old]
def test_de_json_required(self, client, track_short_old):
json_dict = {'other_tracks': [track_short_old.to_dict()]}
play_contexts_data = PlayContextsData.de_json(json_dict, client)
assert play_contexts_data.other_tracks == [track_short_old]
def test_de_json_all(self, client, track_short_old):
json_dict = {'other_tracks': [track_short_old.to_dict()]}
play_contexts_data = PlayContextsData.de_json(json_dict, client)
assert play_contexts_data.other_tracks == [track_short_old]
def test_equality(self, track_short_old):
a = PlayContextsData([track_short_old])
b = PlayContextsData(None)
assert a != b != track_short_old
assert hash(a) != hash(b) != hash(track_short_old)
assert a is not track_short_old

40
tests/test_play_counter.py ノーマルファイル
ファイルの表示

@ -0,0 +1,40 @@
from yandex_music import PlayCounter
class TestPlayCounter:
description = 'А&nbsp;вот и&nbsp;ответ на&nbsp;главный вопрос жизни, вселенной и&nbsp;всего такого'
value = 42
updated = True
def test_expected_values(self, play_counter):
assert play_counter.value == self.value
assert play_counter.description == self.description
assert play_counter.updated == self.updated
def test_de_json_required(self, client):
json_dict = {'value': self.value, 'description': self.description, 'updated': self.updated}
play_counter = PlayCounter.de_json(json_dict, client)
assert play_counter.value == self.value
assert play_counter.description == self.description
assert play_counter.updated == self.updated
def test_de_json_all(self, client):
json_dict = {'value': self.value, 'description': self.description, 'updated': self.updated}
play_counter = PlayCounter.de_json(json_dict, client)
assert play_counter.value == self.value
assert play_counter.description == self.description
assert play_counter.updated == self.updated
def test_equality(self):
a = PlayCounter(self.value, self.description, self.updated)
b = PlayCounter(30, self.description, self.updated)
c = PlayCounter(self.value, self.description, False)
d = PlayCounter(self.value, self.description, self.updated)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

133
tests/test_playlist.py ノーマルファイル
ファイルの表示

@ -0,0 +1,133 @@
from yandex_music import Playlist
class TestPlaylist:
uid = 503646255
kind = 69814820
title = 'Плейлист дня'
track_count = 57
tags = []
revision = 0
snapshot = 1
visibility = 'public'
collective = False
created = '2018-04-29T21:00:00+00:00'
modified = '2019-11-09T03:00:00+00:00'
available = True
is_banner = False
is_premiere = False
duration_ms = 12402690
og_image = 'avatars.yandex.net/get-music-user-playlist/38125/q0ahkhfQE3neTk/%%?1572609906461'
prerolls = []
likes_count = 1
generated_playlist_type = 'playlistOfTheDay'
animated_cover_uri = 'avatars.yandex.net/get-music-user-playlist/30088/q0ahjvoZK5FT4A/%%'
ever_played = True
description = 'Каждый день — новый. Каждый день — ваш!'
description_formatted = 'Каждый день — новый. Каждый день — ваш!'
is_for_from = None
regions = None
def test_expected_values(self, playlist, user, cover, made_for, track_short, play_counter):
assert playlist.owner == user
assert playlist.uid == self.uid
assert playlist.kind == self.kind
assert playlist.title == self.title
assert playlist.track_count == self.track_count
assert playlist.cover == cover
assert playlist.made_for == made_for
assert playlist.play_counter == play_counter
assert playlist.tags == self.tags
assert playlist.revision == self.revision
assert playlist.snapshot == self.snapshot
assert playlist.visibility == self.visibility
assert playlist.collective == self.collective
assert playlist.created == self.created
assert playlist.modified == self.modified
assert playlist.available == self.available
assert playlist.is_banner == self.is_banner
assert playlist.is_premiere == self.is_premiere
assert playlist.duration_ms == self.duration_ms
assert playlist.og_image == self.og_image
assert playlist.tracks == [track_short]
assert playlist.prerolls == self.prerolls
assert playlist.likes_count == self.likes_count
assert playlist.generated_playlist_type == self.generated_playlist_type
assert playlist.animated_cover_uri == self.animated_cover_uri
assert playlist.ever_played == self.ever_played
assert playlist.description == self.description
assert playlist.description_formatted == self.description_formatted
assert playlist.is_for_from == self.is_for_from
assert playlist.regions == self.regions
def test_de_json_required(self, client, user, cover, made_for, play_counter):
json_dict = {'owner': user.to_dict(), 'uid': self.uid, 'kind': self.kind, 'title': self.title,
'track_count': self.track_count, 'cover': cover.to_dict(), 'made_for': made_for.to_dict(),
'play_counter': play_counter.to_dict()}
playlist = Playlist.de_json(json_dict, client)
assert playlist.owner == user
assert playlist.uid == self.uid
assert playlist.kind == self.kind
assert playlist.title == self.title
assert playlist.track_count == self.track_count
assert playlist.cover == cover
assert playlist.made_for == made_for
assert playlist.play_counter == play_counter
def test_de_json_all(self, client, user, cover, made_for, track_short, play_counter):
json_dict = {'owner': user.to_dict(), 'uid': self.uid, 'kind': self.kind, 'title': self.title,
'track_count': self.track_count, 'cover': cover.to_dict(), 'made_for': made_for.to_dict(),
'play_counter': play_counter.to_dict(), 'tags': self.tags, 'revision': self.revision,
'snapshot': self.snapshot, 'visibility': self.visibility, 'collective': self.collective,
'created': self.created, 'modified': self.modified, 'available': self.available,
'is_banner': self.is_banner, 'is_premiere': self.is_premiere, 'duration_ms': self.duration_ms,
'og_image': self.og_image, 'tracks': [track_short.to_dict()], 'prerolls': self.prerolls,
'likes_count': self.likes_count, 'generated_playlist_type': self.generated_playlist_type,
'animated_cover_uri': self.animated_cover_uri, 'ever_played': self.ever_played,
'description': self.description, 'description_formatted': self.description_formatted,
'is_for_from': self.is_for_from, 'regions': self.regions}
playlist = Playlist.de_json(json_dict, client)
assert playlist.owner == user
assert playlist.uid == self.uid
assert playlist.kind == self.kind
assert playlist.title == self.title
assert playlist.track_count == self.track_count
assert playlist.cover == cover
assert playlist.made_for == made_for
assert playlist.play_counter == play_counter
assert playlist.tags == self.tags
assert playlist.revision == self.revision
assert playlist.snapshot == self.snapshot
assert playlist.visibility == self.visibility
assert playlist.collective == self.collective
assert playlist.created == self.created
assert playlist.modified == self.modified
assert playlist.available == self.available
assert playlist.is_banner == self.is_banner
assert playlist.is_premiere == self.is_premiere
assert playlist.duration_ms == self.duration_ms
assert playlist.og_image == self.og_image
assert playlist.tracks == [track_short]
assert playlist.prerolls == self.prerolls
assert playlist.likes_count == self.likes_count
assert playlist.generated_playlist_type == self.generated_playlist_type
assert playlist.animated_cover_uri == self.animated_cover_uri
assert playlist.ever_played == self.ever_played
assert playlist.description == self.description
assert playlist.description_formatted == self.description_formatted
assert playlist.is_for_from == self.is_for_from
assert playlist.regions == self.regions
def test_equality(self, user, cover, made_for, play_counter):
a = Playlist(user, self.uid, self.kind, self.title, self.track_count, cover, made_for, play_counter)
b = Playlist(user, 123, self.kind, self.title, 10, cover, made_for, play_counter)
c = Playlist(user, self.uid, 321, self.title, self.track_count, None, made_for, play_counter)
d = Playlist(user, self.uid, self.kind, self.title, self.track_count, cover, made_for, play_counter)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

36
tests/test_playlist_id.py ノーマルファイル
ファイルの表示

@ -0,0 +1,36 @@
from yandex_music import PlaylistId
class TestPlaylistId:
uid = 460142547
kind = 5332052
def test_expected_values(self, playlist_id):
assert playlist_id.uid == self.uid
assert playlist_id.kind == self.kind
def test_de_json_required(self, client):
json_dict = {'uid': self.uid, 'kind': self.kind}
playlist_id = PlaylistId.de_json(json_dict, client)
assert playlist_id.uid == self.uid
assert playlist_id.kind == self.kind
def test_de_json_all(self, client):
json_dict = {'uid': self.uid, 'kind': self.kind}
playlist_id = PlaylistId.de_json(json_dict, client)
assert playlist_id.uid == self.uid
assert playlist_id.kind == self.kind
def test_equality(self):
a = PlaylistId(self.uid, self.kind)
b = PlaylistId(self.uid, 10)
c = PlaylistId(10, self.kind)
d = PlaylistId(self.uid, self.kind)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

43
tests/test_playlists_likes.py ノーマルファイル
ファイルの表示

@ -0,0 +1,43 @@
import pytest
from yandex_music import PlaylistsLikes
@pytest.fixture(scope='class')
def playlists_likes(playlist):
return PlaylistsLikes(TestPlaylistsLikes.timestamp, TestPlaylistsLikes.id, playlist)
class TestPlaylistsLikes:
id = None
timestamp = '2019-06-21T05:41:46+00:00'
def test_expected_values(self, playlists_likes, playlist):
assert playlists_likes.timestamp == self.timestamp
assert playlists_likes.id == self.id
assert playlists_likes.playlist == playlist
def test_de_json_required(self, client):
json_dict = {'timestamp': self.timestamp}
playlists_likes = PlaylistsLikes.de_json(json_dict, client)
assert playlists_likes.timestamp == self.timestamp
def test_de_json_all(self, client, playlist):
json_dict = {'timestamp': self.timestamp, 'id': self.id, 'playlist': playlist.to_dict()}
playlists_likes = PlaylistsLikes.de_json(json_dict, client)
assert playlists_likes.timestamp == self.timestamp
assert playlists_likes.id == self.id
assert playlists_likes.playlist == playlist
def test_equality(self, playlist):
a = PlaylistsLikes(self.timestamp, self.id, playlist)
b = PlaylistsLikes(self.timestamp, self.id, None)
c = PlaylistsLikes(self.timestamp, self.id, playlist)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

35
tests/test_plus.py ノーマルファイル
ファイルの表示

@ -0,0 +1,35 @@
from yandex_music import Plus
class TestPlus:
has_plus = True
is_tutorial_completed = True
def test_expected_values(self, plus):
assert plus.has_plus == self.has_plus
assert plus.is_tutorial_completed == self.is_tutorial_completed
def test_de_json_required(self, client):
json_dict = {'has_plus': self.has_plus, 'is_tutorial_completed': self.is_tutorial_completed}
plus = Plus.de_json(json_dict, client)
assert plus.has_plus == self.has_plus
assert plus.is_tutorial_completed == self.is_tutorial_completed
def test_de_json_all(self, client):
json_dict = {'has_plus': self.has_plus, 'is_tutorial_completed': self.is_tutorial_completed}
plus = Plus.de_json(json_dict, client)
assert plus.has_plus == self.has_plus
assert plus.is_tutorial_completed == self.is_tutorial_completed
def test_equality(self):
a = Plus(self.has_plus, self.is_tutorial_completed)
b = Plus(self.has_plus, False)
c = Plus(self.has_plus, self.is_tutorial_completed)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

36
tests/test_price.py ノーマルファイル
ファイルの表示

@ -0,0 +1,36 @@
from yandex_music import Price
class TestPrice:
amount = 99
currency = 'RUB'
def test_expected_values(self, price):
assert price.amount == self.amount
assert price.currency == self.currency
def test_de_json_required(self, client):
json_dict = {'amount': self.amount, 'currency': self.currency}
price = Price.de_json(json_dict, client)
assert price.amount == self.amount
assert price.currency == self.currency
def test_de_json_all(self, client):
json_dict = {'amount': self.amount, 'currency': self.currency}
price = Price.de_json(json_dict, client)
assert price.amount == self.amount
assert price.currency == self.currency
def test_equality(self):
a = Price(self.amount, self.currency)
b = Price(10, self.currency)
c = Price(self.amount, 'USD')
d = Price(self.amount, self.currency)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

94
tests/test_product.py ノーマルファイル
ファイルの表示

@ -0,0 +1,94 @@
from yandex_music import Product
class TestProduct:
product_id = 'ru.yandex.mobile.music.1month.autorenewable.native.web.notrial.restricted.cache.99'
type = 'subscription'
common_period_duration = 'P1M'
description = None
duration = 30
trial_duration = 0
feature = ['basic-music']
debug = False
features = 'basic-music'
available = None
trial_available = None
vendor_trial_available = None
button_text = None
button_additional_text = None
payment_method_types = None
def test_expected_values(self, product, price):
assert product.product_id == self.product_id
assert product.type == self.type
assert product.common_period_duration == self.common_period_duration
assert product.duration == self.duration
assert product.trial_duration == self.trial_duration
assert product.price == price
assert product.feature == self.feature
assert product.debug == self.debug
assert product.features == self.features
assert product.description == self.description
assert product.available == self.available
assert product.trial_available == self.trial_available
assert product.vendor_trial_available == self.vendor_trial_available
assert product.button_text == self.button_text
assert product.button_additional_text == self.button_additional_text
assert product.payment_method_types == self.payment_method_types
def test_de_json_required(self, client, price):
json_dict = {'product_id': self.product_id, 'type': self.type,
'common_period_duration': self.common_period_duration, 'duration': self.duration,
'trial_duration': self.trial_duration, 'price': price.to_dict(), 'feature': self.feature,
'debug': self.debug}
product = Product.de_json(json_dict, client)
assert product.product_id == self.product_id
assert product.type == self.type
assert product.common_period_duration == self.common_period_duration
assert product.duration == self.duration
assert product.trial_duration == self.trial_duration
assert product.price == price
assert product.feature == self.feature
assert product.debug == self.debug
def test_de_json_all(self, client, price):
json_dict = {'product_id': self.product_id, 'type': self.type,
'common_period_duration': self.common_period_duration, 'duration': self.duration,
'trial_duration': self.trial_duration, 'price': price.to_dict(), 'feature': self.feature,
'debug': self.debug, 'features': self.features, 'description': self.description,
'available': self.available, 'trial_available': self.trial_available,
'vendor_trial_available': self.vendor_trial_available, 'button_text': self.button_text,
'button_additional_text': self.button_additional_text,
'payment_method_types': self.payment_method_types}
product = Product.de_json(json_dict, client)
assert product.product_id == self.product_id
assert product.type == self.type
assert product.common_period_duration == self.common_period_duration
assert product.duration == self.duration
assert product.trial_duration == self.trial_duration
assert product.price == price
assert product.feature == self.feature
assert product.debug == self.debug
assert product.features == self.features
assert product.description == self.description
assert product.available == self.available
assert product.trial_available == self.trial_available
assert product.vendor_trial_available == self.vendor_trial_available
assert product.button_text == self.button_text
assert product.button_additional_text == self.button_additional_text
assert product.payment_method_types == self.payment_method_types
def test_equality(self, price):
a = Product(self.product_id, self.type, self.common_period_duration, self.duration, self.trial_duration, price,
self.feature, self.debug)
b = Product(10, self.type, self.common_period_duration, self.duration, self.trial_duration, price,
self.feature, self.debug)
c = Product(self.product_id, self.type, self.common_period_duration, self.duration, self.trial_duration, price,
self.feature, self.debug)
assert a != b
assert hash(a) != hash(b)
assert a == c

45
tests/test_promo_code_status.py ノーマルファイル
ファイルの表示

@ -0,0 +1,45 @@
import pytest
from yandex_music import PromoCodeStatus
@pytest.fixture(scope='class')
def promo_code_status(status):
return PromoCodeStatus(TestPromoCodeStatus.status, TestPromoCodeStatus.status_desc, status)
class TestPromoCodeStatus:
status = 'user-temporary-banned'
status_desc = 'You entered the wrong code more than 10 times. You will be able to continue in 24 hours.'
def test_expected_values(self, promo_code_status, status):
assert promo_code_status.status == self.status
assert promo_code_status.status_desc == self.status_desc
assert promo_code_status.account_status == status
def test_de_json_required(self, client, status):
json_dict = {'status': self.status, 'status_desc': self.status_desc, 'account_status': status.to_dict()}
promo_code_status = PromoCodeStatus.de_json(json_dict, client)
assert promo_code_status.status == self.status
assert promo_code_status.status_desc == self.status_desc
assert promo_code_status.account_status == status
def test_de_json_all(self, client, status):
json_dict = {'status': self.status, 'status_desc': self.status_desc, 'account_status': status.to_dict()}
promo_code_status = PromoCodeStatus.de_json(json_dict, client)
assert promo_code_status.status == self.status
assert promo_code_status.status_desc == self.status_desc
assert promo_code_status.account_status == status
def test_equality(self, status):
a = PromoCodeStatus(self.status, self.status_desc, status)
b = PromoCodeStatus(self.status, '', status)
c = PromoCodeStatus(self.status, self.status_desc, status)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

72
tests/test_promotion.py ノーマルファイル
ファイルの表示

@ -0,0 +1,72 @@
from yandex_music import Promotion
class TestPromotion:
promo_id = '5db861cfa6245a2c8c63445d'
title = '«Никакого андеграунда!»'
subtitle = 'на новой пластинке группы «Папин Олимпос»'
heading = 'Мини-альбом'
url = '/album/8839440'
url_scheme = 'yandexmusic://album/8839440'
text_color = ''
gradient = ''
image = 'avatars.yandex.net/get-music-feed-promotion/69892/5db861cfa6245a2c8c63445d-landing.image/%%'
def test_expected_values(self, promotion):
assert promotion.promo_id == self.promo_id
assert promotion.title == self.title
assert promotion.subtitle == self.subtitle
assert promotion.heading == self.heading
assert promotion.url == self.url
assert promotion.url_scheme == self.url_scheme
assert promotion.text_color == self.text_color
assert promotion.gradient == self.gradient
assert promotion.image == self.image
def test_de_json_required(self, client):
json_dict = {'promo_id': self.promo_id, 'title': self.title, 'subtitle': self.subtitle, 'heading': self.heading,
'url': self.url, 'url_scheme': self.url_scheme, 'text_color': self.text_color,
'gradient': self.gradient, 'image': self.image}
promotion = Promotion.de_json(json_dict, client)
assert promotion.promo_id == self.promo_id
assert promotion.title == self.title
assert promotion.subtitle == self.subtitle
assert promotion.heading == self.heading
assert promotion.url == self.url
assert promotion.url_scheme == self.url_scheme
assert promotion.text_color == self.text_color
assert promotion.gradient == self.gradient
assert promotion.image == self.image
def test_de_json_all(self, client):
json_dict = {'promo_id': self.promo_id, 'title': self.title, 'subtitle': self.subtitle, 'heading': self.heading,
'url': self.url, 'url_scheme': self.url_scheme, 'text_color': self.text_color,
'gradient': self.gradient, 'image': self.image}
promotion = Promotion.de_json(json_dict, client)
assert promotion.promo_id == self.promo_id
assert promotion.title == self.title
assert promotion.subtitle == self.subtitle
assert promotion.heading == self.heading
assert promotion.url == self.url
assert promotion.url_scheme == self.url_scheme
assert promotion.text_color == self.text_color
assert promotion.gradient == self.gradient
assert promotion.image == self.image
def test_equality(self):
a = Promotion(self.promo_id, self.title, self.subtitle, self.heading, self.url, self.url_scheme,
self.text_color, self.gradient, self.image)
b = Promotion('', self.title, self.subtitle, '', self.url, self.url_scheme,
self.text_color, self.gradient, self.image)
c = Promotion(self.promo_id, '', self.subtitle, self.heading, self.url, self.url_scheme,
self.text_color, self.gradient, '')
d = Promotion(self.promo_id, self.title, self.subtitle, self.heading, self.url, self.url_scheme,
self.text_color, self.gradient, self.image)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

38
tests/test_ratings.py ノーマルファイル
ファイルの表示

@ -0,0 +1,38 @@
from yandex_music import Ratings
class TestRatings:
week = 4949
month = 6597
day = 5512
def test_expected_values(self, ratings):
assert ratings.week == self.week
assert ratings.month == self.month
assert ratings.day == self.day
def test_de_json_required(self, client):
json_dict = {'week': self.week, 'month': self.month}
ratings = Ratings.de_json(json_dict, client)
assert ratings.week == self.week
assert ratings.month == self.month
def test_de_json_all(self, client):
json_dict = {'week': self.week, 'month': self.month, 'day': self.day}
ratings = Ratings.de_json(json_dict, client)
assert ratings.week == self.week
assert ratings.month == self.month
assert ratings.day == self.day
def test_equality(self):
a = Ratings(self.week, self.month)
b = Ratings(10, self.month)
c = Ratings(self.week, self.month, self.day)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

39
tests/test_restrictions.py ノーマルファイル
ファイルの表示

@ -0,0 +1,39 @@
from yandex_music import Restrictions
class TestRestrictions:
def test_expected_values(self, restrictions, enum, discrete_scale):
assert restrictions.language == enum
assert restrictions.diversity == enum
assert restrictions.mood == discrete_scale
assert restrictions.energy == discrete_scale
assert restrictions.mood_energy == enum
def test_de_json_required(self, client, enum):
json_dict = {'language': enum.to_dict(), 'diversity': enum.to_dict()}
restrictions = Restrictions.de_json(json_dict, client)
assert restrictions.language == enum
assert restrictions.diversity == enum
def test_de_json_all(self, client, enum, discrete_scale):
json_dict = {'language': enum.to_dict(), 'diversity': enum.to_dict(), 'mood': discrete_scale.to_dict(),
'energy': discrete_scale.to_dict(), 'mood_energy': enum.to_dict()}
restrictions = Restrictions.de_json(json_dict, client)
assert restrictions.language == enum
assert restrictions.diversity == enum
assert restrictions.mood == discrete_scale
assert restrictions.energy == discrete_scale
assert restrictions.mood_energy == enum
def test_equality(self, enum, discrete_scale):
a = Restrictions(enum, enum)
b = Restrictions(enum, None, discrete_scale, discrete_scale, discrete_scale, enum)
c = Restrictions(enum, enum)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

45
tests/test_rotor_settings.py ノーマルファイル
ファイルの表示

@ -0,0 +1,45 @@
from yandex_music import RotorSettings
class TestRotorSettings:
language = 'not-russian'
diversity = 'default'
mood = 2
energy = 2
mood_energy = None
def test_expected_values(self, rotor_settings):
assert rotor_settings.language == self.language
assert rotor_settings.diversity == self.diversity
assert rotor_settings.mood == self.mood
assert rotor_settings.energy == self.energy
assert rotor_settings.mood_energy == self.mood_energy
def test_de_json_required(self, client):
json_dict = {'language': self.language, 'diversity': self.diversity}
rotor_settings = RotorSettings.de_json(json_dict, client)
assert rotor_settings.language == self.language
assert rotor_settings.diversity == self.diversity
def test_de_json_all(self, client):
json_dict = {'language': self.language, 'diversity': self.diversity, 'mood': self.mood, 'energy': self.energy,
'mood_energy': self.mood_energy}
rotor_settings = RotorSettings.de_json(json_dict, client)
assert rotor_settings.language == self.language
assert rotor_settings.diversity == self.diversity
assert rotor_settings.mood == self.mood
assert rotor_settings.energy == self.energy
assert rotor_settings.mood_energy == self.mood_energy
def test_equality(self):
a = RotorSettings(self.language, self.diversity)
b = RotorSettings('', self.diversity)
c = RotorSettings(self.language, self.diversity)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

89
tests/test_search.py ノーマルファイル
ファイルの表示

@ -0,0 +1,89 @@
import pytest
from tests import TestSearchResult
from yandex_music import Search, SearchResult
@pytest.fixture(scope='class')
def search_result(results):
def make_search_result(param):
return SearchResult(TestSearchResult.total, TestSearchResult.per_page,
TestSearchResult.order, [results[param]])
return make_search_result
@pytest.fixture(scope='class')
def search(best, search_result):
return Search(TestSearch.search_request_id, TestSearch.text, best,
search_result(3), search_result(2), search_result(4),
search_result(1), search_result(5), TestSearch.misspell_corrected, TestSearch.nocorrect)
class TestSearch:
search_request_id = 'myt1-0261-c2e-msk-myt-music-st-e72-18274.gencfg-c.yandex.net-1573323135801461' \
'-3742331365077765411-1573323135819 '
text = 'NCS'
misspell_corrected = False
nocorrect = False
def test_expected_values(self, search, best, search_result):
assert search.search_request_id == self.search_request_id
assert search.text == self.text
assert search.best == best
assert search.albums == search_result(3)
assert search.artists == search_result(2)
assert search.playlists == search_result(4)
assert search.tracks == search_result(1)
assert search.videos == search_result(5)
assert search.misspell_corrected == self.misspell_corrected
assert search.nocorrect == self.nocorrect
def test_de_json_required(self, client, best, search_result):
json_dict = {'search_request_id': self.search_request_id, 'text': self.text, 'best': best.to_dict(),
'albums': search_result(3).to_dict(), 'artists': search_result(2).to_dict(),
'playlists': search_result(4).to_dict(), 'tracks': search_result(1).to_dict(),
'videos': search_result(5).to_dict()}
search = Search.de_json(json_dict, client)
assert search.search_request_id == self.search_request_id
assert search.text == self.text
assert search.best == best
assert search.albums == search_result(3)
assert search.artists == search_result(2)
assert search.playlists == search_result(4)
assert search.tracks == search_result(1)
assert search.videos == search_result(5)
def test_de_json_all(self, client, best, search_result):
json_dict = {'search_request_id': self.search_request_id, 'text': self.text, 'best': best.to_dict(),
'albums': search_result(3).to_dict(), 'artists': search_result(2).to_dict(),
'playlists': search_result(4).to_dict(), 'tracks': search_result(1).to_dict(),
'videos': search_result(5).to_dict(), 'misspell_corrected': self.misspell_corrected,
'nocorrect': self.nocorrect}
search = Search.de_json(json_dict, client)
assert search.search_request_id == self.search_request_id
assert search.text == self.text
assert search.best == best
assert search.albums == search_result(3)
assert search.artists == search_result(2)
assert search.playlists == search_result(4)
assert search.tracks == search_result(1)
assert search.videos == search_result(5)
assert search.misspell_corrected == self.misspell_corrected
assert search.nocorrect == self.nocorrect
def test_equality(self, best, search_result):
a = Search(self.search_request_id, self.text, best, search_result(3), search_result(2), search_result(4),
search_result(1), search_result(5))
b = Search(self.search_request_id, '', best, search_result(3), None, search_result(4), search_result(1),
search_result(5))
c = Search(self.search_request_id, self.text, best, search_result(3), search_result(2), search_result(4),
search_result(1), search_result(5))
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

50
tests/test_search_result.py ノーマルファイル
ファイルの表示

@ -0,0 +1,50 @@
from yandex_music import SearchResult
class TestSearchResult:
total = 3
per_page = 10
order = 0
def test_expected_values(self, search_result_with_results):
search_result, results = search_result_with_results
assert search_result.total == self.total
assert search_result.per_page == self.per_page
assert search_result.order == self.order
assert search_result.results == results
def test_de_json_required(self, client, result_with_type):
result, type = result_with_type
json_dict = {'total': self.total, 'per_page': self.per_page, 'order': self.order, 'results': [result.to_dict()]}
search_result = SearchResult.de_json(json_dict, client, type)
assert search_result.total == self.total
assert search_result.per_page == self.per_page
assert search_result.order == self.order
assert search_result.results == [result]
def test_de_json_all(self, client, result_with_type):
result, type = result_with_type
json_dict = {'total': self.total, 'per_page': self.per_page, 'order': self.order, 'results': [result.to_dict()]}
search_result = SearchResult.de_json(json_dict, client, type)
assert search_result.total == self.total
assert search_result.per_page == self.per_page
assert search_result.order == self.order
assert search_result.results == [result]
def test_equality(self, result_with_type):
result, _ = result_with_type
a = SearchResult(self.total, self.per_page, self.order, [result])
b = SearchResult(10, self.per_page, 1, [result])
c = SearchResult(self.total, self.per_page, self.order, [result])
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

38
tests/test_sequence.py ノーマルファイル
ファイルの表示

@ -0,0 +1,38 @@
from yandex_music import Sequence
class TestSequence:
type = 'track'
liked = False
def test_expected_values(self, sequence, track):
assert sequence.type == self.type
assert sequence.track == track
assert sequence.liked == self.liked
def test_de_json_required(self, client, track):
json_dict = {'type': self.type, 'track': track.to_dict(), 'liked': self.liked}
sequence = Sequence.de_json(json_dict, client)
assert sequence.type == self.type
assert sequence.track == track
assert sequence.liked == self.liked
def test_de_json_all(self, client, track):
json_dict = {'type': self.type, 'track': track.to_dict(), 'liked': self.liked}
sequence = Sequence.de_json(json_dict, client)
assert sequence.type == self.type
assert sequence.track == track
assert sequence.liked == self.liked
def test_equality(self, track):
a = Sequence(self.type, track, self.liked)
b = Sequence('', track, True)
c = Sequence(self.type, track, self.liked)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

47
tests/test_settings.py ノーマルファイル
ファイルの表示

@ -0,0 +1,47 @@
from yandex_music import Settings
class TestSettings:
web_payment_url = 'https://music.yandex.ru/webview/payment'
promo_codes_enabled = True
def test_expected_values(self, settings, product, price):
assert settings.in_app_products == [product]
assert settings.native_products == [product]
assert settings.web_payment_url == self.web_payment_url
assert settings.promo_codes_enabled == self.promo_codes_enabled
assert settings.web_payment_month_product_price == price
def test_de_json_required(self, client, product):
json_dict = {'in_app_products': [product.to_dict()], 'native_products': [product.to_dict()],
'web_payment_url': self.web_payment_url, 'promo_codes_enabled': self.promo_codes_enabled}
settings = Settings.de_json(json_dict, client)
assert settings.in_app_products == [product]
assert settings.native_products == [product]
assert settings.web_payment_url == self.web_payment_url
assert settings.promo_codes_enabled == self.promo_codes_enabled
def test_de_json_all(self, client, product, price):
json_dict = {'in_app_products': [product.to_dict()], 'native_products': [product.to_dict()],
'web_payment_url': self.web_payment_url, 'promo_codes_enabled': self.promo_codes_enabled,
'web_payment_month_product_price': price.to_dict()}
settings = Settings.de_json(json_dict, client)
assert settings.in_app_products == [product]
assert settings.native_products == [product]
assert settings.web_payment_url == self.web_payment_url
assert settings.promo_codes_enabled == self.promo_codes_enabled
assert settings.web_payment_month_product_price == price
def test_equality(self, product):
a = Settings([product], [product], self.web_payment_url, self.promo_codes_enabled)
b = Settings([product], [product], '', self.promo_codes_enabled)
c = Settings([product], [product], self.web_payment_url, False)
d = Settings([product], [product], self.web_payment_url, self.promo_codes_enabled)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

61
tests/test_station.py ノーマルファイル
ファイルの表示

@ -0,0 +1,61 @@
from yandex_music import Station
class TestStation:
name = 'На вашей волне'
id_for_from = 'user-561231028'
def test_expected_values(self, station, id, icon, restrictions):
assert station.id == id
assert station.name == self.name
assert station.icon == icon
assert station.mts_icon == icon
assert station.geocell_icon == icon
assert station.id_for_from == self.id_for_from
assert station.restrictions == restrictions
assert station.restrictions2 == restrictions
assert station.parent_id == id
def test_de_json_required(self, client, id, icon, restrictions):
json_dict = {'id': id.to_dict(), 'name': self.name, 'icon': icon.to_dict(), 'mts_icon': icon.to_dict(),
'geocell_icon': icon.to_dict(), 'id_for_from': self.id_for_from,
'restrictions': restrictions.to_dict(), 'restrictions2': restrictions.to_dict()}
station = Station.de_json(json_dict, client)
assert station.id == id
assert station.name == self.name
assert station.icon == icon
assert station.mts_icon == icon
assert station.geocell_icon == icon
assert station.id_for_from == self.id_for_from
assert station.restrictions == restrictions
assert station.restrictions2 == restrictions
def test_de_json_all(self, client, id, icon, restrictions):
json_dict = {'id': id.to_dict(), 'name': self.name, 'icon': icon.to_dict(), 'mts_icon': icon.to_dict(),
'geocell_icon': icon.to_dict(), 'id_for_from': self.id_for_from,
'restrictions': restrictions.to_dict(), 'restrictions2': restrictions.to_dict(),
'parent_id': id.to_dict()}
station = Station.de_json(json_dict, client)
assert station.id == id
assert station.name == self.name
assert station.icon == icon
assert station.mts_icon == icon
assert station.geocell_icon == icon
assert station.id_for_from == self.id_for_from
assert station.restrictions == restrictions
assert station.restrictions2 == restrictions
assert station.parent_id == id
def test_equality(self, id, icon, restrictions):
a = Station(id, icon, self.name, icon, icon, icon, self.id_for_from, restrictions, restrictions)
b = Station(id, icon, self.name, None, icon, icon, self.id_for_from, restrictions, restrictions)
c = Station(id, icon, '', icon, icon, None, self.id_for_from, restrictions, restrictions)
d = Station(id, icon, self.name, icon, icon, icon, self.id_for_from, restrictions, restrictions)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

49
tests/test_station_result.py ノーマルファイル
ファイルの表示

@ -0,0 +1,49 @@
from yandex_music import StationResult
class TestStationResult:
explanation = ''
prerolls = []
def test_expected_values(self, station_result, station, rotor_settings, ad_params):
assert station_result.station == station
assert station_result.settings == rotor_settings
assert station_result.settings2 == rotor_settings
assert station_result.ad_params == ad_params
assert station_result.explanation == self.explanation
assert station_result.prerolls == self.prerolls
def test_de_json_required(self, client, station, rotor_settings, ad_params):
json_dict = {'station': station.to_dict(), 'settings': rotor_settings.to_dict(),
'settings2': rotor_settings.to_dict(), 'ad_params': ad_params.to_dict()}
station_result = StationResult.de_json(json_dict, client)
assert station_result.station == station
assert station_result.settings == rotor_settings
assert station_result.settings2 == rotor_settings
assert station_result.ad_params == ad_params
def test_de_json_all(self, client, station, rotor_settings, ad_params):
json_dict = {'station': station.to_dict(), 'settings': rotor_settings.to_dict(),
'settings2': rotor_settings.to_dict(), 'ad_params': ad_params.to_dict(),
'explanation': self.explanation, 'prerolls': self.prerolls}
station_result = StationResult.de_json(json_dict, client)
assert station_result.station == station
assert station_result.settings == rotor_settings
assert station_result.settings2 == rotor_settings
assert station_result.ad_params == ad_params
assert station_result.explanation == self.explanation
assert station_result.prerolls == self.prerolls
def test_equality(self, station, rotor_settings, ad_params):
a = StationResult(station, rotor_settings, rotor_settings, ad_params)
b = StationResult(None, rotor_settings, rotor_settings, ad_params)
c = StationResult(station, None, rotor_settings, ad_params)
d = StationResult(station, rotor_settings, rotor_settings, ad_params)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

50
tests/test_station_tracks_result.py ノーマルファイル
ファイルの表示

@ -0,0 +1,50 @@
import pytest
from yandex_music import StationTracksResult
@pytest.fixture(scope='class')
def station_tracks_result(id, sequence):
return StationTracksResult(id, [sequence], TestStationTracksResult.batch_id, TestStationTracksResult.pumpkin)
class TestStationTracksResult:
batch_id = '1573227402825981-2727432063278102211'
pumpkin = False
def test_expected_values(self, station_tracks_result, id, sequence):
assert station_tracks_result.id == id
assert station_tracks_result.sequence == [sequence]
assert station_tracks_result.batch_id == self.batch_id
assert station_tracks_result.pumpkin == self.pumpkin
def test_de_json_required(self, client, id, sequence):
json_dict = {'id': id.to_dict(), 'sequence': [sequence.to_dict()], 'batch_id': self.batch_id,
'pumpkin': self.pumpkin}
station_tracks_result = StationTracksResult.de_json(json_dict, client)
assert station_tracks_result.id == id
assert station_tracks_result.sequence == [sequence]
assert station_tracks_result.batch_id == self.batch_id
assert station_tracks_result.pumpkin == self.pumpkin
def test_de_json_all(self, client, id, sequence):
json_dict = {'id': id.to_dict(), 'sequence': [sequence.to_dict()], 'batch_id': self.batch_id,
'pumpkin': self.pumpkin}
station_tracks_result = StationTracksResult.de_json(json_dict, client)
assert station_tracks_result.id == id
assert station_tracks_result.sequence == [sequence]
assert station_tracks_result.batch_id == self.batch_id
assert station_tracks_result.pumpkin == self.pumpkin
def test_equality(self, id, sequence):
a = StationTracksResult(id, sequence, self.batch_id, self.pumpkin)
b = StationTracksResult(id, sequence, "", False)
c = StationTracksResult(id, sequence, self.batch_id, self.pumpkin)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

62
tests/test_status.py ノーマルファイル
ファイルの表示

@ -0,0 +1,62 @@
from yandex_music import Status
class TestStatus:
cache_limit = 99
subeditor = False
subeditor_level = 0
default_email = 'Ilya@marshal.by'
skips_per_hour = None
station_exists = None
premium_region = None
def test_expected_values(self, status, account, permissions, subscription, plus):
assert status.account == account
assert status.permissions == permissions
assert status.subscription == subscription
assert status.cache_limit == self.cache_limit
assert status.subeditor == self.subeditor
assert status.subeditor_level == self.subeditor_level
assert status.plus == plus
assert status.default_email == self.default_email
assert status.skips_per_hour == self.skips_per_hour
assert status.station_exists == self.station_exists
assert status.premium_region == self.premium_region
def test_de_json_required(self, client, account, permissions):
json_dict = {'account': account.to_dict(), 'permissions': permissions.to_dict()}
status = Status.de_json(json_dict, client)
assert status.account == account
assert status.permissions == permissions
def test_de_json_all(self, client, account, permissions, subscription, plus):
json_dict = {'account': account.to_dict(), 'permissions': permissions.to_dict(),
'subscription': subscription.to_dict(), 'cache_limit': self.cache_limit,
'subeditor': self.subeditor, 'subeditor_level': self.subeditor_level, 'plus': plus.to_dict(),
'default_email': self.default_email, 'skips_per_hour': self.skips_per_hour,
'station_exists': self.station_exists, 'premium_region': self.premium_region}
status = Status.de_json(json_dict, client)
assert status.account == account
assert status.permissions == permissions
assert status.subscription == subscription
assert status.cache_limit == self.cache_limit
assert status.subeditor == self.subeditor
assert status.subeditor_level == self.subeditor_level
assert status.plus == plus
assert status.default_email == self.default_email
assert status.skips_per_hour == self.skips_per_hour
assert status.station_exists == self.station_exists
assert status.premium_region == self.premium_region
def test_equality(self, account, permissions, subscription):
a = Status(account, permissions)
b = Status(None, permissions, subscription, self.cache_limit)
c = Status(account, permissions)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

35
tests/test_subscription.py ノーマルファイル
ファイルの表示

@ -0,0 +1,35 @@
from yandex_music import Subscription
class TestSubscription:
can_start_trial = False
mcdonalds = False
end = None
def test_expected_values(self, subscription, auto_renewable):
assert subscription.auto_renewable == [auto_renewable]
assert subscription.can_start_trial == self.can_start_trial
assert subscription.mcdonalds == self.mcdonalds
assert subscription.end == self.end
def test_de_json_required(self, client):
json_dict = {}
subscription = Subscription.de_json(json_dict, client)
def test_de_json_all(self, client, auto_renewable):
json_dict = {'auto_renewable': [auto_renewable.to_dict()], 'can_start_trial': self.can_start_trial,
'mcdonalds': self.mcdonalds, 'end': self.end}
subscription = Subscription.de_json(json_dict, client)
assert subscription.auto_renewable == [auto_renewable]
assert subscription.can_start_trial == self.can_start_trial
assert subscription.mcdonalds == self.mcdonalds
assert subscription.end == self.end
def test_equality(self, auto_renewable):
a = Subscription([auto_renewable])
b = Subscription(None)
assert a != b != auto_renewable
assert hash(a) != hash(b) != hash(auto_renewable)
assert a is not auto_renewable

50
tests/test_suggestions.py ノーマルファイル
ファイルの表示

@ -0,0 +1,50 @@
import pytest
from tests import TestBest
from yandex_music import Suggestions, Best
@pytest.fixture(scope='class', params=[1, 2, 3, 4, 5])
def suggestions_with_best(request, results, types):
best = Best(types[request.param], results[request.param], TestBest.text)
return Suggestions(best, TestSuggestions.suggestions), best
class TestSuggestions:
suggestions = ['empathy test', 'testament', 'crash test dummies', 'seekae - test & recognise', 'joji - test drive',
'john powell - test drive', 'max richter - testament of youth', 'seekae - test & recognise',
'testament - first strike still deadly', '90-е в стиле r&b и соул',
'crash test dummy: из чего состоит portishead', 'в стиле: alice testrup']
def test_expected_values(self, suggestions_with_best):
suggestions, best = suggestions_with_best
assert suggestions.best == best
assert suggestions.suggestions == self.suggestions
def test_de_json_required(self, client, best):
json_dict = {'best': best.to_dict(), 'suggestions': self.suggestions}
suggestions = Suggestions.de_json(json_dict, client)
assert suggestions.best == best
assert suggestions.suggestions == self.suggestions
def test_de_json_all(self, client, best):
json_dict = {'best': best.to_dict(), 'suggestions': self.suggestions}
suggestions = Suggestions.de_json(json_dict, client)
assert suggestions.best == best
assert suggestions.suggestions == self.suggestions
def test_equality(self, best):
a = Suggestions(best, self.suggestions)
b = Suggestions(None, self.suggestions)
c = Suggestions(best, '')
d = Suggestions(best, self.suggestions)
assert a != b != c
assert hash(a) != hash(b) != hash(c)
assert a is not b is not c
assert a == d

50
tests/test_supplement.py ノーマルファイル
ファイルの表示

@ -0,0 +1,50 @@
import pytest
from yandex_music import Supplement
@pytest.fixture(scope='class')
def supplement(lyrics, video_supplement):
return Supplement(TestSupplement.id, lyrics, [video_supplement], TestSupplement.radio_is_available)
class TestSupplement:
id = 103844
radio_is_available = False
def test_expected_values(self, supplement, lyrics, video_supplement):
assert supplement.id == self.id
assert supplement.lyrics == lyrics
assert supplement.videos == [video_supplement]
assert supplement.radio_is_available == self.radio_is_available
def test_de_json_required(self, client, lyrics, video_supplement):
json_dict = {'id': self.id, 'lyrics': lyrics.to_dict(), 'videos': [video_supplement.to_dict()],
'radio_is_available': self.radio_is_available}
supplement = Supplement.de_json(json_dict, client)
assert supplement.id == self.id
assert supplement.lyrics == lyrics
assert supplement.videos == [video_supplement]
assert supplement.radio_is_available == self.radio_is_available
def test_de_json_all(self, client, lyrics, video_supplement):
json_dict = {'id': self.id, 'lyrics': lyrics.to_dict(), 'videos': [video_supplement.to_dict()],
'radio_is_available': self.radio_is_available}
supplement = Supplement.de_json(json_dict, client)
assert supplement.id == self.id
assert supplement.lyrics == lyrics
assert supplement.videos == [video_supplement]
assert supplement.radio_is_available == self.radio_is_available
def test_equality(self, lyrics, video_supplement):
a = Supplement(self.id, lyrics, [video_supplement], self.radio_is_available)
b = Supplement(self.id, None, [video_supplement], True)
c = Supplement(self.id, lyrics, [video_supplement], self.radio_is_available)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

34
tests/test_title.py ノーマルファイル
ファイルの表示

@ -0,0 +1,34 @@
from yandex_music import Title
class TestTitle:
title = 'Hammasi'
full_title = 'Barcha janrlar musiqasi'
def test_expected_values(self, title):
assert title.title == self.title
assert title.full_title == self.full_title
def test_de_json_required(self, client):
json_dict = {'title': self.title}
title = Title.de_json(json_dict, client)
assert title.title == self.title
def test_de_json_all(self, client):
json_dict = {'title': self.title, 'full_title': self.full_title}
title = Title.de_json(json_dict, client)
assert title.title == self.title
assert title.full_title == self.full_title
def test_equality(self):
a = Title(self.title, self.full_title)
b = Title('')
c = Title(self.title, self.full_title)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

114
tests/test_track.py ノーマルファイル
ファイルの表示

@ -0,0 +1,114 @@
from yandex_music import Track
class TestTrack:
id = '10994777'
title = 'Sapphire'
available = True
available_for_premium_users = True
lyrics_available = False
real_id = '10994777'
og_image = 'avatars.yandex.net/get-music-content/28589/daef4251.a.1193829-1/%%'
type = 'music'
cover_uri = 'avatars.yandex.net/get-music-content/28589/daef4251.a.1193829-1/%%'
duration_ms = 251270
storage_dir = '51327_109b74ca.36526310.1.609676'
file_size = 6036792
error = None
regions = None
available_as_rbt = None
content_warning = None
explicit = None
preview_duration_ms = 30000
available_full_without_permission = False
def test_expected_values(self, track, artist, album, major, normalization):
assert track.id == self.id
assert track.title == self.title
assert track.available == self.available
assert track.available_for_premium_users == self.available_for_premium_users
assert track.artists == [artist]
assert track.albums == [album]
assert track.lyrics_available == self.lyrics_available
assert track.real_id == self.real_id
assert track.og_image == self.og_image
assert track.type == self.type
assert track.cover_uri == self.cover_uri
assert track.major == major
assert track.duration_ms == self.duration_ms
assert track.storage_dir == self.storage_dir
assert track.file_size == self.file_size
assert track.normalization == normalization
assert track.error == self.error
assert track.regions == self.regions
assert track.available_as_rbt == self.available_as_rbt
assert track.content_warning == self.content_warning
assert track.explicit == self.explicit
assert track.preview_duration_ms == self.preview_duration_ms
assert track.available_full_without_permission == self.available_full_without_permission
def test_de_json_required(self, client, artist, album):
json_dict = {'id': self.id, 'title': self.title, 'available': self.available,
'available_for_premium_users': self.available_for_premium_users,
'artists': [artist.to_dict()], 'albums': [album.to_dict()],
'lyrics_available': self.lyrics_available}
track = Track.de_json(json_dict, client)
assert track.id == self.id
assert track.title == self.title
assert track.available == self.available
assert track.available_for_premium_users == self.available_for_premium_users
assert track.artists == [artist]
assert track.albums == [album]
assert track.lyrics_available == self.lyrics_available
def test_de_json_all(self, client, artist, album, major, normalization):
json_dict = {'id': self.id, 'title': self.title, 'available': self.available,
'available_for_premium_users': self.available_for_premium_users,
'artists': [artist.to_dict()], 'albums': [album.to_dict()],
'lyrics_available': self.lyrics_available, 'real_id': self.real_id,
'og_image': self.og_image, 'type': self.type, 'cover_uri': self.cover_uri,
'major': major.to_dict(), 'duration_ms': self.duration_ms, 'storage_dir': self.storage_dir,
'file_size': self.file_size, 'normalization': normalization.to_dict(), 'error': self.error,
'regions': self.regions, 'available_as_rbt': self.available_as_rbt,
'content_warning': self.content_warning, 'explicit': self.explicit,
'preview_duration_ms': self.preview_duration_ms,
'available_full_without_permission': self.available_full_without_permission}
track = Track.de_json(json_dict, client)
assert track.id == self.id
assert track.title == self.title
assert track.available == self.available
assert track.available_for_premium_users == self.available_for_premium_users
assert track.artists == [artist]
assert track.albums == [album]
assert track.lyrics_available == self.lyrics_available
assert track.real_id == self.real_id
assert track.og_image == self.og_image
assert track.type == self.type
assert track.cover_uri == self.cover_uri
assert track.major == major
assert track.duration_ms == self.duration_ms
assert track.storage_dir == self.storage_dir
assert track.file_size == self.file_size
assert track.normalization == normalization
assert track.error == self.error
assert track.regions == self.regions
assert track.available_as_rbt == self.available_as_rbt
assert track.content_warning == self.content_warning
assert track.explicit == self.explicit
assert track.preview_duration_ms == self.preview_duration_ms
assert track.available_full_without_permission == self.available_full_without_permission
def test_equality(self, artist, album):
a = Track(self.id, self.title, self.available, self.available_for_premium_users, [artist], [album],
self.lyrics_available)
b = Track(self.id, '', self.available, self.available_for_premium_users, [artist], [album], False)
c = Track(self.id, self.title, self.available, self.available_for_premium_users, [artist], [album],
self.lyrics_available)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

34
tests/test_track_id.py ノーマルファイル
ファイルの表示

@ -0,0 +1,34 @@
from yandex_music import TrackId
class TestTrackId:
id = 74340
album_id = 7025
def test_expected_values(self, track_id):
assert track_id.id == self.id
assert track_id.album_id == self.album_id
def test_de_json_required(self, client):
json_dict = {'id': self.id}
track_id = TrackId.de_json(json_dict, client)
assert track_id.id == self.id
def test_de_json_all(self, client):
json_dict = {'id': self.id, 'album_id': self.album_id}
track_id = TrackId.de_json(json_dict, client)
assert track_id.id == self.id
assert track_id.album_id == self.album_id
def test_equality(self):
a = TrackId(self.id, self.album_id)
b = TrackId(10, self.album_id)
c = TrackId(self.id, self.album_id)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

35
tests/test_track_position.py ノーマルファイル
ファイルの表示

@ -0,0 +1,35 @@
from yandex_music import TrackPosition
class TestTrackPosition:
volume = 1
index = 10
def test_expected_values(self, track_position):
assert track_position.volume == self.volume
assert track_position.index == self.index
def test_de_json_required(self, client):
json_dict = {'volume': self.volume, 'index': self.index}
track_position = TrackPosition.de_json(json_dict, client)
assert track_position.volume == self.volume
assert track_position.index == self.index
def test_de_json_all(self, client):
json_dict = {'volume': self.volume, 'index': self.index}
track_position = TrackPosition.de_json(json_dict, client)
assert track_position.volume == self.volume
assert track_position.index == self.index
def test_equality(self):
a = TrackPosition(self.volume, self.index)
b = TrackPosition(5, self.index)
c = TrackPosition(self.volume, 10)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

45
tests/test_track_short.py ノーマルファイル
ファイルの表示

@ -0,0 +1,45 @@
import pytest
from yandex_music import TrackShort
@pytest.fixture(scope='class')
def track_short():
return TrackShort(TestTrackShort.id, TestTrackShort.timestamp, TestTrackShort.album_id)
class TestTrackShort:
id = 21997388
timestamp = '2019-11-07T03:00:00+00:00'
album_id = None
def test_expected_values(self, track_short):
assert track_short.id == self.id
assert track_short.timestamp == self.timestamp
assert track_short.album_id == self.album_id
def test_de_json_required(self, client):
json_dict = {'id': self.id, 'timestamp': self.timestamp}
track_short = TrackShort.de_json(json_dict, client)
assert track_short.id == self.id
assert track_short.timestamp == self.timestamp
def test_de_json_all(self, client):
json_dict = {'id': self.id, 'timestamp': self.timestamp, 'album_id': self.album_id}
track_short = TrackShort.de_json(json_dict, client)
assert track_short.id == self.id
assert track_short.timestamp == self.timestamp
assert track_short.album_id == self.album_id
def test_equality(self):
a = TrackShort(self.id, self.timestamp, self.album_id)
b = TrackShort(23, self.timestamp, self.album_id)
c = TrackShort(self.id, self.timestamp)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

31
tests/test_track_short_old.py ノーマルファイル
ファイルの表示

@ -0,0 +1,31 @@
from yandex_music import TrackShortOld
class TestTrackShortOld:
timestamp = '2019-11-07T19:50:44+00:00'
def test_expected_values(self, track_short_old, track_id):
assert track_short_old.track_id == track_id
assert track_short_old.timestamp == self.timestamp
def test_de_json_required(self, client, track_id):
json_dict = {'track_id': track_id.to_dict(), 'timestamp': self.timestamp}
track_short_old = TrackShortOld.de_json(json_dict, client)
assert track_short_old.track_id == track_id
assert track_short_old.timestamp == self.timestamp
def test_de_json_all(self, client, track_id):
json_dict = {'track_id': track_id.to_dict(), 'timestamp': self.timestamp}
track_short_old = TrackShortOld.de_json(json_dict, client)
assert track_short_old.track_id == track_id
assert track_short_old.timestamp == self.timestamp
def test_equality(self, track_id):
a = TrackShortOld(track_id, self.timestamp)
b = TrackShortOld(track_id, self.timestamp)
assert a == b
assert hash(a) == hash(b)
assert a != track_id

34
tests/test_track_with_ads.py ノーマルファイル
ファイルの表示

@ -0,0 +1,34 @@
from yandex_music import TrackWithAds
class TestTrackWithAds:
type = 'track'
def test_expected_values(self, track_with_ads, track):
assert track_with_ads.type == self.type
assert track_with_ads.track == track
def test_de_json_required(self, client, track):
json_dict = {'type': self.type, 'track': track.to_dict()}
track_with_ads = TrackWithAds.de_json(json_dict, client)
assert track_with_ads.type == self.type
assert track_with_ads.track == track
def test_de_json_all(self, client, track):
json_dict = {'type': self.type, 'track': track.to_dict()}
track_with_ads = TrackWithAds.de_json(json_dict, client)
assert track_with_ads.type == self.type
assert track_with_ads.track == track
def test_equality(self, track):
a = TrackWithAds(self.type, track)
b = TrackWithAds('', track)
c = TrackWithAds(self.type, track)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

45
tests/test_tracks_list.py ノーマルファイル
ファイルの表示

@ -0,0 +1,45 @@
import pytest
from yandex_music import TracksList
@pytest.fixture(scope='class')
def tracks_list(track_short):
return TracksList(TestTracksList.uid, TestTracksList.revision, [track_short])
class TestTracksList:
uid = None
revision = None
def test_expected_values(self, tracks_list, track_short):
assert tracks_list.uid == self.uid
assert tracks_list.revision == self.revision
assert tracks_list.tracks == [track_short]
def test_de_json_required(self, client, track_short):
json_dict = {'uid': self.uid, 'revision': self.revision, 'tracks': [track_short.to_dict()]}
tracks_list = TracksList.de_json(json_dict, client)
assert tracks_list.uid == self.uid
assert tracks_list.revision == self.revision
assert tracks_list.tracks == [track_short]
def test_de_json_all(self, client, track_short):
json_dict = {'uid': self.uid, 'revision': self.revision, 'tracks': [track_short.to_dict()]}
tracks_list = TracksList.de_json(json_dict, client)
assert tracks_list.uid == self.uid
assert tracks_list.revision == self.revision
assert tracks_list.tracks == [track_short]
def test_equality(self, track_short):
a = TracksList(self.uid, self.revision, [track_short])
b = TracksList(123, self.revision, [track_short])
c = TracksList(self.uid, 10, [track_short])
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

49
tests/test_user.py ノーマルファイル
ファイルの表示

@ -0,0 +1,49 @@
from yandex_music import User
class TestUser:
uid = 503646255
login = 'yamusic-daily'
name = 'yamusic-daily'
sex = 'unknown'
verified = False
def test_expected_values(self, user):
assert user.uid == self.uid
assert user.login == self.login
assert user.name == self.name
assert user.sex == self.sex
assert user.verified == self.verified
def test_de_json_required(self, client):
json_dict = {'uid': self.uid, 'login': self.login, 'name': self.name, 'sex': self.sex,
'verified': self.verified}
user = User.de_json(json_dict, client)
assert user.uid == self.uid
assert user.login == self.login
assert user.name == self.name
assert user.sex == self.sex
assert user.verified == self.verified
def test_de_json_all(self, client):
json_dict = {'uid': self.uid, 'login': self.login, 'name': self.name, 'sex': self.sex,
'verified': self.verified}
user = User.de_json(json_dict, client)
assert user.uid == self.uid
assert user.login == self.login
assert user.name == self.name
assert user.sex == self.sex
assert user.verified == self.verified
def test_equality(self):
a = User(self.uid, self.login, self.name, self.sex, self.verified)
b = User(1, self.login, self.name, self.sex, self.verified)
c = User(self.uid, self.login, '', self.sex, self.verified)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

35
tests/test_value.py ノーマルファイル
ファイルの表示

@ -0,0 +1,35 @@
from yandex_music import Value
class TestValue:
value = 'not-russian'
name = 'Иностранный'
def test_expected_values(self, value):
assert value.value == self.value
assert value.name == self.name
def test_de_json_required(self, client):
json_dict = {'value': self.value, 'name': self.name}
value = Value.de_json(json_dict, client)
assert value.value == self.value
assert value.name == self.name
def test_de_json_all(self, client):
json_dict = {'value': self.value, 'name': self.name}
value = Value.de_json(json_dict, client)
assert value.value == self.value
assert value.name == self.name
def test_equality(self):
a = Value(self.value, self.name)
b = Value(self.value, '')
c = Value(self.value, self.name)
assert a != b
assert hash(a) != hash(b)
assert a is not b
assert a == c

変更されたファイルが多すぎるため、一部のファイルは表示されません さらに表示