|  | 
|  | 1 | +from datetime import date | 
|  | 2 | +from pathlib import Path | 
|  | 3 | + | 
|  | 4 | +import pytest | 
|  | 5 | + | 
|  | 6 | +from fundamend.reader import AhbReader, MigReader | 
|  | 7 | + | 
|  | 8 | +data_path: Path = Path(__file__).parent.parent / "xml-migs-and-ahbs" | 
|  | 9 | + | 
|  | 10 | + | 
|  | 11 | +@pytest.mark.parametrize( | 
|  | 12 | +    "ahb_xml_file_path, expected_date", | 
|  | 13 | +    [ | 
|  | 14 | +        pytest.param( | 
|  | 15 | +            data_path / "APERAK" / "APERAK_AHB_2_3n_ausserordentliche_2024_07_26_2024_04_03.xml", | 
|  | 16 | +            date(2024, 7, 26), | 
|  | 17 | +        ), | 
|  | 18 | +        pytest.param( | 
|  | 19 | +            data_path / "COMDIS" / "COMDIS_AHB_1_0e_2023_10_24_2024_04_03.xml", | 
|  | 20 | +            date(2023, 10, 24), | 
|  | 21 | +        ), | 
|  | 22 | +        pytest.param( | 
|  | 23 | +            data_path / "COMDIS" / "COMDIS_AHB_1_0f_2024_06_19_2024_11_20.xml", | 
|  | 24 | +            date(2024, 6, 19), | 
|  | 25 | +        ), | 
|  | 26 | +        pytest.param( | 
|  | 27 | +            data_path / "CONTRL" / "CONTRL_AHB_2_3n_ausserordentliche_2024_07_26_2024_04_03.xml", | 
|  | 28 | +            date(2024, 7, 26), | 
|  | 29 | +        ), | 
|  | 30 | +        pytest.param( | 
|  | 31 | +            data_path / "IFTSTA" / "IFTSTA_AHB_2_0e_ausserordentliche_2024_07_26_2024_03_11.xml", | 
|  | 32 | +            date(2024, 7, 26), | 
|  | 33 | +        ), | 
|  | 34 | +        pytest.param( | 
|  | 35 | +            data_path / "INSRPT" / "INSRPT_AHB_1_1g_ausserordentliche_2024_07_26_2023_03_23.xml", | 
|  | 36 | +            date(2024, 7, 26), | 
|  | 37 | +        ), | 
|  | 38 | +        pytest.param( | 
|  | 39 | +            data_path / "INVOIC" / "INVOIC_AHB_2_5c_Fehlerkorrektur_2024_06_17_2024_06_17.xml", | 
|  | 40 | +            date(2024, 6, 17), | 
|  | 41 | +        ), | 
|  | 42 | +        pytest.param( | 
|  | 43 | +            data_path / "MSCONS" / "MSCONS_AHB_3_1d_ausserordentliche_2024_07_26_2024_04_03.xml", | 
|  | 44 | +            date(2024, 7, 26), | 
|  | 45 | +        ), | 
|  | 46 | +        pytest.param( | 
|  | 47 | +            data_path / "ORDCHG" / "ORDCHG_AHB_2_2_Fehlerkorrektur_2024_09_23_2024_09_23.xml", | 
|  | 48 | +            date(2024, 9, 23), | 
|  | 49 | +        ), | 
|  | 50 | +        pytest.param( | 
|  | 51 | +            data_path / "ORDRSP" / "ORDRSP_AHB_2_2_Fehlerkorrektur_2024_09_23_2024_09_23.xml", | 
|  | 52 | +            date(2024, 9, 23), | 
|  | 53 | +        ), | 
|  | 54 | +        pytest.param( | 
|  | 55 | +            data_path / "PARTIN" / "PARTIN_AHB_1_0d_Fehlerkorrektur_2024_03_10_2024_04_03.xml", | 
|  | 56 | +            date(2024, 7, 26), | 
|  | 57 | +        ), | 
|  | 58 | +        pytest.param( | 
|  | 59 | +            data_path / "PRICAT" / "PRICAT_AHB_2_0d_ausserordentliche_2024_07_26_2024_04_03.xml", | 
|  | 60 | +            date(2024, 7, 26), | 
|  | 61 | +        ), | 
|  | 62 | +        pytest.param( | 
|  | 63 | +            data_path / "REMADV" / "REMADV_AHB_2_5c_Fehlerkorrektur_2024_06_17_2024_06_17.xml", | 
|  | 64 | +            date(2024, 6, 17), | 
|  | 65 | +        ), | 
|  | 66 | +        pytest.param( | 
|  | 67 | +            data_path / "REQOTE" / "REQOTE_AHB_2_2_Fehlerkorrektur_2024_09_23_2024_09_23.xml", | 
|  | 68 | +            date(2024, 9, 23), | 
|  | 69 | +        ), | 
|  | 70 | +        pytest.param( | 
|  | 71 | +            data_path / "UTILMD" / "UTILMD_AHB_Gas_1_0_ausserordentliche_2024_07_26_2023_12_12.xml", | 
|  | 72 | +            date(2024, 7, 26), | 
|  | 73 | +        ), | 
|  | 74 | +        pytest.param( | 
|  | 75 | +            data_path / "UTILMD" / "UTILMD_AHB_Strom_1_2a_Fehlerkorrektur_2024_10_18_2024_10_18.xml", | 
|  | 76 | +            date(2024, 10, 18), | 
|  | 77 | +        ), | 
|  | 78 | +        pytest.param( | 
|  | 79 | +            data_path / "UTILMD" / "UTILMD_AHB_Strom_2_1_2024_10_01_2024_09_20.xml", | 
|  | 80 | +            date(2024, 10, 1), | 
|  | 81 | +        ), | 
|  | 82 | +        pytest.param( | 
|  | 83 | +            data_path / "UTILTS" / "UTILTS_AHB_1_0f_ausserordentliche_2024_07_26_2024_04_03.xml", | 
|  | 84 | +            date(2024, 7, 26), | 
|  | 85 | +        ), | 
|  | 86 | +        pytest.param( | 
|  | 87 | +            data_path / "UTILTS" / "UTILTS_AHB_1_1c_Lesefassung_2023_12_12_2023_12_12.xml", | 
|  | 88 | +            date(2023, 10, 24), | 
|  | 89 | +        ), | 
|  | 90 | +        pytest.param( | 
|  | 91 | +            data_path / "UTILTS" / "UTILTS_AHB_1_1d_Konsultationsfassung_2024_04_02_2024_04_02.xml", | 
|  | 92 | +            date(2024, 4, 2), | 
|  | 93 | +        ), | 
|  | 94 | +    ], | 
|  | 95 | +) | 
|  | 96 | +def test_read_ahb_xml(ahb_xml_file_path: Path, expected_date: date) -> None: | 
|  | 97 | +    reader = AhbReader(ahb_xml_file_path) | 
|  | 98 | +    actual = reader.get_publishing_date() | 
|  | 99 | +    assert actual == expected_date | 
|  | 100 | + | 
|  | 101 | + | 
|  | 102 | +@pytest.mark.parametrize( | 
|  | 103 | +    "mig_xml_file_path, expected_date", | 
|  | 104 | +    [ | 
|  | 105 | +        pytest.param( | 
|  | 106 | +            data_path / "APERAK" / "APERAK_MIG_2_1h_ausserordentliche_2024_07_26_2022_10_01.xml", | 
|  | 107 | +            date(2024, 7, 26), | 
|  | 108 | +        ), | 
|  | 109 | +        pytest.param( | 
|  | 110 | +            data_path / "CONTRL" / "CONTRL_MIG_2_0b_ausserordentliche_2024_07_26_2022_10_01.xml", | 
|  | 111 | +            date(2024, 7, 26), | 
|  | 112 | +        ), | 
|  | 113 | +        pytest.param( | 
|  | 114 | +            data_path / "IFTSTA" / "IFTSTA_MIG_2_0e_auserordentliche_2024_07_26_2024_03_11.xml", | 
|  | 115 | +            date(2024, 7, 26), | 
|  | 116 | +        ), | 
|  | 117 | +        pytest.param( | 
|  | 118 | +            data_path / "INSRPT" / "INSRPT_MIG_1_1a_ausserordentliche_2024_07_26_2023_03_23.xml", | 
|  | 119 | +            date(2024, 7, 26), | 
|  | 120 | +        ), | 
|  | 121 | +        pytest.param( | 
|  | 122 | +            data_path / "INVOIC" / "INVOIC_MIG_2_8c_ausserordentliche_2024_07_26_2024_04_03.xml", | 
|  | 123 | +            date(2024, 7, 26), | 
|  | 124 | +        ), | 
|  | 125 | +        pytest.param( | 
|  | 126 | +            data_path / "MSCONS" / "MSCONS_MIG_2_4c_ausserordentliche_2024_07_26_2024_04_03.xml", | 
|  | 127 | +            date(2024, 7, 26), | 
|  | 128 | +        ), | 
|  | 129 | +        pytest.param( | 
|  | 130 | +            data_path / "ORDCHG" / "ORDCHG_MIG_1_1_ausserordentliche_2024_07_26_2023_10_01.xml", | 
|  | 131 | +            date(2024, 7, 26), | 
|  | 132 | +        ), | 
|  | 133 | +        pytest.param( | 
|  | 134 | +            data_path / "ORDERS" / "ORDERS_MIG_1_3_ausserordentliche_2024_07_26_2023_10_01.xml", | 
|  | 135 | +            date(2024, 7, 26), | 
|  | 136 | +        ), | 
|  | 137 | +        pytest.param( | 
|  | 138 | +            data_path / "ORDRSP" / "ORDRSP_MIG_1_3_ausserordentliche_2024_07_26_2023_10_01.xml", | 
|  | 139 | +            date(2024, 7, 26), | 
|  | 140 | +        ), | 
|  | 141 | +        pytest.param( | 
|  | 142 | +            data_path / "PARTIN" / "PARTIN_MIG_1_0d_ausserordentliche_2024_07_26_2024_04_03.xml", | 
|  | 143 | +            date(2024, 7, 26), | 
|  | 144 | +        ), | 
|  | 145 | +        pytest.param( | 
|  | 146 | +            data_path / "PRICAT" / "PRICAT_MIG_2_0c_Fehlerkorrektur_2024_06_17_2024_04_03.xml", | 
|  | 147 | +            date(2024, 6, 17), | 
|  | 148 | +        ), | 
|  | 149 | +        pytest.param( | 
|  | 150 | +            data_path / "QUOTES" / "QUOTES_MIG_1_3_ausserordentliche_2024_07_26_2023_10_01.xml", | 
|  | 151 | +            date(2024, 7, 26), | 
|  | 152 | +        ), | 
|  | 153 | +        pytest.param( | 
|  | 154 | +            data_path / "REMADV" / "REMADV_MIG_2_9c_ausserordentliche_2024_07_26_2024_04_03.xml", | 
|  | 155 | +            date(2024, 7, 26), | 
|  | 156 | +        ), | 
|  | 157 | +        pytest.param( | 
|  | 158 | +            data_path / "REQOTE" / "REQOTE_MIG_1_3_ausserordentliche_2024_07_26_2023_10_01.xml", | 
|  | 159 | +            date(2024, 7, 26), | 
|  | 160 | +        ), | 
|  | 161 | +        pytest.param( | 
|  | 162 | +            data_path / "UTILMD" / "UTILMD_MIG_Gas_1_0_ausserordendliche_2024_07_26_2023_12_12.xml", | 
|  | 163 | +            date(2024, 7, 26), | 
|  | 164 | +        ), | 
|  | 165 | +        pytest.param( | 
|  | 166 | +            data_path / "UTILMD" / "UTILMD_MIG_Strom_1_1a_Fehlerkorrektur_2024_07_12_2024_07_11.xml", | 
|  | 167 | +            date(2024, 9, 23), | 
|  | 168 | +        ), | 
|  | 169 | +        pytest.param( | 
|  | 170 | +            data_path / "UTILMD" / "UTILMD_MIG_Strom_2_1_2024_10_01_2024_09_20.xml", | 
|  | 171 | +            date(2024, 10, 1), | 
|  | 172 | +        ), | 
|  | 173 | +        pytest.param( | 
|  | 174 | +            data_path / "UTILTS" / "UTILTS_MIG_1_1c_Fehlerkorrektur_2024_12_13_2024_12_13.xml", | 
|  | 175 | +            date(2024, 12, 13), | 
|  | 176 | +        ), | 
|  | 177 | +        pytest.param( | 
|  | 178 | +            data_path / "UTILTS" / "UTILTS_MIG_1_1c_Lesefassung_2023_12_12_2023_12_12.xml", | 
|  | 179 | +            date(2023, 10, 24), | 
|  | 180 | +        ), | 
|  | 181 | +        pytest.param( | 
|  | 182 | +            data_path / "UTILTS" / "UTILTS_MIG_1_1d_Konsultationsfassung_2024_04_02_2024_04_02.xml", | 
|  | 183 | +            date(2024, 4, 2), | 
|  | 184 | +        ), | 
|  | 185 | +    ], | 
|  | 186 | +) | 
|  | 187 | +def test_read_mig_xml(mig_xml_file_path: Path, expected_date: date) -> None: | 
|  | 188 | +    reader = MigReader(mig_xml_file_path) | 
|  | 189 | +    actual = reader.get_publishing_date() | 
|  | 190 | +    assert actual == expected_date | 
0 commit comments