|
1 | 1 | import pytest |
2 | 2 |
|
3 | | -from fundamend.utils import remove_linebreaks_and_hyphens |
| 3 | +from fundamend.models.anwendungshandbuch import Kommunikationsrichtung |
| 4 | +from fundamend.utils import parse_kommunikation_von, remove_linebreaks_and_hyphens |
4 | 5 |
|
5 | 6 |
|
6 | 7 | @pytest.mark.parametrize( |
|
20 | 21 | def test_anwendungsfall_beschreibung_normalization(original: str, expected: str) -> None: |
21 | 22 | actual = remove_linebreaks_and_hyphens(original) |
22 | 23 | assert actual == expected |
| 24 | + |
| 25 | + |
| 26 | +@pytest.mark.parametrize( |
| 27 | + "original, expected", |
| 28 | + [ |
| 29 | + pytest.param("", [], id="empty string = no directions"), |
| 30 | + pytest.param("LF an NB", [Kommunikationsrichtung(sender="LF", empfaenger="NB")], id="simple example"), |
| 31 | + pytest.param( |
| 32 | + "MSB an NB, LF", |
| 33 | + [ |
| 34 | + Kommunikationsrichtung(sender="MSB", empfaenger="NB"), |
| 35 | + Kommunikationsrichtung(sender="MSB", empfaenger="LF"), |
| 36 | + ], |
| 37 | + id="two receivers, comma separated", |
| 38 | + ), |
| 39 | + pytest.param( |
| 40 | + "MSB an NB / LF", |
| 41 | + [ |
| 42 | + Kommunikationsrichtung(sender="MSB", empfaenger="NB"), |
| 43 | + Kommunikationsrichtung(sender="MSB", empfaenger="LF"), |
| 44 | + ], |
| 45 | + id="two receivers, slash separated", |
| 46 | + ), |
| 47 | + pytest.param( |
| 48 | + "NB, LF an MSB", |
| 49 | + [ |
| 50 | + Kommunikationsrichtung(sender="NB", empfaenger="MSB"), |
| 51 | + Kommunikationsrichtung(sender="LF", empfaenger="MSB"), |
| 52 | + ], |
| 53 | + id="two senders, comma separated", |
| 54 | + ), |
| 55 | + pytest.param( |
| 56 | + "NB / LF an MSB", |
| 57 | + [ |
| 58 | + Kommunikationsrichtung(sender="NB", empfaenger="MSB"), |
| 59 | + Kommunikationsrichtung(sender="LF", empfaenger="MSB"), |
| 60 | + ], |
| 61 | + id="two senders, slash separated", |
| 62 | + ), |
| 63 | + pytest.param( |
| 64 | + "BIKO an NB / ÜNB", |
| 65 | + [ |
| 66 | + Kommunikationsrichtung(sender="BIKO", empfaenger="NB"), |
| 67 | + Kommunikationsrichtung(sender="BIKO", empfaenger="ÜNB"), |
| 68 | + ], |
| 69 | + id="two receivers, slash separated but with Umlaut", |
| 70 | + ), |
| 71 | + pytest.param( |
| 72 | + "NB an LF\nMSB an LF, NB, ESA", |
| 73 | + [ |
| 74 | + Kommunikationsrichtung(sender="NB", empfaenger="LF"), |
| 75 | + Kommunikationsrichtung(sender="MSB", empfaenger="LF"), |
| 76 | + Kommunikationsrichtung(sender="MSB", empfaenger="NB"), |
| 77 | + Kommunikationsrichtung(sender="MSB", empfaenger="ESA"), |
| 78 | + ], |
| 79 | + id="two lines", |
| 80 | + ), |
| 81 | + pytest.param( |
| 82 | + "NB an LF / MSB\r\nLF an NB, MSB", |
| 83 | + [ |
| 84 | + Kommunikationsrichtung(sender="NB", empfaenger="LF"), |
| 85 | + Kommunikationsrichtung(sender="NB", empfaenger="MSB"), |
| 86 | + Kommunikationsrichtung(sender="LF", empfaenger="NB"), |
| 87 | + Kommunikationsrichtung(sender="LF", empfaenger="MSB"), |
| 88 | + ], |
| 89 | + id="two lines with mixed separators", |
| 90 | + # shit is real, I'm not making this up |
| 91 | + ), |
| 92 | + pytest.param( |
| 93 | + "MSB an NB/LF/ÜNB/MSB/ESA", |
| 94 | + [ |
| 95 | + Kommunikationsrichtung(sender="MSB", empfaenger="NB"), |
| 96 | + Kommunikationsrichtung(sender="MSB", empfaenger="LF"), |
| 97 | + Kommunikationsrichtung(sender="MSB", empfaenger="ÜNB"), |
| 98 | + Kommunikationsrichtung(sender="MSB", empfaenger="MSB"), |
| 99 | + Kommunikationsrichtung(sender="MSB", empfaenger="ESA"), |
| 100 | + ], |
| 101 | + id="many receivers", |
| 102 | + ), |
| 103 | + ], |
| 104 | +) |
| 105 | +def test_parsing_kommunikation_von(original: str, expected: list[Kommunikationsrichtung]) -> None: |
| 106 | + actual = parse_kommunikation_von(original) |
| 107 | + assert actual == expected |
0 commit comments