@@ -69,13 +69,13 @@ class TestGates:
6969 def test_no_finder_key_is_a_no_op (self , db ):
7070 SiteConfig .objects .update (bettercontact_api_key = "" )
7171 with patch .object (discover_mod , "_fetch" ) as fetch :
72- assert discover (_campaign ()) == 0
72+ assert discover (_campaign ()) is False
7373 fetch .assert_not_called ()
7474
7575 def test_no_icp_text_is_a_no_op (self , db ):
7676 c = _campaign (product_docs = "" , campaign_target = "" )
7777 with patch .object (discover_mod , "_fetch" ) as fetch :
78- assert discover (c ) == 0
78+ assert discover (c ) is False
7979 fetch .assert_not_called ()
8080
8181
@@ -86,9 +86,9 @@ def test_a_productive_page_creates_leads_and_advances_the_node(self, db):
8686 page = Page ([_row ()], 9027 )
8787
8888 with patch .object (discover_mod , "_fetch" , return_value = page ):
89- created = discover (c )
89+ assert discover (c ) is True
9090
91- assert created == 1
91+ assert Lead . objects . count () == 1
9292 node .refresh_from_db ()
9393 assert node .state == QueryNode .State .FIRED
9494 assert node .next_offset == select .DISCOVERY_PAGE_SIZE
@@ -98,14 +98,16 @@ def test_a_productive_page_creates_leads_and_advances_the_node(self, db):
9898 def test_a_page_of_duplicates_is_not_a_stall (self , db ):
9999 # Bug 8: `_harvest` counts *newly created* leads, and a page of already-seen
100100 # profiles used to read as "nothing left to do" and halt the engine with the
101- # frontier wide open. The node must still advance.
101+ # frontier wide open. The node must still advance, and the walk must report
102+ # that it moved — `top_up` stops the whole job on a False here.
102103 c = _campaign ()
103104 node = _node (c , [("lead_job_title" , "founder" )])
104105 Lead .objects .create (profile_url = "https://linkedin.com/in/a" , profile_text = "x" )
105106
106107 with patch .object (discover_mod , "_fetch" , return_value = Page ([_row ()], 10 )):
107- assert discover (c ) == 0
108+ assert discover (c ) is True
108109
110+ assert Lead .objects .count () == 1 # nothing new created — and that is fine
109111 node .refresh_from_db ()
110112 assert node .state == QueryNode .State .FIRED
111113 assert node .next_offset == select .DISCOVERY_PAGE_SIZE
@@ -147,7 +149,7 @@ def test_a_positive_count_with_no_rows_is_a_transport_artifact(self, db):
147149
148150 with patch .object (discover_mod , "_fetch" ,
149151 return_value = Page ([], 71403396 )) as fetch :
150- assert discover (c ) == 0
152+ assert discover (c ) is False
151153
152154 assert fetch .call_count == 1 # not even retried — the count already answered
153155 node .refresh_from_db ()
@@ -172,15 +174,15 @@ def test_the_loop_tries_the_next_node_after_a_dead_one(self, db):
172174
173175 pages = [Page ([], 0 ), Page ([_row ()], 10 )]
174176 with patch .object (discover_mod , "_fetch" , side_effect = pages ):
175- assert discover (c ) == 1
177+ assert discover (c ) is True
176178
177179 assert QueryNode .objects .filter (campaign = c , state = QueryNode .State .DEAD ).count () == 1
178180
179- def test_saturation_returns_zero (self , db ):
181+ def test_saturation_is_the_one_false (self , db ):
180182 c = _campaign ()
181183 _node (c , [("lead_job_title" , "a" )], state = QueryNode .State .DRAINED )
182184 with patch .object (discover_mod , "_fetch" ) as fetch :
183- assert discover (c ) == 0
185+ assert discover (c ) is False
184186 fetch .assert_not_called ()
185187
186188
@@ -192,7 +194,7 @@ def test_an_outage_leaves_the_node_on_the_frontier(self, db):
192194 node = _node (c , [("lead_job_title" , "founder" )])
193195
194196 with patch .object (discover_mod , "_fetch" , return_value = None ):
195- assert discover (c ) == 0
197+ assert discover (c ) is False
196198
197199 node .refresh_from_db ()
198200 assert node .state == QueryNode .State .FRONTIER
0 commit comments