|
17 | 17 |
|
18 | 18 | import factories |
19 | 19 |
|
| 20 | +from ..versions import ELASTICSEARCH_GTE_5_0, ELASTICSEARCH_GTE_6_0 |
20 | 21 | from .base import BaseRestFrameworkTestCase |
21 | 22 | from .data_mixins import AddressesMixin |
22 | 23 |
|
@@ -341,10 +342,16 @@ def test_suggesters_on_empty_index(self): |
341 | 342 | {} |
342 | 343 | ) |
343 | 344 | self.assertEqual(response.status_code, status.HTTP_200_OK) |
344 | | - self.assertFalse(bool(response.data)) |
345 | | - # self.assertFalse(bool(response.data.get('name_suggest__completion'))) |
| 345 | + |
| 346 | + if ELASTICSEARCH_GTE_6_0: |
| 347 | + self.assertFalse(bool(response.data)) |
| 348 | + else: |
| 349 | + self.assertFalse( |
| 350 | + bool(response.data.get('name_suggest__completion')) |
| 351 | + ) |
346 | 352 |
|
347 | 353 |
|
| 354 | +@unittest.skipIf(not ELASTICSEARCH_GTE_5_0, 'ES >=5.x only') |
348 | 355 | @pytest.mark.django_db |
349 | 356 | class TestContextSuggesters(BaseRestFrameworkTestCase, AddressesMixin): |
350 | 357 | """Test context suggesters.""" |
@@ -392,12 +399,12 @@ def setUpClass(cls): |
392 | 399 | cls.books.append( |
393 | 400 | factories.BookFactory( |
394 | 401 | title='Ccccc Eeee', |
395 | | - summary='He took his vorpal sword in his hand,' |
| 402 | + summary='She took his zorpal blade in his hand,' |
396 | 403 | 'Long time the manxome foe he sought --' |
397 | 404 | 'So rested he by the Tumtum tree,' |
398 | 405 | 'And stood awhile in thought.', |
399 | | - publisher__name='Mario', |
400 | | - publisher__country='US', |
| 406 | + # publisher__name='Mario', |
| 407 | + # publisher__country='US', |
401 | 408 | ) |
402 | 409 | ) |
403 | 410 |
|
@@ -544,7 +551,11 @@ def test_suggesters_completion_context(self): |
544 | 551 | 'Harazatyan', |
545 | 552 | ], |
546 | 553 | 'filters': { |
547 | | - 'title_suggest_loc': '40__44__1000km', |
| 554 | + 'title_suggest_loc': ( |
| 555 | + '40__44__1000km' |
| 556 | + if ELASTICSEARCH_GTE_6_0 |
| 557 | + else '40__44' |
| 558 | + ), |
548 | 559 | } |
549 | 560 | }, |
550 | 561 | }, |
|
0 commit comments