|
| 1 | +from returns.pipeline import is_successful |
| 2 | +from returns.result import Success |
| 3 | + |
| 4 | +from mediathequeroubaix.get_holds.hold import Hold |
| 5 | +from mediathequeroubaix.get_holds.parse_holds import parse_holds |
| 6 | + |
| 7 | + |
| 8 | +def test_empty() -> None: |
| 9 | + assert is_successful(parse_holds("")) is False |
| 10 | + |
| 11 | + |
| 12 | +def test_object() -> None: |
| 13 | + assert is_successful(parse_holds("{}")) is False |
| 14 | + |
| 15 | + |
| 16 | +def test_empty_array() -> None: |
| 17 | + assert parse_holds("[]") == Success([]) |
| 18 | + |
| 19 | + |
| 20 | +def test_some_holds() -> None: |
| 21 | + assert parse_holds( |
| 22 | + '[{"hold_id":507643,"title":"Apprendre, si par bonheur","itemnumber":null,"barcode":"","found":null,' |
| 23 | + '"cancellationdate":null,"rank":2,"biblionumber":329375,"itemcallnumber":"","reservedate":"2025-07-14",' |
| 24 | + '"branchcode":"MED","branchname":"M\u00e9diath\u00e8que"},{"hold_id":507642,"cancellationdate":null,' |
| 25 | + '"rank":0,"biblionumber":302152,"found":"W","itemnumber":368084,"barcode":"C1400002454",' |
| 26 | + '"title":"L\'espace d\'un an","reservedate":"2025-07-14","itemcallnumber":"SF\/CHA",' |
| 27 | + '"branchname":"M\u00e9diath\u00e8que","branchcode":"MED"}]' |
| 28 | + ) == Success( |
| 29 | + [ |
| 30 | + Hold( |
| 31 | + hold_id=507643, |
| 32 | + title="Apprendre, si par bonheur", |
| 33 | + itemnumber=None, |
| 34 | + barcode="", |
| 35 | + rank=2, |
| 36 | + itemcallnumber="", |
| 37 | + reservedate="2025-07-14", |
| 38 | + ), |
| 39 | + Hold( |
| 40 | + hold_id=507642, |
| 41 | + title="L'espace d'un an", |
| 42 | + itemnumber=368084, |
| 43 | + barcode="C1400002454", |
| 44 | + rank=0, |
| 45 | + itemcallnumber="SF/CHA", |
| 46 | + reservedate="2025-07-14", |
| 47 | + ), |
| 48 | + ] |
| 49 | + ) |
0 commit comments