Esempio n. 1
0
def test_write_file(test_folder, config, monkeypatch):
    def mockreturn(path):
        return open(os.path.join(os.path.dirname(__file__), 'testfile.mp3'), 'r')
    import capturadio
    monkeypatch.setattr(capturadio, 'urlopen', mockreturn)

    recorder = Recorder()
    recorder.start_time = time.time()

    folder = test_folder.mkdir('casts')
    file_name = os.path.join(str(folder), 'output.mp3')
    stream_url = 'http://example.org/stream.mp3'
    recorder._write_stream_to_file(stream_url, file_name, 2)
    assert os.path.exists(file_name)
Esempio n. 2
0
def test_write_file(test_folder, config, monkeypatch):
    def mockreturn(path):
        filename = os.path.join(os.path.dirname(__file__), 'testfile.mp3')
        return open(filename, 'rb')
    import capturadio
    monkeypatch.setattr(capturadio, 'urlopen', mockreturn)

    folder = test_folder.mkdir('casts')
    show = config.shows['weather']
    episode = capturadio.Episode(config, show)
    episode.filename = os.path.join(str(folder), 'output.mp3')
    episode.duration = 3

    recorder = Recorder()
    recorder._write_stream_to_file(episode)
    assert os.path.exists(episode.filename)
Esempio n. 3
0
def test_write_file(test_folder, config, monkeypatch):
    def mockreturn(path):
        return open(os.path.join(os.path.dirname(__file__), 'testfile.mp3'),
                    'r')

    import capturadio
    monkeypatch.setattr(capturadio, 'urlopen', mockreturn)

    recorder = Recorder()
    recorder.start_time = time.time()

    folder = test_folder.mkdir('casts')
    file_name = os.path.join(str(folder), 'output.mp3')
    stream_url = 'http://example.org/stream.mp3'
    recorder._write_stream_to_file(stream_url, file_name, 2)
    assert os.path.exists(file_name)
Esempio n. 4
0
def test_write_file(test_folder, config, monkeypatch):
    def mockreturn(path):
        filename = os.path.join(os.path.dirname(__file__), 'testfile.mp3')
        return open(filename, 'rb')
    import capturadio.recorder
    monkeypatch.setattr(capturadio.recorder, 'urlopen', mockreturn)

    folder = test_folder.mkdir('casts')
    show = config.shows['weather']
    episode = capturadio.Episode(config, show)
    episode.filename = os.path.join(str(folder), 'output.mp3')
    episode.duration = 3

    recorder = Recorder()
    recorder._write_stream_to_file(episode)
    assert os.path.exists(episode.filename)
Esempio n. 5
0
def test_change_destination(test_folder):
    config = Configuration(reset=True, folder=str(test_folder))
    new_folder = str(test_folder.mkdir('destination'))
    config.set_destination(new_folder)
    assert config.destination == new_folder
Esempio n. 6
0
def test_change_destination(test_folder):
    config = Configuration(reset=True, folder=str(test_folder))
    new_folder = str(test_folder.mkdir('destination'))
    config.set_destination(new_folder)
    assert config.destination == new_folder