Merge pull request #2819 from hroff-1902/worker-delete-state

Remove state attribute from Worker class
This commit is contained in:
Matthias 2020-01-29 15:57:35 +01:00 committed by GitHub
commit 2396f35586
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 14 deletions

View File

@ -56,14 +56,6 @@ class Worker:
self._sd_notify = sdnotify.SystemdNotifier() if \
self._config.get('internals', {}).get('sd_notify', False) else None
@property
def state(self) -> State:
return self.freqtrade.state
@state.setter
def state(self, value: State) -> None:
self.freqtrade.state = value
def run(self) -> None:
state = None
while True:

View File

@ -797,10 +797,10 @@ def test_process_operational_exception(default_conf, ticker, mocker) -> None:
worker = Worker(args=None, config=default_conf)
patch_get_signal(worker.freqtrade)
assert worker.state == State.RUNNING
assert worker.freqtrade.state == State.RUNNING
worker._process()
assert worker.state == State.STOPPED
assert worker.freqtrade.state == State.STOPPED
assert 'OperationalException' in msg_mock.call_args_list[-1][0][0]['status']
@ -3631,7 +3631,7 @@ def test_startup_state(default_conf, mocker):
}
mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True))
worker = get_patched_worker(mocker, default_conf)
assert worker.state is State.RUNNING
assert worker.freqtrade.state is State.RUNNING
def test_startup_trade_reinit(default_conf, edge_conf, mocker):

View File

@ -11,11 +11,11 @@ from tests.conftest import get_patched_worker, log_has
def test_worker_state(mocker, default_conf, markets) -> None:
mocker.patch('freqtrade.exchange.Exchange.markets', PropertyMock(return_value=markets))
worker = get_patched_worker(mocker, default_conf)
assert worker.state is State.RUNNING
assert worker.freqtrade.state is State.RUNNING
default_conf.pop('initial_state')
worker = Worker(args=None, config=default_conf)
assert worker.state is State.STOPPED
assert worker.freqtrade.state is State.STOPPED
def test_worker_running(mocker, default_conf, caplog) -> None:
@ -41,7 +41,7 @@ def test_worker_stopped(mocker, default_conf, caplog) -> None:
mock_sleep = mocker.patch('time.sleep', return_value=None)
worker = get_patched_worker(mocker, default_conf)
worker.state = State.STOPPED
worker.freqtrade.state = State.STOPPED
state = worker._worker(old_state=State.RUNNING)
assert state is State.STOPPED
assert log_has('Changing state to: STOPPED', caplog)