def test_getPlaylistFileNotFoundMock(self): inputType = InputDataFile() directoryPath = "missing file" logger = IOTest() InputDataFile.getRawData = MagicMock(side_effect=FileNotFoundError) playlist = getPlaylist(inputType, directoryPath, logger) self.assertEqual("stub_bensound-dubstep.wav", playlist[0])
def test_inputDataFile(self): inputType = InputDataFile() logger = IOTest() directoryPath = "../../Music/" playlist = getPlaylist(inputType, directoryPath, logger) self.assertEqual("Beat Of Success.mp3", playlist[0])
def test_getPlaylistFileNotFoundMockOutput(self): inputType = InputDataFile() directoryPath = "missing file" logger = IOTest() InputDataFile.getRawData = MagicMock(side_effect=FileNotFoundError) playlist = getPlaylist(inputType, directoryPath, logger) self.assertEqual("Error. Directory was not found. Switching to stub.", logger.getOutputList()[-1])
def main(directoryPath="Music/", logger=IOLogger(True)): soundPlayer = "" volume = 1.0 close = False if type(logger) == IOLogger: initialiseLogs() musicFiles = getPlaylist(InputDataFile(), directoryPath, logger) while True: soundPlayer, volume, close = enterCommand(soundPlayer, musicFiles, directoryPath, volume, close, logger) if close: break
def main(directoryPath="Music/", logger=IOLogger(True)): soundPlayer = "" volume = 1.0 close = False musicFiles = getPlaylist(InputDataFile(), directoryPath, logger) if type(logger) == IOLogger: logger.initialiseLogs() while not close: print() displayCommands(logger) command = getUserCommand("Please enter a command", logger) # handle command # stop if command in Commands.STOP.value: stopSound(soundPlayer, logger) # play elif command in Commands.PLAY.value: displayFiles(musicFiles, logger) songName = getFileToPlay(musicFiles, logger) filePath = directoryPath + songName soundPlayer = playSound(filePath, volume, logger) # volume control elif command in Commands.VOLUME.value: volume = getVolume(logger) setVolume(volume, soundPlayer) # pause elif command in Commands.PAUSE.value: playPause(logger) # unpause elif command in Commands.UNPAUSE.value: unPause(logger) # close program elif command in Commands.CLOSE.value: close = True else: logger.showOutput("That is not a valid user command") logger.showOutput("Closing program")
def test_InputDataFile(self): inputType = InputDataFile() logger = IOTest() playlist = getPlaylist(inputType, "../Music", logger) self.assertEqual("Beat Of Success.mp3", playlist[0])