<commit_before>import datetime as dt
import unittest

from mopidy.models import Artist, Album, Track, Playlist

class ArtistTest(unittest.TestCase):
    def test_uri(self):
        uri = u'an_uri'
        artist = Artist(uri=uri)
        self.assertEqual(artist.uri, uri)
        self.assertRaises(AttributeError, setattr, artist, 'uri', None)

    def test_name(self):
        name = u'a name'
        artist = Artist(name=name)
        self.assertEqual(artist.name, name)
        self.assertRaises(AttributeError, setattr, artist, 'name', None)

    def test_eq_name(self):
        artist1 = Artist(name=u'name')
        artist2 = Artist(name=u'name')
        self.assertEqual(artist1, artist2) 
        self.assertEqual(hash(artist1), hash(artist2)) 

    def test_eq_uri(self):
        artist1 = Artist(uri=u'uri')
        artist2 = Artist(uri=u'uri')
        self.assertEqual(artist1, artist2) 
        self.assertEqual(hash(artist1), hash(artist2)) 

    def test_eq(self):
        artist1 = Artist(uri=u'uri', name=u'name')
        artist2 = Artist(uri=u'uri', name=u'name')
        self.assertEqual(artist1, artist2) 
        self.assertEqual(hash(artist1), hash(artist2)) 

    def test_eq_none(self):
        self.assertNotEqual(Artist(), None)

    def test_eq_other(self):
        self.assertNotEqual(Artist(), 'other')

    def test_ne_name(self):
        artist1 = Artist(name=u'name1')
        artist2 = Artist(name=u'name2')
        self.assertNotEqual(artist1, artist2) 
        self.assertNotEqual(hash(artist1), hash(artist2)) 

    def test_ne_uri(self):
        artist1 = Artist(uri=u'uri1')
        artist2 = Artist(uri=u'uri2')
        self.assertNotEqual(artist1, artist2) 
        self.assertNotEqual(hash(artist1), hash(artist2)) 

    def test_ne(self):
        artist1 = Artist(uri=u'uri1', name=u'name1')
        artist2 = Artist(uri=u'uri2', name=u'name2')
        self.assertNotEqual(artist1, artist2) 
        self.assertNotEqual(hash(artist1), hash(artist2)) 


class AlbumTest(unittest.TestCase):
    def test_uri(self):
        uri = u'an_uri'
        album = Album(uri=uri)
        self.assertEqual(album.uri, uri)
        self.assertRaises(AttributeError, setattr, album, 'uri', None)

    def test_name(self):
        name = u'a name'
        album = Album(name=name)
        self.assertEqual(album.name, name)
        self.assertRaises(AttributeError, setattr, album, 'name', None)

    def test_artists(self):
        artists = [Artist()]
        album = Album(artists=artists)
        self.assertEqual(album.artists, artists)
        self.assertRaises(AttributeError, setattr, album, 'artists', None)

    def test_num_tracks(self):
        num_tracks = 11
        album = Album(num_tracks=11)
        self.assertEqual(album.num_tracks, num_tracks)
        self.assertRaises(AttributeError, setattr, album, 'num_tracks', None)

    def test_eq_name(self):
        album1 = Album(name=u'name')
        album2 = Album(name=u'name')
        self.assertEqual(album1, album2) 
        self.assertEqual(hash(album1), hash(album2))

    def test_eq_uri(self):
        album1 = Album(uri=u'uri')
        album2 = Album(uri=u'uri')
        self.assertEqual(album1, album2) 
        self.assertEqual(hash(album1), hash(album2))

    def test_eq_artists(self):
        artists = [Artist()]
        album1 = Album(artists=artists)
        album2 = Album(artists=artists)
        self.assertEqual(album1, album2) 
        self.assertEqual(hash(album1), hash(album2))

    def test_eq_artists_order(self):
        artist1 = Artist(name=u'name1')
        artist2 = Artist(name=u'name2')
        album1 = Album(artists=[artist1, artist2])
        album2 = Album(artists=[artist2, artist1])
        self.assertEqual(album1, album2) 
        self.assertEqual(hash(album1), hash(album2))

    def test_eq_num_tracks(self):
        album1 = Album(num_tracks=2)
        album2 = Album(num_tracks=2)
        self.assertEqual(album1, album2) 
        self.assertEqual(hash(album1), hash(album2))

    def test_eq(self):
        artists = [Artist()]
        album1 = Album(name=u'name', uri=u'uri', artists=artists, num_tracks=2)
        album2 = Album(name=u'name', uri=u'uri', artists=artists, num_tracks=2)
        self.assertEqual(album1, album2) 
        self.assertEqual(hash(album1), hash(album2))

    def test_eq_none(self):
        self.assertNotEqual(Album(), None)

    def test_eq_other(self):
        self.assertNotEqual(Album(), 'other')

    def test_ne_name(self):
        album1 = Album(name=u'name1')
        album2 = Album(name=u'name2')
        self.assertNotEqual(album1, album2) 
        self.assertNotEqual(hash(album1), hash(album2))

    def test_ne_uri(self):
        album1 = Album(uri=u'uri1')
        album2 = Album(uri=u'uri2')
        self.assertNotEqual(album1, album2) 
        self.assertNotEqual(hash(album1), hash(album2))

    def test_ne_artists(self):
        album1 = Album(artists=[Artist(name=u'name1')])
        album2 = Album(artists=[Artist(name=u'name2')])
        self.assertNotEqual(album1, album2) 
        self.assertNotEqual(hash(album1), hash(album2))

    def test_ne_num_tracks(self):
        album1 = Album(num_tracks=1)
        album2 = Album(num_tracks=2)
        self.assertNotEqual(album1, album2) 
        self.assertNotEqual(hash(album1), hash(album2))

    def test_ne(self):
        album1 = Album(name=u'name1', uri=u'uri1', artists=[Artist(name=u'name1')], num_tracks=1)
        album2 = Album(name=u'name2', uri=u'uri2', artists=[Artist(name=u'name2')], num_tracks=2)
        self.assertNotEqual(album1, album2) 
        self.assertNotEqual(hash(album1), hash(album2))


class TrackTest(unittest.TestCase):
    def test_uri(self):
        uri = u'an_uri'
        track = Track(uri=uri)
        self.assertEqual(track.uri, uri)
        self.assertRaises(AttributeError, setattr, track, 'uri', None)

    def test_name(self):
        name = u'a name'
        track = Track(name=name)
        self.assertEqual(track.name, name)
        self.assertRaises(AttributeError, setattr, track, 'name', None)

    def test_artists(self):
        artists = [Artist(), Artist()]
        track = Track(artists=artists)
        self.assertEqual(track.artists, artists)
        self.assertRaises(AttributeError, setattr, track, 'artists', None)

    def test_album(self):
        album = Album()
        track = Track(album=album)
        self.assertEqual(track.album, album)<commit_msg>Fix test_artists test with respect to hashing and set behaveviour<commit_after>import datetime as dt
import unittest

from mopidy.models import Artist, Album, Track, Playlist

class ArtistTest(unittest.TestCase):
    def test_uri(self):
        uri = u'an_uri'
        artist = Artist(uri=uri)
        self.assertEqual(artist.uri, uri)
        self.assertRaises(AttributeError, setattr, artist, 'uri', None)

    def test_name(self):
        name = u'a name'
        artist = Artist(name=name)
        self.assertEqual(artist.name, name)
        self.assertRaises(AttributeError, setattr, artist, 'name', None)

    def test_eq_name(self):
        artist1 = Artist(name=u'name')
        artist2 = Artist(name=u'name')
        self.assertEqual(artist1, artist2) 
        self.assertEqual(hash(artist1), hash(artist2)) 

    def test_eq_uri(self):
        artist1 = Artist(uri=u'uri')
        artist2 = Artist(uri=u'uri')
        self.assertEqual(artist1, artist2) 
        self.assertEqual(hash(artist1), hash(artist2)) 

    def test_eq(self):
        artist1 = Artist(uri=u'uri', name=u'name')
        artist2 = Artist(uri=u'uri', name=u'name')
        self.assertEqual(artist1, artist2) 
        self.assertEqual(hash(artist1), hash(artist2)) 

    def test_eq_none(self):
        self.assertNotEqual(Artist(), None)

    def test_eq_other(self):
        self.assertNotEqual(Artist(), 'other')

    def test_ne_name(self):
        artist1 = Artist(name=u'name1')
        artist2 = Artist(name=u'name2')
        self.assertNotEqual(artist1, artist2) 
        self.assertNotEqual(hash(artist1), hash(artist2)) 

    def test_ne_uri(self):
        artist1 = Artist(uri=u'uri1')
        artist2 = Artist(uri=u'uri2')
        self.assertNotEqual(artist1, artist2) 
        self.assertNotEqual(hash(artist1), hash(artist2)) 

    def test_ne(self):
        artist1 = Artist(uri=u'uri1', name=u'name1')
        artist2 = Artist(uri=u'uri2', name=u'name2')
        self.assertNotEqual(artist1, artist2) 
        self.assertNotEqual(hash(artist1), hash(artist2)) 


class AlbumTest(unittest.TestCase):
    def test_uri(self):
        uri = u'an_uri'
        album = Album(uri=uri)
        self.assertEqual(album.uri, uri)
        self.assertRaises(AttributeError, setattr, album, 'uri', None)

    def test_name(self):
        name = u'a name'
        album = Album(name=name)
        self.assertEqual(album.name, name)
        self.assertRaises(AttributeError, setattr, album, 'name', None)

    def test_artists(self):
        artists = [Artist()]
        album = Album(artists=artists)
        self.assertEqual(album.artists, artists)
        self.assertRaises(AttributeError, setattr, album, 'artists', None)

    def test_num_tracks(self):
        num_tracks = 11
        album = Album(num_tracks=11)
        self.assertEqual(album.num_tracks, num_tracks)
        self.assertRaises(AttributeError, setattr, album, 'num_tracks', None)

    def test_eq_name(self):
        album1 = Album(name=u'name')
        album2 = Album(name=u'name')
        self.assertEqual(album1, album2) 
        self.assertEqual(hash(album1), hash(album2))

    def test_eq_uri(self):
        album1 = Album(uri=u'uri')
        album2 = Album(uri=u'uri')
        self.assertEqual(album1, album2) 
        self.assertEqual(hash(album1), hash(album2))

    def test_eq_artists(self):
        artists = [Artist()]
        album1 = Album(artists=artists)
        album2 = Album(artists=artists)
        self.assertEqual(album1, album2) 
        self.assertEqual(hash(album1), hash(album2))

    def test_eq_artists_order(self):
        artist1 = Artist(name=u'name1')
        artist2 = Artist(name=u'name2')
        album1 = Album(artists=[artist1, artist2])
        album2 = Album(artists=[artist2, artist1])
        self.assertEqual(album1, album2) 
        self.assertEqual(hash(album1), hash(album2))

    def test_eq_num_tracks(self):
        album1 = Album(num_tracks=2)
        album2 = Album(num_tracks=2)
        self.assertEqual(album1, album2) 
        self.assertEqual(hash(album1), hash(album2))

    def test_eq(self):
        artists = [Artist()]
        album1 = Album(name=u'name', uri=u'uri', artists=artists, num_tracks=2)
        album2 = Album(name=u'name', uri=u'uri', artists=artists, num_tracks=2)
        self.assertEqual(album1, album2) 
        self.assertEqual(hash(album1), hash(album2))

    def test_eq_none(self):
        self.assertNotEqual(Album(), None)

    def test_eq_other(self):
        self.assertNotEqual(Album(), 'other')

    def test_ne_name(self):
        album1 = Album(name=u'name1')
        album2 = Album(name=u'name2')
        self.assertNotEqual(album1, album2) 
        self.assertNotEqual(hash(album1), hash(album2))

    def test_ne_uri(self):
        album1 = Album(uri=u'uri1')
        album2 = Album(uri=u'uri2')
        self.assertNotEqual(album1, album2) 
        self.assertNotEqual(hash(album1), hash(album2))

    def test_ne_artists(self):
        album1 = Album(artists=[Artist(name=u'name1')])
        album2 = Album(artists=[Artist(name=u'name2')])
        self.assertNotEqual(album1, album2) 
        self.assertNotEqual(hash(album1), hash(album2))

    def test_ne_num_tracks(self):
        album1 = Album(num_tracks=1)
        album2 = Album(num_tracks=2)
        self.assertNotEqual(album1, album2) 
        self.assertNotEqual(hash(album1), hash(album2))

    def test_ne(self):
        album1 = Album(name=u'name1', uri=u'uri1', artists=[Artist(name=u'name1')], num_tracks=1)
        album2 = Album(name=u'name2', uri=u'uri2', artists=[Artist(name=u'name2')], num_tracks=2)
        self.assertNotEqual(album1, album2) 
        self.assertNotEqual(hash(album1), hash(album2))


class TrackTest(unittest.TestCase):
    def test_uri(self):
        uri = u'an_uri'
        track = Track(uri=uri)
        self.assertEqual(track.uri, uri)
        self.assertRaises(AttributeError, setattr, track, 'uri', None)

    def test_name(self):
        name = u'a name'
        track = Track(name=name)
        self.assertEqual(track.name, name)
        self.assertRaises(AttributeError, setattr, track, 'name', None)

    def test_artists(self):
        artists = [Artist(name=u'name1'), Artist(name=u'name2')]
        track = Track(artists=artists)
        self.assertEqual(set(track.artists), set(artists))
        self.assertRaises(AttributeError, setattr, track, 'artists', None)

    def test_album(self):
        album = Album()
        track = Track(album=album)
        self.assertEqual(track.album, album)
{'fraction_non_alphanumeric': 0.12973222530009235, 'fraction_numerical': 0.02200677131425054, 'mean_word_length': 3.0768506900878294, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '6572370', 'n_tokens_mistral': 4422, 'n_tokens_neox': 4319, 'n_words': 728}