File: test_librefm.py

package info (click to toggle)
pylast 5.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 364 kB
  • sloc: python: 2,629; makefile: 10
file content (43 lines) | stat: -rwxr-xr-x 1,139 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
"""
Integration (not unit) tests for pylast.py
"""
from __future__ import annotations

from flaky import flaky

import pylast

from .test_pylast import load_secrets


@flaky(max_runs=3, min_passes=1)
class TestPyLastWithLibreFm:
    """Own class for Libre.fm because we don't need the Last.fm setUp"""

    def test_libre_fm(self) -> None:
        # Arrange
        secrets = load_secrets()
        username = secrets["username"]
        password_hash = secrets["password_hash"]

        # Act
        network = pylast.LibreFMNetwork(password_hash=password_hash, username=username)
        artist = network.get_artist("Radiohead")
        name = artist.get_name()

        # Assert
        assert name == "Radiohead"

    def test_repr(self) -> None:
        # Arrange
        secrets = load_secrets()
        username = secrets["username"]
        password_hash = secrets["password_hash"]
        network = pylast.LibreFMNetwork(password_hash=password_hash, username=username)

        # Act
        representation = repr(network)

        # Assert
        assert representation.startswith("pylast.LibreFMNetwork(")