@mock.patch('shaker.agent.agent.sleep')
    @mock.patch('shaker.agent.agent.time_now')
    @mock.patch('shaker.agent.agent.run_command')
    def test_work_act_schedule(self, mock_run_command, mock_now, mock_sleep):
        agent_id = 'the-agent'
        polling_interval = 10
        start_at = 1234
        now = 1230

        mock_socket = mock.Mock()
        mock_socket.recv_json.side_effect = [
            dict(operation='execute', start_at=start_at), dict(),
        ]
        execute_result = {'res': 'data'}
        mock_run_command.return_value = execute_result

        mock_now.return_value = now

        agent.work_act(mock_socket, agent_id, polling_interval)

        mock_sleep.assert_has_calls([
            mock.call(start_at - now),
            mock.call(polling_interval),
        ])

        mock_socket.send_json.assert_has_calls([
            mock.call(dict(operation='poll', agent_id=agent_id)),
            mock.call(dict(operation='reply', agent_id=agent_id, res='data')),
        ])
dataset/ETHPy150Open openstack/shaker/shaker/tests/test_agent.py/TestAgent.test_work_act_schedule/original