| Total Complexity | 3 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Coverage | 50% |
| Changes | 0 | ||
| 1 | 1 | import os |
|
| 2 | 1 | import subprocess |
|
| 3 | |||
| 4 | 1 | import mock |
|
| 5 | 1 | import pytest |
|
| 6 | 1 | from click.testing import CliRunner |
|
| 7 | 1 | from music_album_creation.create_album import main |
|
| 8 | |||
| 9 | |||
| 10 | 1 | class TestCreateAlbum: |
|
| 11 | 1 | def test_executable(self): |
|
| 12 | 1 | assert subprocess.call(['create-album', '--help']) == 0 |
|
| 13 | |||
| 14 | |||
| 15 | 1 | @pytest.fixture(scope='module') |
|
| 16 | def integration_data(): |
||
| 17 | return "Music library: /media/kostas/freeagent/m\nLogo\n" |
||
| 18 | |||
| 19 | 1 | @mock.patch('music_album_creation.create_album.inout') |
|
| 20 | 1 | @mock.patch('music_album_creation.create_album.music_lib_directory') |
|
| 21 | def test_integration(mock_music_lib_directory, mock_inout, tmpdir, integration_data): |
||
| 22 | target_directory = str(tmpdir.mkdir('temp-music-library')) |
||
| 23 | runner = CliRunner() |
||
| 24 | mock_music_lib_directory.return_value = target_directory |
||
| 25 | mock_inout.input_youtube_url_dialog.return_value = 'https://www.youtube.com/watch?v=Wjrrgrvq1ew' |
||
| 26 | mock_inout.interactive_track_info_input_dialog.return_value = \ |
||
| 27 | '1. Gasoline - 0:00\n' \ |
||
| 28 | '2. Man vs. God - 0:10\n' |
||
| 29 | mock_inout.track_information_type_dialog.return_value = 'Timestamps' |
||
| 30 | mock_inout.album_directory_path_dialog.return_value = os.path.join(target_directory, 'del/Faith_in_Science') |
||
| 31 | mock_inout.interactive_metadata_dialogs.return_value = {'artist': 'del', 'album-artist': 'del', 'album': 'Faith in Science', 'year': '2019'} |
||
| 32 | |||
| 33 | result = runner.invoke(main, []) |
||
| 34 | print("CAP\n{}\nCAP".format(result.output)) |
||
| 35 | # captured = capsys.readouterr() |
||
| 36 | assert result.exit_code == 0 |
||
| 37 |