

def test_log_package_handler_ok(self):
    task = {
        'status': 'running',
        'name': 'dump',
        'progress': 0,
        'message': None,
        'id': 1,
        'uuid': '00000000-0000-0000-0000-000000000000',
    }
    tm_patcher = mock.patch('nailgun.api.v1.handlers.logs.DumpTaskManager')
    th_patcher = mock.patch('nailgun.api.v1.handlers.logs.objects.Task')
    tm_mocked = tm_patcher.start()
    th_mocked = th_patcher.start()
    tm_instance = tm_mocked.return_value
    resp.execute.return_value = mock.Mock(**task)
    th_mocked.to_json.side_effect = (lambda x: task)
    resp = self.app.put(reverse('LogPackageHandler'), '[]', headers=self.default_headers)
    tm_patcher.stop()
    th_patcher.stop()
    self.assertEqual(resp.status_code, 202)
    self.assertDictEqual(task, resp.json_body)

dataset/ETHPy150Open openstack/fuel-web/nailgun/nailgun/test/unit/test_logs_handlers.py TestLogs.test_log_package_handler_ok/VarMisuse@86/169 `tm_instance`->`resp`