def setUp(self): db.init_database("sqlite:") with db_session: root = db.Folder(root=True, name="Folder", path="tests") artist = db.Artist(name="Artist") album = db.Album(artist=artist, name="Album") for i in range(3): db.Track( title="Track {}".format(i), album=album, artist=artist, disc=1, number=i + 1, duration=3, has_art=False, bitrate=64, path="tests/track{}".format(i), last_modification=2, root_folder=root, folder=root, genre="Genre", ) db.User(name="user", password="******", salt="sugar")
def test_user(self): user = db.User() user.name = u'Test User' user.password = u'secret' user.salt = u'ABC+' user_dict = user.as_subsonic_user() self.assertIsInstance(user_dict, dict)
def create_playlist(self): user = db.User() user.name = u'Test User' user.password = u'secret' user.salt = u'ABC+' playlist = db.Playlist() playlist.user = user playlist.name = u'Playlist!' self.store.add(playlist) return playlist
def test_chat(self): user = db.User() user.name = u'Test User' user.password = u'secret' user.salt = u'ABC+' line = db.ChatMessage() line.user = user line.message = u'Hello world!' line_dict = line.responsize() self.assertIsInstance(line_dict, dict) self.assertIn(u'username', line_dict) self.assertEqual(line_dict[u'username'], user.name)
def create_user(self, name="Test User"): return db.User(name=name, password="******", salt="ABC+")