File: test_librefm.py

package info (click to toggle)
pylast 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 296 kB
  • sloc: python: 2,564; makefile: 10
file content (47 lines) | stat: -rwxr-xr-x 1,213 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
44
45
46
47
#!/usr/bin/env python
"""
Integration (not unit) tests for pylast.py
"""
import unittest

from flaky import flaky

import pylast

from .test_pylast import PyLastTestCase, load_secrets


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

    def test_libre_fm(self):
        # 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
        self.assertEqual(name, "Radiohead")

    def test_repr(self):
        # 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
        self.assert_startswith(representation, "pylast.LibreFMNetwork(")


if __name__ == "__main__":
    unittest.main(failfast=True)