"""Tests for the CLI argument parsing in main.py.""" import pytest import main # --------------------------------------------------------------------------- # selected_sources: comma-separated --source values # --------------------------------------------------------------------------- def test_all_expands_to_every_source(): assert main.selected_sources("all") == ["rightmove", "onthemarket", "zoopla"] def test_single_source(): assert main.selected_sources("rightmove") == ["rightmove"] def test_comma_separated_sources(): assert main.selected_sources("rightmove,onthemarket") == [ "rightmove", "onthemarket", ] def test_whitespace_and_case_are_tolerated(): assert main.selected_sources(" Rightmove , ZOOPLA ") == ["rightmove", "zoopla"] def test_order_is_canonical_and_deduplicated(): # Caller order ignored, duplicates collapsed: keeps SOURCES order so the # downstream merge/dedup stays deterministic. assert main.selected_sources("zoopla,rightmove,rightmove") == [ "rightmove", "zoopla", ] def test_all_anywhere_in_the_list_wins(): assert main.selected_sources("rightmove,all") == [ "rightmove", "onthemarket", "zoopla", ] def test_empty_value_is_rejected(): with pytest.raises(SystemExit): main.selected_sources(" , ") def test_unknown_source_is_rejected(): with pytest.raises(SystemExit) as excinfo: main.selected_sources("rightmove,foo") assert "foo" in str(excinfo.value)