Exemple #1
0
	def test_number_starred_song(self):
		app = MusicApp(True)

		for k in range(20):
			app.add_song(Song(starred = not k % 2))

		self.assertEqual(len(app.get_starred_songs()), 10)
Exemple #2
0
	def test_add_song_free(self):
		app = MusicApp()

		for _ in range(20):
			app.add_song(Song())

		self.assertEqual(len(app.get_sorted()), 5)
Exemple #3
0
	def test_add_song_premium(self):
		app = MusicApp(True)

		for _ in range(20):
			app.add_song(Song())

		self.assertEqual(len(app.get_sorted()), 20)
Exemple #4
0
	def test_sorted_songs(self):
		app = MusicApp(True)

		for k in range(10):
			app.add_song(Song(duration = (10 - k)))

		self.assertEqual(
			[m.duration for m in app.get_sorted()],
			[k + 1 for k in range(10)]
		)
Exemple #5
0
	def test_starred_song(self):
		app = MusicApp(True)

		for k in range(5):
			app.add_song(Song())

		only_song_starred = Song(starred = True)
		app.add_song(only_song_starred)

		self.assertEqual(app.get_starred_songs()[0], only_song_starred)
Exemple #6
0
        self.__alert_to_finish = threading.Thread(target=self.__alert,
                                                  args=(song, ))
        self.__alert_to_finish.start()

        return song


class ShowInfoPlugin(MusicAppComponent):
    def __init__(self, music_app):
        self.__music_app = music_app

    def play_song(self, name):
        song = self.__music_app.play_song(name)

        if song == None:
            return None

        print(
            f"Nombre: {song.name}\nDuración: {str(song.duration)} s\nGénero: {str(song.gender)}\n"
        )


if __name__ == "__main__":
    music_app = MusicApp()
    music_app.add_song(Song(name="Tengo miedo", duration=2))

    plugin_app = ShowInfoPlugin(AlertFinishSongPlugin(music_app))

    plugin_app.play_song("Saludos")
    plugin_app.play_song("Tengo miedo")
Exemple #7
0
                            required=False,
                            help='Path to playlist file')
        self.args = parser.parse_args()

    def run(self):
        paths = []

        if self.args.playlist:
            copyfile(self.args.playlist, "playlist.txt")
            return

        if len(self.args.dir) == 0:
            return

        for path in self.args.dir:
            filesindir = [
                path + "/" + f for f in listdir(path)
                if isfile(join(path, f)) and f.endswith(('.mp3', 'wav'))
            ]
            paths.extend(filesindir)

        with open("playlist.txt", "w+") as file:
            for path in paths:
                file.write(path + "\n")


if __name__ == '__main__':
    s = Stuff()
    s.run()
    MusicApp().run()
Exemple #8
0
	def test_use_dark_mode_free(self):
		app = MusicApp()
		app.use_dark_mode(True)

		self.assertFalse(app.is_dark_mode_activated())
Exemple #9
0
	def test_use_dark_mode_premium(self):
		app = MusicApp(True)
		app.use_dark_mode(True)

		self.assertTrue(app.is_dark_mode_activated())