| 1 | """Regression: one non-dict Threads entry must not zero the whole source.""" |
| 2 | |
| 3 | from lib import threads |
| 4 | |
| 5 | |
| 6 | def test_non_dict_rows_are_skipped_not_fatal(): |
| 7 | items = threads._parse_items( |
| 8 | [None, "oops", {"id": "1", "text": "hello threads", "like_count": 3}], |
| 9 | "threads api", |
| 10 | ) |
| 11 | |
| 12 | assert len(items) == 1 |
| 13 | assert items[0]["id"] == "1" |
| 14 | assert items[0]["engagement"]["likes"] == 3 |
| 15 | |
| 16 | |
| 17 | def test_all_malformed_rows_yield_no_items(): |
| 18 | assert threads._parse_items([None, 7, "x"], "threads api") == [] |
| 19 |