Răsfoiți Sursa

tests (device): update for heartbeat change

The test that checks for a heartbeat no longer passes, because the heartbeat
should not be sent yet. Set up the preconditions so a heartbeat is due.
Jason Rumney 3 săptămâni în urmă
părinte
comite
54ce969d66
1 a modificat fișierele cu 4 adăugiri și 3 ștergeri
  1. 4 3
      tests/test_device.py

+ 4 - 3
tests/test_device.py

@@ -597,12 +597,13 @@ async def test_async_receive(subject, mock_api, mocker):
     mock_api().set_socketPersistent.assert_called_once_with(False)
     # Check that a full poll was done
     mock_api().status.assert_called_once()
-    assert result == {"1": "INIT", "2": 2, "full_poll": mocker.ANY}
+    assert result == {"1": "INIT", "2": 2, "full_poll": True}
     # Prepare for next round
     subject._cached_state = subject._cached_state | result
     mock_api().set_socketPersistent.reset_mock()
     mock_api().status.reset_mock()
-    subject._cached_state["updated_at"] = time()
+    # Set the updated_at back in time to force a heartbeat poll on the next iteration
+    subject._cached_state["updated_at"] = time() - 11
 
     # Call the function under test
     print("getting second iteration...")
@@ -612,7 +613,7 @@ async def test_async_receive(subject, mock_api, mocker):
     mock_api().status.assert_not_called()
     mock_api().heartbeat.assert_called_once()
     mock_api().receive.assert_called_once()
-    assert result == {"1": "UPDATED", "full_poll": mocker.ANY}
+    assert result == {"1": "UPDATED", "full_poll": False}
     # Check that the connection was made persistent now that data has been
     # returned
     mock_api().set_socketPersistent.assert_called_once_with(True)