import os
import pytest
from utils.input_output import get_spectra_per_acc_from_yaml

pg_yaml = 'tests/unit_tests/read_spectra_from_yaml/proteome_discoverer_example.yaml'
pd_result = {'BPBMOCPF_00058': {''},
             'LPLDNAKH_00307': {'ms_run14:scan=21060', 'ms_run4:scan=21755', 'ms_run24:scan=21676'},
             'LPLDNAKH_06997': {''},
             'BPBMOCPF_00062': {'ms_run20:scan=30174', 'ms_run20:scan=16709', 'ms_run7:scan=28288', 'ms_run24:scan=29222',
                                'ms_run11:scan=28665', 'ms_run20:scan=30146', 'ms_run21:scan=7777', 'ms_run19:scan=29573',
                                'ms_run24:scan=7969', 'ms_run5:scan=28896', 'ms_run13:scan=28348', 'ms_run19:scan=7538',
                                'ms_run1:scan=8188', 'ms_run8:scan=28186', 'ms_run15:scan=7808', 'ms_run24:scan=29304',
                                'ms_run9:scan=29069', 'ms_run18:scan=36381', 'ms_run2:scan=28770', 'ms_run17:scan=29917'},
             'BPBMOCPF_00095': {'ms_run22:scan=8340', 'ms_run13:scan=8404', 'ms_run18:scan=8437', 'ms_run5:scan=8507',
                                'ms_run16:scan=7676', 'ms_run7:scan=8035'},
             'BPBMOCPF_00143': {'ms_run2:scan=14021', 'ms_run12:scan=9866', 'ms_run3:scan=9361', 'ms_run11:scan=13732',
                                'ms_run11:scan=4519', 'ms_run1:scan=4456', 'ms_run20:scan=12813', 'ms_run5:scan=29225',
                                'ms_run20:scan=11522', 'ms_run2:scan=10033', 'ms_run23:scan=11053', 'ms_run6:scan=9764',
                                'ms_run22:scan=9649', 'ms_run2:scan=4771', 'ms_run9:scan=9703', 'ms_run17:scan=11162',
                                'ms_run1:scan=13503', 'ms_run15:scan=8773'}}
@pytest.mark.parametrize("pg_yaml", [pg_yaml])
def test_spectra_from_yaml(pg_yaml):
    accs_to_spectra_dict = get_spectra_per_acc_from_yaml(pg_yaml)
    assert pd_result == accs_to_spectra_dict