@@ -53,7 +53,7 @@ def wait_for_selector_side_effect(*_, **__) -> AsyncMock:
5353 mock_page .wait_for_selector .side_effect = wait_for_selector_side_effect
5454 form_url = "https://example.com/form"
5555
56- with caplog .at_level ("INFO" ), patch ("src.form_submission .cryptogen.randint" , return_value = 250 ):
56+ with caplog .at_level ("INFO" ), patch ("src.automation .cryptogen.randint" , return_value = 250 ):
5757 await submit_listings (mock_page , form_url , sample_listings )
5858
5959 assert mock_page .goto .call_count == 3
@@ -67,7 +67,7 @@ async def test_submit_listings_all_succeed(caplog: LogCaptureFixture, sample_lis
6767 mock_page = AsyncMock ()
6868 form_url = "https://example.com/form"
6969
70- with caplog .at_level ("INFO" ), patch ("src.form_submission .cryptogen.randint" , return_value = 250 ):
70+ with caplog .at_level ("INFO" ), patch ("src.automation .cryptogen.randint" , return_value = 250 ):
7171 await submit_listings (mock_page , form_url , sample_listings )
7272
7373 assert "3 successful, 0 failed" in caplog .text
@@ -82,7 +82,7 @@ async def test_submit_listings_all_fail(caplog: LogCaptureFixture, sample_listin
8282 mock_page .wait_for_selector .side_effect = PlaywrightTimeoutError ("Timeout" )
8383 form_url = "https://example.com/form"
8484
85- with caplog .at_level ("INFO" ), patch ("src.form_submission .cryptogen.randint" , return_value = 250 ):
85+ with caplog .at_level ("INFO" ), patch ("src.automation .cryptogen.randint" , return_value = 250 ):
8686 await submit_listings (mock_page , form_url , sample_listings )
8787
8888 assert "0 successful, 3 failed" in caplog .text
@@ -107,7 +107,7 @@ async def test_submit_single_listing_flow_order() -> None:
107107 mock_page .wait_for_selector .side_effect = lambda * _ , ** __ : call_order .append ("wait_for_selector" )
108108 mock_page .wait_for_timeout .side_effect = lambda _ : call_order .append ("wait_for_timeout" )
109109
110- with patch ("src.form_submission .cryptogen.randint" , return_value = 250 ):
110+ with patch ("src.automation .cryptogen.randint" , return_value = 250 ):
111111 await _submit_single_listing (mock_page , form_url , listing )
112112
113113 # Verify the sequence
@@ -123,30 +123,6 @@ async def test_submit_single_listing_flow_order() -> None:
123123 ]
124124
125125
126- @pytest .mark .asyncio
127- async def test_submit_listings_uses_random_waits () -> None :
128- """Test that random wait times are used between submissions."""
129- mock_page = AsyncMock ()
130- listings = [
131- PropertyListing ("Addr1" , "$1000" , "1000" , "http://link1" ),
132- PropertyListing ("Addr2" , "$2000" , "2000" , "http://link2" ),
133- ]
134- form_url = "https://example.com/form"
135-
136- wait_times : list [int ] = []
137- mock_page .wait_for_timeout .side_effect = wait_times .append
138-
139- with patch ("src.form_submission.cryptogen.randint" ) as mock_randint :
140- # Return different values for each call
141- mock_randint .side_effect = [100 , 150 , 200 , 250 ]
142- await submit_listings (mock_page , form_url , listings )
143-
144- # Should have wait_for_timeout called multiple times (2 per listing)
145- assert len (wait_times ) == 4
146- # Verify the random values were used
147- assert wait_times == [100 , 150 , 200 , 250 ]
148-
149-
150126@pytest .mark .parametrize (
151127 "empty_list_arg" ,
152128 [
@@ -177,7 +153,7 @@ async def test_submit_single_listing_field_mapping(mock_page: AsyncMock) -> None
177153 listing = PropertyListing (address = "742 Evergreen Terrace" , price = "$2,500/mo" , median_price = "2500" , link = "https://zillow.com/listing/999" )
178154 form_url = "https://example.com/form"
179155
180- with patch ("src.form_submission .cryptogen.randint" , return_value = 250 ):
156+ with patch ("src.automation .cryptogen.randint" , return_value = 250 ):
181157 await _submit_single_listing (mock_page , form_url , listing )
182158
183159 fill_calls = mock_page .fill .call_args_list
0 commit comments