Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SilkeSchomann committed Dec 5, 2024
1 parent 101deef commit e6b4ec3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/workspacemanager_presenter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import unittest

import mock
from mock import call, patch, MagicMock
from mock import call, patch
import numpy as np

from mantid.api import AnalysisDataService
Expand Down Expand Up @@ -438,33 +438,37 @@ def test_compose_error(self):

def test_ensure_that_the_ads_observer_calls_delete_handle(self, _):
presenter = WorkspaceManagerPresenter(self.view)
presenter.delete_handle = MagicMock()
presenter.delete_handle = mock.Mock()
self.assertTrue(isinstance(presenter._ads_observer, MSliceADSObserver))
presenter._ads_observer = MSliceADSObserver(
presenter.delete_handle, presenter.clear_handle, presenter.rename_handle
)

# Ensure ADS is empty before test
AnalysisDataService.clear()
CreateSampleWorkspace(OutputWorkspace="ws", StoreInADS=True)
AnalysisDataService.remove("ws")

presenter.delete_handle.assert_called_once_with("ws")

def test_ensure_that_the_ads_observer_calls_clear_handle(self, _):
presenter = WorkspaceManagerPresenter(self.view)
presenter.clear_handle = MagicMock()
presenter.clear_handle = mock.Mock()
self.assertTrue(isinstance(presenter._ads_observer, MSliceADSObserver))
presenter._ads_observer = MSliceADSObserver(
presenter.delete_handle, presenter.clear_handle, presenter.rename_handle
)

# Ensure ADS is empty before test
AnalysisDataService.clear()
CreateSampleWorkspace(OutputWorkspace="ws", StoreInADS=True)
AnalysisDataService.clear()

presenter.clear_handle.assert_called_once()

def test_ensure_that_the_ads_observer_calls_rename_handle(self, _):
presenter = WorkspaceManagerPresenter(self.view)
presenter.rename_handle = MagicMock()
presenter.rename_handle = mock.Mock()
self.assertTrue(isinstance(presenter._ads_observer, MSliceADSObserver))
presenter._ads_observer = MSliceADSObserver(
presenter.delete_handle, presenter.clear_handle, presenter.rename_handle
Expand Down

0 comments on commit e6b4ec3

Please sign in to comment.