"""Minimal tests for marketing_intelligence.agent_workflows.discovery_relevant pure functions.""" from marketing_intelligence.agent_workflows.discovery_relevant import ( STAGE1_SHARD_SIZE, STAGE1_SHARD_THRESHOLD, _build_units, _shard_sizes, ) class TestShardSizes: def test_below_threshold_returns_single_shard(self) -> None: result = _shard_sizes(50) assert result == [50] def test_at_threshold_returns_single_shard(self) -> None: result = _shard_sizes(STAGE1_SHARD_THRESHOLD) assert result == [STAGE1_SHARD_THRESHOLD] def test_above_threshold_splits_into_multiple(self) -> None: result = _shard_sizes(STAGE1_SHARD_THRESHOLD + 1) assert len(result) > 1 def test_total_equals_sample_size(self) -> None: for n in (50, 100, 150, 200, 350, 500): assert sum(_shard_sizes(n)) == n def test_shards_are_balanced(self) -> None: sizes = _shard_sizes(300) assert max(sizes) - min(sizes) <= 1 def test_large_sample_splits_into_shard_size_chunks(self) -> None: sizes = _shard_sizes(200) for s in sizes: assert s <= STAGE1_SHARD_SIZE class TestBuildUnits: def test_single_track_below_threshold(self) -> None: units = _build_units([("dance", "Dance Track", 50)]) assert len(units) == 1 tag, track_name, size, label, skip = units[0] assert tag == "dance" assert track_name == "Dance Track" assert size == 50 assert skip == 0 def test_multiple_tracks_each_get_unit(self) -> None: units = _build_units([("tag1", "Track1", 50), ("tag2", "Track2", 60)]) assert len(units) == 2 assert units[0][0] == "tag1" assert units[1][0] == "tag2" def test_zero_target_excluded(self) -> None: units = _build_units([("tag1", "Track1", 0), ("tag2", "Track2", 50)]) assert len(units) == 1 assert units[0][0] == "tag2" def test_sharded_track_has_skip_positions(self) -> None: units = _build_units([("dance", "Track", STAGE1_SHARD_THRESHOLD + 1)]) assert len(units) > 1 assert units[0][4] == 0 assert units[1][4] == STAGE1_SHARD_SIZE def test_label_suffix_appended(self) -> None: units = _build_units([("tag", "Track", 50)], label_suffix=" (resume)") assert "(resume)" in units[0][3] def test_single_shard_label_has_no_shard_numbering(self) -> None: units = _build_units([("tag", "Track", 50)]) assert "shard" not in units[0][3] def test_multi_shard_label_has_shard_numbering(self) -> None: units = _build_units([("tag", "Track", STAGE1_SHARD_THRESHOLD + 1)]) assert "shard" in units[0][3]