Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
don't store booleans in config_desc
Browse files Browse the repository at this point in the history
supplements #4860
  • Loading branch information
etam committed Nov 7, 2019
1 parent b0569f1 commit a116c8f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
20 changes: 10 additions & 10 deletions tests/golem/task/test_taskcomputeradapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def setUp(self, new_task_computer, old_task_computer, int_stats_keeper): # noqa
self.old_computer = old_task_computer()
self.int_stats_keeper = int_stats_keeper()
config_desc = ClientConfigDescriptor()
config_desc.accept_tasks = True
config_desc.in_shutdown = False
config_desc.accept_tasks = 1
config_desc.in_shutdown = 0
self.task_keeper = mock.Mock()
self.task_server = mock.Mock(
spec=TaskServer,
Expand Down Expand Up @@ -330,23 +330,23 @@ def _test_compute_tasks(self, accept_tasks, in_shutdown, expected):
@defer.inlineCallbacks
def test_compute_tasks_setting(self):
yield self._test_compute_tasks(
accept_tasks=True,
in_shutdown=True,
accept_tasks=1,
in_shutdown=1,
expected=False
)
yield self._test_compute_tasks(
accept_tasks=True,
in_shutdown=False,
accept_tasks=1,
in_shutdown=0,
expected=True
)
yield self._test_compute_tasks(
accept_tasks=False,
in_shutdown=True,
accept_tasks=0,
in_shutdown=1,
expected=False
)
yield self._test_compute_tasks(
accept_tasks=False,
in_shutdown=False,
accept_tasks=0,
in_shutdown=0,
expected=False
)

Expand Down
2 changes: 1 addition & 1 deletion tests/golem/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ def test_provider_status_computing(self, *_):

def test_provider_status_not_accepting_tasks(self, *_):
# given
self.client.config_desc.accept_tasks = False
self.client.config_desc.accept_tasks = 0

# when
status = self.client.get_provider_status()
Expand Down
10 changes: 4 additions & 6 deletions tests/golem/test_opt_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ def test_graceful_shutdown_quit(self, reactor, *_):

@patch('golem.node.StatusPublisher')
def test_graceful_shutdown_off(self, publisher, *_):
self.node_kwargs['config_desc'].in_shutdown = True
self.node_kwargs['config_desc'].in_shutdown = 1

self.node = Node(**self.node_kwargs)
self.node.quit = Mock()
Expand All @@ -851,8 +851,7 @@ def test_graceful_shutdown_off(self, publisher, *_):

result = self.node.graceful_shutdown()
assert result == ShutdownResponse.off
assert self.node.client.update_settings.called_with('in_shutdown',
False)
assert self.node.client.update_settings.called_with('in_shutdown', 0)
assert self.node._is_task_in_progress.not_called
assert self.node.quit.not_called
publisher.publish.assert_called_with(
Expand All @@ -867,8 +866,7 @@ def test_graceful_shutdown_on(self, publisher, *_):

result = self.node.graceful_shutdown()
assert result == ShutdownResponse.on
assert self.node.client.update_settings.called_with('in_shutdown',
True)
assert self.node.client.update_settings.called_with('in_shutdown', 1)
assert self.node.quit.not_called
assert self.node._is_task_in_progress.called
publisher.publish.assert_called_with(
Expand All @@ -886,7 +884,7 @@ def test_try_shutdown(self, *_):
result = self.node.graceful_shutdown()
assert result == ShutdownResponse.on

self.node._config_desc.in_shutdown = True
self.node._config_desc.in_shutdown = 1
self.node._is_task_in_progress = Mock(return_value=False)
self.node._try_shutdown()
assert self.node._is_task_in_progress.called
Expand Down

0 comments on commit a116c8f

Please sign in to comment.