test_elasticsearch.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. # -*- coding: utf-8 -*-
  2. '''
  3. :codeauthor: Lukas Raska <lukas@raska.me>
  4. '''
  5. # Import Python libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. # Import Salt Testing Libs
  8. from tests.support.mixins import LoaderModuleMockMixin
  9. from tests.support.unit import TestCase
  10. from tests.support.mock import (
  11. MagicMock,
  12. patch)
  13. from salt.exceptions import CommandExecutionError
  14. # Import Salt Libs
  15. import salt.utils.dictdiffer as dictdiffer
  16. from salt.states import elasticsearch
  17. class ElasticsearchTestCase(TestCase, LoaderModuleMockMixin):
  18. '''
  19. Test cases for salt.states.elasticsearch
  20. '''
  21. def setup_loader_modules(self):
  22. return {
  23. elasticsearch: {
  24. '__opts__': {'test': False},
  25. '__utils__': {'dictdiffer.deep_diff': dictdiffer.deep_diff}
  26. }
  27. }
  28. # 'index_absent' function tests: 1
  29. def test_index_absent(self):
  30. '''
  31. Test to manage a elasticsearch index.
  32. '''
  33. name = 'foo'
  34. ret = {'name': name,
  35. 'result': True,
  36. 'comment': 'Index foo is already absent',
  37. 'changes': {}}
  38. mock_get = MagicMock(side_effect=[None, {name: {"test": "key"}}, {name: {}}, {name: {"test": "key"}}, CommandExecutionError, {name: {"test": "key"}}])
  39. mock_delete = MagicMock(side_effect=[True, False, CommandExecutionError])
  40. with patch.dict(elasticsearch.__salt__, {'elasticsearch.index_get': mock_get,
  41. 'elasticsearch.index_delete': mock_delete}):
  42. self.assertDictEqual(elasticsearch.index_absent(name), ret)
  43. ret.update({'comment': 'Successfully removed index foo', 'changes': {"old": {"test": "key"}}})
  44. self.assertDictEqual(elasticsearch.index_absent(name), ret)
  45. ret.update({'comment': 'Failed to remove index foo for unknown reasons', 'result': False, 'changes': {}})
  46. self.assertDictEqual(elasticsearch.index_absent(name), ret)
  47. with patch.dict(elasticsearch.__opts__, {'test': True}):
  48. ret.update({'comment': "Index foo will be removed", 'result': None, 'changes': {"old": {"test": "key"}}})
  49. self.assertDictEqual(elasticsearch.index_absent(name), ret)
  50. ret.update({'comment': '', 'result': False, 'changes': {}})
  51. self.assertDictEqual(elasticsearch.index_absent(name), ret)
  52. ret.update({'comment': '', 'result': False, 'changes': {}})
  53. self.assertDictEqual(elasticsearch.index_absent(name), ret)
  54. # 'index_present' function tests: 1
  55. def test_index_present(self):
  56. '''
  57. Test to manage a elasticsearch index.
  58. '''
  59. name = 'foo'
  60. ret = {'name': name,
  61. 'result': True,
  62. 'comment': 'Index foo is already present',
  63. 'changes': {}}
  64. mock_exists = MagicMock(side_effect=[True, False, False, False, CommandExecutionError, False, False])
  65. mock_get = MagicMock(side_effect=[{name: {"test": "key"}}, CommandExecutionError])
  66. mock_create = MagicMock(side_effect=[True, False, CommandExecutionError, True])
  67. with patch.dict(elasticsearch.__salt__, {'elasticsearch.index_get': mock_get,
  68. 'elasticsearch.index_exists': mock_exists,
  69. 'elasticsearch.index_create': mock_create}):
  70. self.assertDictEqual(elasticsearch.index_present(name), ret)
  71. ret.update({'comment': 'Successfully created index foo', 'changes': {"new": {"test": "key"}}})
  72. self.assertDictEqual(elasticsearch.index_present(name), ret)
  73. ret.update({'comment': 'Cannot create index foo, False', 'result': False, 'changes': {}})
  74. self.assertDictEqual(elasticsearch.index_present(name), ret)
  75. with patch.dict(elasticsearch.__opts__, {'test': True}):
  76. ret.update({'comment': "Index foo does not exist and will be created", 'result': None, 'changes': {"new": {"test2": "key"}}})
  77. self.assertDictEqual(elasticsearch.index_present(name, {"test2": "key"}), ret)
  78. ret.update({'comment': '', 'result': False, 'changes': {}})
  79. self.assertDictEqual(elasticsearch.index_absent(name), ret)
  80. ret.update({'comment': '', 'result': False, 'changes': {}})
  81. self.assertDictEqual(elasticsearch.index_absent(name), ret)
  82. ret.update({'comment': '', 'result': False, 'changes': {}})
  83. self.assertDictEqual(elasticsearch.index_absent(name), ret)
  84. # 'alias_absent' function tests: 1
  85. def test_alias_absent(self):
  86. '''
  87. Test to manage a elasticsearch alias.
  88. '''
  89. name = 'foo'
  90. index = 'bar'
  91. alias = {index: {"aliases": {name: {"test": "key"}}}}
  92. ret = {'name': name,
  93. 'result': True,
  94. 'comment': 'Alias foo for index bar is already absent',
  95. 'changes': {}}
  96. mock_get = MagicMock(side_effect=[None, {"foo2": {}}, alias, alias, alias, CommandExecutionError, alias])
  97. mock_delete = MagicMock(side_effect=[True, False, CommandExecutionError])
  98. with patch.dict(elasticsearch.__salt__, {'elasticsearch.alias_get': mock_get,
  99. 'elasticsearch.alias_delete': mock_delete}):
  100. self.assertDictEqual(elasticsearch.alias_absent(name, index), ret)
  101. self.assertDictEqual(elasticsearch.alias_absent(name, index), ret)
  102. ret.update({'comment': 'Successfully removed alias foo for index bar', 'changes': {"old": {"test": "key"}}})
  103. self.assertDictEqual(elasticsearch.alias_absent(name, index), ret)
  104. ret.update({'comment': 'Failed to remove alias foo for index bar for unknown reasons', 'result': False, 'changes': {}})
  105. self.assertDictEqual(elasticsearch.alias_absent(name, index), ret)
  106. with patch.dict(elasticsearch.__opts__, {'test': True}):
  107. ret.update({'comment': "Alias foo for index bar will be removed", 'result': None, 'changes': {"old": {"test": "key"}}})
  108. self.assertDictEqual(elasticsearch.alias_absent(name, index), ret)
  109. ret.update({'comment': '', 'result': False, 'changes': {}})
  110. self.assertDictEqual(elasticsearch.alias_absent(name, index), ret)
  111. ret.update({'comment': '', 'result': False, 'changes': {}})
  112. self.assertDictEqual(elasticsearch.alias_absent(name, index), ret)
  113. # 'alias_present' function tests: 1
  114. def test_alias_present(self):
  115. '''
  116. Test to manage a elasticsearch alias.
  117. '''
  118. name = 'foo'
  119. index = 'bar'
  120. alias = {index: {"aliases": {name: {"test": "key"}}}}
  121. ret = {'name': name,
  122. 'result': True,
  123. 'comment': 'Alias foo for index bar is already present',
  124. 'changes': {}}
  125. mock_get = MagicMock(side_effect=[alias, alias, None, None, None, alias, CommandExecutionError, None])
  126. mock_create = MagicMock(side_effect=[True, True, False, CommandExecutionError])
  127. with patch.dict(elasticsearch.__salt__, {'elasticsearch.alias_get': mock_get,
  128. 'elasticsearch.alias_create': mock_create}):
  129. self.assertDictEqual(elasticsearch.alias_present(name, index, {"test": "key"}), ret)
  130. ret.update({'comment': "Successfully replaced alias foo for index bar", 'changes': {'old': {"test": "key"}, 'new': {"test2": "key"}}})
  131. self.assertDictEqual(elasticsearch.alias_present(name, index, {"test2": "key"}), ret)
  132. ret.update({'comment': "Successfully created alias foo for index bar", 'changes': {'new': {"test2": "key"}}})
  133. self.assertDictEqual(elasticsearch.alias_present(name, index, {"test2": "key"}), ret)
  134. ret.update({'comment': 'Cannot create alias foo for index bar, False', 'result': False})
  135. self.assertDictEqual(elasticsearch.alias_present(name, index, {"test2": "key"}), ret)
  136. with patch.dict(elasticsearch.__opts__, {'test': True}):
  137. ret.update({'comment': "Alias foo for index bar does not exist and will be created", 'result': None, 'changes': {'new': {"test2": "key"}}})
  138. self.assertDictEqual(elasticsearch.alias_present(name, index, {"test2": "key"}), ret)
  139. ret.update({'comment': "Alias foo for index bar exists with wrong configuration and will be overridden", 'result': None, 'changes': {'old': {"test": "key"}, 'new': {"test2": "key"}}})
  140. self.assertDictEqual(elasticsearch.alias_present(name, index, {"test2": "key"}), ret)
  141. ret.update({'comment': '', 'result': False, 'changes': {}})
  142. self.assertDictEqual(elasticsearch.alias_present(name, index), ret)
  143. ret.update({'comment': '', 'result': False, 'changes': {}})
  144. self.assertDictEqual(elasticsearch.alias_present(name, index), ret)
  145. # 'index_template_absent' function tests: 1
  146. def test_index_template_absent(self):
  147. '''
  148. Test to manage a elasticsearch index template.
  149. '''
  150. name = 'foo'
  151. index_template = {name: {"test": "key"}}
  152. ret = {'name': name,
  153. 'result': True,
  154. 'comment': 'Index template foo is already absent',
  155. 'changes': {}}
  156. mock_get = MagicMock(side_effect=[None, {"bar": {}}, index_template, index_template, index_template, CommandExecutionError, index_template])
  157. mock_delete = MagicMock(side_effect=[True, False, CommandExecutionError])
  158. with patch.dict(elasticsearch.__salt__, {'elasticsearch.index_template_get': mock_get,
  159. 'elasticsearch.index_template_delete': mock_delete}):
  160. self.assertDictEqual(elasticsearch.index_template_absent(name), ret)
  161. self.assertDictEqual(elasticsearch.index_template_absent(name), ret)
  162. ret.update({'comment': 'Successfully removed index template foo', 'changes': {"old": {"test": "key"}}})
  163. self.assertDictEqual(elasticsearch.index_template_absent(name), ret)
  164. ret.update({'comment': 'Failed to remove index template foo for unknown reasons', 'result': False, 'changes': {}})
  165. self.assertDictEqual(elasticsearch.index_template_absent(name), ret)
  166. with patch.dict(elasticsearch.__opts__, {'test': True}):
  167. ret.update({'comment': "Index template foo will be removed", 'result': None, 'changes': {"old": {"test": "key"}}})
  168. self.assertDictEqual(elasticsearch.index_template_absent(name), ret)
  169. ret.update({'comment': '', 'result': False, 'changes': {}})
  170. self.assertDictEqual(elasticsearch.index_template_absent(name), ret)
  171. ret.update({'comment': '', 'result': False, 'changes': {}})
  172. self.assertDictEqual(elasticsearch.index_template_absent(name), ret)
  173. # 'index_template_present' function tests: 1
  174. def test_index_template_present(self):
  175. '''
  176. Test to manage a elasticsearch index template.
  177. '''
  178. name = 'foo'
  179. index_template = {name: {"test": "key"}}
  180. ret = {'name': name,
  181. 'result': True,
  182. 'comment': 'Index template foo is already present',
  183. 'changes': {}}
  184. mock_exists = MagicMock(side_effect=[True, False, False, False, CommandExecutionError, False, False])
  185. mock_create = MagicMock(side_effect=[True, False, CommandExecutionError, True])
  186. mock_get = MagicMock(side_effect=[index_template, CommandExecutionError])
  187. with patch.dict(elasticsearch.__salt__, {'elasticsearch.index_template_get': mock_get,
  188. 'elasticsearch.index_template_create': mock_create,
  189. 'elasticsearch.index_template_exists': mock_exists}):
  190. self.assertDictEqual(elasticsearch.index_template_present(name, {"test2": "key"}), ret)
  191. ret.update({'comment': "Successfully created index template foo", 'changes': {'new': {"test": "key"}}})
  192. self.assertDictEqual(elasticsearch.index_template_present(name, {"test2": "key"}), ret)
  193. ret.update({'comment': 'Cannot create index template foo, False', 'result': False, 'changes': {}})
  194. self.assertDictEqual(elasticsearch.index_template_present(name, {"test2": "key"}), ret)
  195. with patch.dict(elasticsearch.__opts__, {'test': True}):
  196. ret.update({'comment': "Index template foo does not exist and will be created", 'result': None, 'changes': {'new': {"test2": "key"}}})
  197. self.assertDictEqual(elasticsearch.index_template_present(name, {"test2": "key"}), ret)
  198. ret.update({'comment': '', 'result': False, 'changes': {}})
  199. self.assertDictEqual(elasticsearch.index_template_present(name, {}), ret)
  200. ret.update({'comment': '', 'result': False, 'changes': {}})
  201. self.assertDictEqual(elasticsearch.index_template_present(name, {}), ret)
  202. ret.update({'comment': '', 'result': False, 'changes': {}})
  203. self.assertDictEqual(elasticsearch.index_template_present(name, {}), ret)
  204. def test_index_template_present_check_definition(self):
  205. '''
  206. Test to manage a elasticsearch index template.
  207. with check_definition set
  208. '''
  209. name = 'foo'
  210. index_template = {name: {"test2": "key",
  211. "aliases": {},
  212. "mappings": {},
  213. "settings": {}}}
  214. expected = {'name': name,
  215. 'result': True,
  216. 'comment': 'Index template foo is already present and up to date',
  217. 'changes': {}}
  218. mock_exists = MagicMock(side_effect=[True])
  219. mock_create = MagicMock(side_effect=[True])
  220. mock_get = MagicMock(side_effect=[index_template])
  221. with patch.dict(elasticsearch.__salt__, {'elasticsearch.index_template_get': mock_get,
  222. 'elasticsearch.index_template_create': mock_create,
  223. 'elasticsearch.index_template_exists': mock_exists}):
  224. ret = elasticsearch.index_template_present(name,
  225. {"test2": "key",
  226. "aliases": {}},
  227. check_definition=True)
  228. self.assertDictEqual(expected, ret)
  229. def test_index_template_present_check_definition_alias_not_empty(self):
  230. '''
  231. Test to manage a elasticsearch index template.
  232. with check_definition set and alias is not empty
  233. '''
  234. name = 'foo'
  235. index_template = {name: {"test2": "key",
  236. "aliases": {},
  237. "mappings": {},
  238. "settings": {}}}
  239. expected = {'name': name,
  240. 'result': True,
  241. 'comment': 'Successfully updated index template foo',
  242. 'changes': {'new': {'aliases': {'alias1': {}}}, 'old': {'aliases': {}}}}
  243. mock_exists = MagicMock(side_effect=[True])
  244. mock_create = MagicMock(side_effect=[True])
  245. mock_get = MagicMock(side_effect=[index_template])
  246. with patch.dict(elasticsearch.__salt__, {'elasticsearch.index_template_get': mock_get,
  247. 'elasticsearch.index_template_create': mock_create,
  248. 'elasticsearch.index_template_exists': mock_exists}):
  249. ret = elasticsearch.index_template_present(name,
  250. {"test2": "key",
  251. "aliases": {'alias1': {}}},
  252. check_definition=True)
  253. self.assertDictEqual(expected, ret)
  254. # 'pipeline_absent' function tests: 1
  255. def test_pipeline_absent(self):
  256. '''
  257. Test to manage a elasticsearch pipeline.
  258. '''
  259. name = 'foo'
  260. pipeline = {name: {"test": "key"}}
  261. ret = {'name': name,
  262. 'result': True,
  263. 'comment': 'Pipeline foo is already absent',
  264. 'changes': {}}
  265. mock_get = MagicMock(side_effect=[None, {"foo2": {}}, pipeline, pipeline, pipeline, CommandExecutionError, pipeline])
  266. mock_delete = MagicMock(side_effect=[True, False, CommandExecutionError])
  267. with patch.dict(elasticsearch.__salt__, {'elasticsearch.pipeline_get': mock_get,
  268. 'elasticsearch.pipeline_delete': mock_delete}):
  269. self.assertDictEqual(elasticsearch.pipeline_absent(name), ret)
  270. self.assertDictEqual(elasticsearch.pipeline_absent(name), ret)
  271. ret.update({'comment': 'Successfully removed pipeline foo', 'changes': {"old": {"test": "key"}}})
  272. self.assertDictEqual(elasticsearch.pipeline_absent(name), ret)
  273. ret.update({'comment': 'Failed to remove pipeline foo for unknown reasons', 'result': False, 'changes': {}})
  274. self.assertDictEqual(elasticsearch.pipeline_absent(name), ret)
  275. with patch.dict(elasticsearch.__opts__, {'test': True}):
  276. ret.update({'comment': "Pipeline foo will be removed", 'result': None, 'changes': {"old": {"test": "key"}}})
  277. self.assertDictEqual(elasticsearch.pipeline_absent(name), ret)
  278. ret.update({'comment': '', 'result': False, 'changes': {}})
  279. self.assertDictEqual(elasticsearch.pipeline_absent(name), ret)
  280. ret.update({'comment': '', 'result': False, 'changes': {}})
  281. self.assertDictEqual(elasticsearch.pipeline_absent(name), ret)
  282. # 'pipeline_present' function tests: 1
  283. def test_pipeline_present(self):
  284. '''
  285. Test to manage a elasticsearch pipeline.
  286. '''
  287. name = 'foo'
  288. pipeline = {name: {"test": "key"}}
  289. ret = {'name': name,
  290. 'result': True,
  291. 'comment': 'Pipeline foo is already present',
  292. 'changes': {}}
  293. mock_get = MagicMock(side_effect=[pipeline, pipeline, None, None, None, pipeline, CommandExecutionError, None])
  294. mock_create = MagicMock(side_effect=[True, True, False, CommandExecutionError])
  295. with patch.dict(elasticsearch.__salt__, {'elasticsearch.pipeline_get': mock_get,
  296. 'elasticsearch.pipeline_create': mock_create}):
  297. self.assertDictEqual(elasticsearch.pipeline_present(name, {"test": "key"}), ret)
  298. ret.update({'comment': "Successfully replaced pipeline foo", 'changes': {'old': {"test": "key"}, 'new': {"test2": "key"}}})
  299. self.assertDictEqual(elasticsearch.pipeline_present(name, {"test2": "key"}), ret)
  300. ret.update({'comment': "Successfully created pipeline foo", 'changes': {'new': {"test2": "key"}}})
  301. self.assertDictEqual(elasticsearch.pipeline_present(name, {"test2": "key"}), ret)
  302. ret.update({'comment': 'Cannot create pipeline foo, False', 'result': False})
  303. self.assertDictEqual(elasticsearch.pipeline_present(name, {"test2": "key"}), ret)
  304. with patch.dict(elasticsearch.__opts__, {'test': True}):
  305. ret.update({'comment': "Pipeline foo does not exist and will be created", 'result': None, 'changes': {'new': {"test2": "key"}}})
  306. self.assertDictEqual(elasticsearch.pipeline_present(name, {"test2": "key"}), ret)
  307. ret.update({'comment': "Pipeline foo exists with wrong configuration and will be overridden", 'result': None, 'changes': {'old': {"test": "key"}, 'new': {"test2": "key"}}})
  308. self.assertDictEqual(elasticsearch.pipeline_present(name, {"test2": "key"}), ret)
  309. ret.update({'comment': '', 'result': False, 'changes': {}})
  310. self.assertDictEqual(elasticsearch.pipeline_present(name, {}), ret)
  311. ret.update({'comment': '', 'result': False, 'changes': {}})
  312. self.assertDictEqual(elasticsearch.pipeline_present(name, {}), ret)
  313. # 'search_template_absent' function tests: 1
  314. def test_search_template_absent(self):
  315. '''
  316. Test to manage a elasticsearch search template.
  317. '''
  318. name = 'foo'
  319. template = {"template": '{"test": "key"}'}
  320. ret = {'name': name,
  321. 'result': True,
  322. 'comment': 'Search template foo is already absent',
  323. 'changes': {}}
  324. mock_get = MagicMock(side_effect=[None, template, template, template, CommandExecutionError, template])
  325. mock_delete = MagicMock(side_effect=[True, False, CommandExecutionError])
  326. with patch.dict(elasticsearch.__salt__, {'elasticsearch.search_template_get': mock_get,
  327. 'elasticsearch.search_template_delete': mock_delete}):
  328. self.assertDictEqual(elasticsearch.search_template_absent(name), ret)
  329. ret.update({'comment': 'Successfully removed search template foo', 'changes': {"old": {"test": "key"}}})
  330. self.assertDictEqual(elasticsearch.search_template_absent(name), ret)
  331. ret.update({'comment': 'Failed to remove search template foo for unknown reasons', 'result': False, 'changes': {}})
  332. self.assertDictEqual(elasticsearch.search_template_absent(name), ret)
  333. with patch.dict(elasticsearch.__opts__, {'test': True}):
  334. ret.update({'comment': "Search template foo will be removed", 'result': None, 'changes': {"old": {"test": "key"}}})
  335. self.assertDictEqual(elasticsearch.search_template_absent(name), ret)
  336. ret.update({'comment': '', 'result': False, 'changes': {}})
  337. self.assertDictEqual(elasticsearch.search_template_absent(name), ret)
  338. ret.update({'comment': '', 'result': False, 'changes': {}})
  339. self.assertDictEqual(elasticsearch.search_template_absent(name), ret)
  340. # 'pipeline_present' function tests: 1
  341. def test_search_template_present(self):
  342. '''
  343. Test to manage a elasticsearch search template.
  344. '''
  345. name = 'foo'
  346. template = {"template": '{"test": "key"}'}
  347. ret = {'name': name,
  348. 'result': True,
  349. 'comment': 'Search template foo is already present',
  350. 'changes': {}}
  351. mock_get = MagicMock(side_effect=[template, template, None, None, None, template, CommandExecutionError, None])
  352. mock_create = MagicMock(side_effect=[True, True, False, CommandExecutionError])
  353. with patch.dict(elasticsearch.__salt__, {'elasticsearch.search_template_get': mock_get,
  354. 'elasticsearch.search_template_create': mock_create}):
  355. self.assertDictEqual(elasticsearch.search_template_present(name, {"test": "key"}), ret)
  356. ret.update({'comment': "Successfully replaced search template foo", 'changes': {'old': {"test": "key"}, 'new': {"test2": "key"}}})
  357. self.assertDictEqual(elasticsearch.search_template_present(name, {"test2": "key"}), ret)
  358. ret.update({'comment': "Successfully created search template foo", 'changes': {'new': {"test2": "key"}}})
  359. self.assertDictEqual(elasticsearch.search_template_present(name, {"test2": "key"}), ret)
  360. ret.update({'comment': 'Cannot create search template foo, False', 'result': False})
  361. self.assertDictEqual(elasticsearch.search_template_present(name, {"test2": "key"}), ret)
  362. with patch.dict(elasticsearch.__opts__, {'test': True}):
  363. ret.update({'comment': "Search template foo does not exist and will be created", 'result': None, 'changes': {'new': {"test2": "key"}}})
  364. self.assertDictEqual(elasticsearch.search_template_present(name, {"test2": "key"}), ret)
  365. ret.update({'comment': "Search template foo exists with wrong configuration and will be overridden", 'result': None, 'changes': {'old': {"test": "key"}, 'new': {"test2": "key"}}})
  366. self.assertDictEqual(elasticsearch.search_template_present(name, {"test2": "key"}), ret)
  367. ret.update({'comment': '', 'result': False, 'changes': {}})
  368. self.assertDictEqual(elasticsearch.search_template_present(name, {}), ret)
  369. ret.update({'comment': '', 'result': False, 'changes': {}})
  370. self.assertDictEqual(elasticsearch.search_template_present(name, {}), ret)