Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests/API
diff options
context:
space:
mode:
authorGhostkeeper <rubend@tutanota.com>2022-07-27 12:43:31 +0300
committerGhostkeeper <rubend@tutanota.com>2022-07-27 12:43:31 +0300
commit37a98cbb6f0075098dd8644b640966d7a8e36dd5 (patch)
tree958735186753f30d016efd1f157f15b178c0b23e /tests/API
parentd52be42e01480710920f2fc53ea2025e0798aa94 (diff)
Mock HttpRequestManager while changing sync stateCURA-9220_hide_if_no_permission
This change triggers a cascade of updates and in some cases triggers a sync. The sync trigger also triggers an update of the account permissions which crashes because the HttpRequestManager can't be started on a thread. We shouldn't make HTTP requests from our tests anyway so mock this away. Contributes to issue CURA-9220.
Diffstat (limited to 'tests/API')
-rw-r--r--tests/API/TestAccount.py46
1 files changed, 24 insertions, 22 deletions
diff --git a/tests/API/TestAccount.py b/tests/API/TestAccount.py
index 820e7dfbf5..9d62646eff 100644
--- a/tests/API/TestAccount.py
+++ b/tests/API/TestAccount.py
@@ -93,18 +93,19 @@ def test_sync_success():
service1 = "test_service1"
service2 = "test_service2"
- account.setSyncState(service1, SyncState.SYNCING)
- assert account.syncState == SyncState.SYNCING
+ with patch("UM.TaskManagement.HttpRequestManager.HttpRequestManager.getInstance"): # Don't want triggers for account information to actually make HTTP requests.
+ account.setSyncState(service1, SyncState.SYNCING)
+ assert account.syncState == SyncState.SYNCING
- account.setSyncState(service2, SyncState.SYNCING)
- assert account.syncState == SyncState.SYNCING
+ account.setSyncState(service2, SyncState.SYNCING)
+ assert account.syncState == SyncState.SYNCING
- account.setSyncState(service1, SyncState.SUCCESS)
- # service2 still syncing
- assert account.syncState == SyncState.SYNCING
+ account.setSyncState(service1, SyncState.SUCCESS)
+ # service2 still syncing
+ assert account.syncState == SyncState.SYNCING
- account.setSyncState(service2, SyncState.SUCCESS)
- assert account.syncState == SyncState.SUCCESS
+ account.setSyncState(service2, SyncState.SUCCESS)
+ assert account.syncState == SyncState.SUCCESS
def test_sync_update_action():
@@ -114,23 +115,24 @@ def test_sync_update_action():
mockUpdateCallback = MagicMock()
- account.setSyncState(service1, SyncState.SYNCING)
- assert account.syncState == SyncState.SYNCING
+ with patch("UM.TaskManagement.HttpRequestManager.HttpRequestManager.getInstance"): # Don't want triggers for account information to actually make HTTP requests.
+ account.setSyncState(service1, SyncState.SYNCING)
+ assert account.syncState == SyncState.SYNCING
- account.setUpdatePackagesAction(mockUpdateCallback)
- account.onUpdatePackagesClicked()
- mockUpdateCallback.assert_called_once_with()
- account.setSyncState(service1, SyncState.SUCCESS)
+ account.setUpdatePackagesAction(mockUpdateCallback)
+ account.onUpdatePackagesClicked()
+ mockUpdateCallback.assert_called_once_with()
+ account.setSyncState(service1, SyncState.SUCCESS)
- account.sync() # starting a new sync resets the update action to None
+ account.sync() # starting a new sync resets the update action to None
- account.setSyncState(service1, SyncState.SYNCING)
- assert account.syncState == SyncState.SYNCING
+ account.setSyncState(service1, SyncState.SYNCING)
+ assert account.syncState == SyncState.SYNCING
- account.onUpdatePackagesClicked() # Should not be connected to an action anymore
- mockUpdateCallback.assert_called_once_with() # No additional calls
- assert account.updatePackagesEnabled is False
- account.setSyncState(service1, SyncState.SUCCESS)
+ account.onUpdatePackagesClicked() # Should not be connected to an action anymore
+ mockUpdateCallback.assert_called_once_with() # No additional calls
+ assert account.updatePackagesEnabled is False
+ account.setSyncState(service1, SyncState.SUCCESS)