<commit_before>#!/usr/bin/env python
"""
Integration (not unit) tests for pylast.py
"""
import unittest
import warnings

import pylast

from .test_pylast import TestPyLastWithLastFm


class TestPyLastAlbum(TestPyLastWithLastFm):
    def test_album_tags_are_topitems(self):
        # Arrange
        album = self.network.get_album("Test Artist", "Test Album")

        # Act
        tags = album.get_top_tags(limit=1)

        # Assert
        self.assertGreater(len(tags), 0)
        self.assertIsInstance(tags[0], pylast.TopItem)

    def test_album_is_hashable(self):
        # Arrange
        album = self.network.get_album("Test Artist", "Test Album")

        # Act/Assert
        self.helper_is_thing_hashable(album)

    def test_album_in_recent_tracks(self):
        # Arrange
        lastfm_user = self.network.get_user(self.username)

        # Act
        # limit=2 to ignore now-playing:
        track = lastfm_user.get_recent_tracks(limit=2)[0]

        # Assert
        self.assertTrue(hasattr(track, "album"))

    def test_album_in_artist_tracks(self):
        # Arrange
        lastfm_user = self.network.get_user(self.username)

        # Act
        with warnings.catch_warnings():
            warnings.filterwarnings("ignore", category=DeprecationWarning)
            track = lastfm_user.get_artist_tracks(artist="Test Artist")[0]

        # Assert
        self.assertTrue(hasattr(track, "album"))

    def test_album_wiki_content(self):
        # Arrange
        album = pylast.Album("Test Artist", "Test Album", self.network)

        # Act
        wiki = album.get_wiki_content()

        # Assert
        self.assertIsNotNone(wiki)
        self.assertGreaterEqual(len(wiki), 1)

    def test_album_wiki_published_date(self):
        # Arrange
        album = pylast.Album("Test Artist", "Test Album", self.network)

        # Act
        wiki = album.get_wiki_published_date()

        # Assert
        self.assertIsNotNone(wiki)
        self.assertGreaterEqual(len(wiki), 1)

    def test_album_wiki_summary(self):
        # Arrange
        album = pylast.Album("Test Artist", "Test Album", self.network)

        # Act
        wiki = album.get_wiki_summary()

        # Assert
        self.assertIsNotNone(wiki)
        self.assertGreaterEqual(len(wiki), 1)

    def test_album_eq_none_is_false(self):
        # Arrange
        album1 = None
        album2 = pylast.Album("Test Artist", "Test Album", self.network)

        # Act / Assert
        self.assertNotEqual(album1, album2)

    def test_album_ne_none_is_true(self):
        # Arrange
        album1 = None
        album2 = pylast.Album("Test Artist", "Test Album", self.network)

        # Act / Assert
        self.assertNotEqual(album1, album2)

    def test_get_cover_image(self):
        # Arrange
        album = self.network.get_album("Test Artist", "Test Album")

        # Act
        image = album.get_cover_image()

        # Assert
        self.assert_startswith(image, "https://")
        self.assert_endswith(image, ".png")


if __name__ == "__main__":
    unittest.main(failfast=True)
<commit_msg>Xfail user.getArtistTracks, looks like Last.fm are now removing it from the API<commit_after>#!/usr/bin/env python
"""
Integration (not unit) tests for pylast.py
"""
import unittest
import warnings

import pytest

import pylast

from .test_pylast import TestPyLastWithLastFm


class TestPyLastAlbum(TestPyLastWithLastFm):
    def test_album_tags_are_topitems(self):
        # Arrange
        album = self.network.get_album("Test Artist", "Test Album")

        # Act
        tags = album.get_top_tags(limit=1)

        # Assert
        self.assertGreater(len(tags), 0)
        self.assertIsInstance(tags[0], pylast.TopItem)

    def test_album_is_hashable(self):
        # Arrange
        album = self.network.get_album("Test Artist", "Test Album")

        # Act/Assert
        self.helper_is_thing_hashable(album)

    def test_album_in_recent_tracks(self):
        # Arrange
        lastfm_user = self.network.get_user(self.username)

        # Act
        # limit=2 to ignore now-playing:
        track = lastfm_user.get_recent_tracks(limit=2)[0]

        # Assert
        self.assertTrue(hasattr(track, "album"))

    @pytest.mark.skip(reason="Last.fm is removing from API")
    def test_album_in_artist_tracks(self):
        # Arrange
        lastfm_user = self.network.get_user(self.username)

        # Act
        with warnings.catch_warnings():
            warnings.filterwarnings("ignore", category=DeprecationWarning)
            track = lastfm_user.get_artist_tracks(artist="Test Artist")[0]

        # Assert
        self.assertTrue(hasattr(track, "album"))

    def test_album_wiki_content(self):
        # Arrange
        album = pylast.Album("Test Artist", "Test Album", self.network)

        # Act
        wiki = album.get_wiki_content()

        # Assert
        self.assertIsNotNone(wiki)
        self.assertGreaterEqual(len(wiki), 1)

    def test_album_wiki_published_date(self):
        # Arrange
        album = pylast.Album("Test Artist", "Test Album", self.network)

        # Act
        wiki = album.get_wiki_published_date()

        # Assert
        self.assertIsNotNone(wiki)
        self.assertGreaterEqual(len(wiki), 1)

    def test_album_wiki_summary(self):
        # Arrange
        album = pylast.Album("Test Artist", "Test Album", self.network)

        # Act
        wiki = album.get_wiki_summary()

        # Assert
        self.assertIsNotNone(wiki)
        self.assertGreaterEqual(len(wiki), 1)

    def test_album_eq_none_is_false(self):
        # Arrange
        album1 = None
        album2 = pylast.Album("Test Artist", "Test Album", self.network)

        # Act / Assert
        self.assertNotEqual(album1, album2)

    def test_album_ne_none_is_true(self):
        # Arrange
        album1 = None
        album2 = pylast.Album("Test Artist", "Test Album", self.network)

        # Act / Assert
        self.assertNotEqual(album1, album2)

    def test_get_cover_image(self):
        # Arrange
        album = self.network.get_album("Test Artist", "Test Album")

        # Act
        image = album.get_cover_image()

        # Assert
        self.assert_startswith(image, "https://")
        self.assert_endswith(image, ".png")


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

{'fraction_non_alphanumeric': 0.10416666666666667, 'fraction_numerical': 0.005681818181818182, 'mean_word_length': 2.5303621169916433, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1262688', 'n_tokens_mistral': 2053, 'n_tokens_neox': 1948, 'n_words': 368}