File: test_tag.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 (62 lines) | stat: -rwxr-xr-x 1,543 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python
"""
Integration (not unit) tests for pylast.py
"""
import unittest

import pylast

from .test_pylast import TestPyLastWithLastFm


class TestPyLastTag(TestPyLastWithLastFm):
    def test_tag_is_hashable(self):
        # Arrange
        tag = self.network.get_top_tags(limit=1)[0]

        # Act/Assert
        self.helper_is_thing_hashable(tag)

    def test_tag_top_artists(self):
        # Arrange
        tag = self.network.get_tag("blues")

        # Act
        artists = tag.get_top_artists(limit=1)

        # Assert
        self.helper_only_one_thing_in_top_list(artists, pylast.Artist)

    def test_tag_top_albums(self):
        # Arrange
        tag = self.network.get_tag("blues")

        # Act
        albums = tag.get_top_albums(limit=1)

        # Assert
        self.helper_only_one_thing_in_top_list(albums, pylast.Album)

    def test_tags(self):
        # Arrange
        tag1 = self.network.get_tag("blues")
        tag2 = self.network.get_tag("rock")

        # Act
        tag_repr = repr(tag1)
        tag_str = str(tag1)
        name = tag1.get_name(properly_capitalized=True)
        url = tag1.get_url()

        # Assert
        self.assertEqual("blues", tag_str)
        self.assertIn("pylast.Tag", tag_repr)
        self.assertIn("blues", tag_repr)
        self.assertEqual("blues", name)
        self.assertEqual(tag1, tag1)
        self.assertNotEqual(tag1, tag2)
        self.assertEqual(url, "https://www.last.fm/tag/blues")


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