-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Добавлена статистика прослушиваний исполнителя за месяц (#660)
- Loading branch information
1 parent
d9216d1
commit 1c8619d
Showing
9 changed files
with
106 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
yandex\_music.artist.stats | ||
========================== | ||
|
||
.. automodule:: yandex_music.artist.stats | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from yandex_music import Stats | ||
|
||
|
||
class TestStats: | ||
last_month_listeners = 15111 | ||
last_month_listeners_delta = 5111 | ||
|
||
def test_expected_values(self, stats): | ||
assert stats.last_month_listeners == stats.last_month_listeners | ||
assert stats.last_month_listeners_delta == stats.last_month_listeners_delta | ||
|
||
def test_de_json_none(self, client): | ||
assert Stats.de_json({}, client) is None | ||
|
||
def test_de_json_required(self, client): | ||
json_dict = { | ||
'last_month_listeners': self.last_month_listeners, | ||
'last_month_listeners_delta': self.last_month_listeners_delta, | ||
} | ||
stats = Stats.de_json(json_dict, client) | ||
|
||
assert stats.last_month_listeners == self.last_month_listeners | ||
assert stats.last_month_listeners_delta == self.last_month_listeners_delta | ||
|
||
def test_de_json_all(self, client): | ||
json_dict = { | ||
'last_month_listeners': self.last_month_listeners, | ||
'last_month_listeners_delta': self.last_month_listeners_delta, | ||
} | ||
stats = Stats.de_json(json_dict, client) | ||
|
||
assert stats.last_month_listeners == self.last_month_listeners | ||
assert stats.last_month_listeners_delta == self.last_month_listeners_delta | ||
|
||
def test_equality(self): | ||
a = Stats(self.last_month_listeners, self.last_month_listeners_delta) | ||
b = Stats(51234, self.last_month_listeners_delta) | ||
c = Stats(self.last_month_listeners, self.last_month_listeners_delta) | ||
|
||
assert a != b | ||
assert hash(a) != hash(b) | ||
assert a is not b | ||
|
||
assert a == c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from typing import TYPE_CHECKING, Optional | ||
|
||
from yandex_music import YandexMusicModel | ||
from yandex_music.utils import model | ||
|
||
if TYPE_CHECKING: | ||
from yandex_music import ClientType | ||
|
||
|
||
@model | ||
class Stats(YandexMusicModel): | ||
"""Класс, представляющий статистику слушателей артиста. | ||
Attributes: | ||
last_month_listeners (:obj:`int`): Количество слушателей за последний месяц. | ||
last_month_listeners_delta (:obj:`int`): Изменение количества слушателей за последний месяц. | ||
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. | ||
""" | ||
|
||
last_month_listeners: int | ||
last_month_listeners_delta: int | ||
client: Optional['ClientType'] = None | ||
|
||
def __post_init__(self) -> None: | ||
self._id_attrs = (self.last_month_listeners, self.last_month_listeners_delta) |