|
1 | 1 | from __future__ import unicode_literals
|
| 2 | +import warnings |
2 | 3 |
|
3 | 4 | from elasticsearch.client import _normalize_hosts, Elasticsearch
|
4 | 5 |
|
@@ -110,3 +111,27 @@ def test_index_uses_put_if_id_is_not_empty(self):
|
110 | 111 | self.client.index(index="my-index", id=0, body={})
|
111 | 112 |
|
112 | 113 | self.assert_url_called("PUT", "/my-index/_doc/0")
|
| 114 | + |
| 115 | + def test_tasks_get_without_task_id_deprecated(self): |
| 116 | + warnings.simplefilter("always", DeprecationWarning) |
| 117 | + with warnings.catch_warnings(record=True) as w: |
| 118 | + self.client.tasks.get() |
| 119 | + |
| 120 | + self.assert_url_called("GET", "/_tasks") |
| 121 | + self.assertEquals(len(w), 1) |
| 122 | + self.assertIs(w[0].category, DeprecationWarning) |
| 123 | + self.assertEquals( |
| 124 | + str(w[0].message), |
| 125 | + "Calling client.tasks.get() without a task_id is deprecated " |
| 126 | + "and will be removed in v8.0. Use client.tasks.list() instead.", |
| 127 | + ) |
| 128 | + |
| 129 | + def test_tasks_get_with_task_id_not_deprecated(self): |
| 130 | + warnings.simplefilter("always", DeprecationWarning) |
| 131 | + with warnings.catch_warnings(record=True) as w: |
| 132 | + self.client.tasks.get("task-1") |
| 133 | + self.client.tasks.get(task_id="task-2") |
| 134 | + |
| 135 | + self.assert_url_called("GET", "/_tasks/task-1") |
| 136 | + self.assert_url_called("GET", "/_tasks/task-2") |
| 137 | + self.assertEquals(len(w), 0) |
0 commit comments