diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-11-12 12:17:49 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2020-11-12 12:17:49 +0100 |
commit | 91c0aec5a99194f6fd1927b80354a56e135c1baf (patch) | |
tree | b719392d4d650776e454fc073c0a13e928eafe9d /archaeological_context_records | |
parent | ee190a72c5cbba24c97fad63cc5b55d9d47c08a2 (diff) | |
download | Ishtar-91c0aec5a99194f6fd1927b80354a56e135c1baf.tar.bz2 Ishtar-91c0aec5a99194f6fd1927b80354a56e135c1baf.zip |
Tests: search hierarchic text test
Diffstat (limited to 'archaeological_context_records')
-rw-r--r-- | archaeological_context_records/tests.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py index 0ffe04c3a..cd547bc07 100644 --- a/archaeological_context_records/tests.py +++ b/archaeological_context_records/tests.py @@ -43,7 +43,7 @@ from ishtar_common.tests import WizardTest, WizardTestFormData as FormData, \ create_superuser, create_user, TestCase, AutocompleteTestBase, AcItem, \ CONTEXT_RECORD_FIXTURES, CONTEXT_RECORD_TOWNS_FIXTURES, \ OPERATION_TOWNS_FIXTURES, GenericSerializationTest, COMMON_FIXTURES, \ - WAREHOUSE_FIXTURES + WAREHOUSE_FIXTURES, SearchText from archaeological_operations.models import Operation from archaeological_operations.serializers import operation_serialization @@ -489,8 +489,9 @@ class ContextRecordTest(ContextRecordInit, TestCase): self.assertEqual(obj.datings.count(), 2) -class ContextRecordSearchTest(ContextRecordInit, TestCase): +class ContextRecordSearchTest(ContextRecordInit, TestCase, SearchText): fixtures = CONTEXT_RECORD_TOWNS_FIXTURES + SEARCH_URL = 'get-contextrecord' def setUp(self): IshtarSiteProfile.objects.create() @@ -618,7 +619,7 @@ class ContextRecordSearchTest(ContextRecordInit, TestCase): lines = [line for line in content.split('\n') if line] self.assertEqual(len(lines), 3) - def testUnitHierarchicSearch(self): + def test_unit_hierarchic_search(self): cr = self.context_records[0] c = Client() @@ -659,7 +660,16 @@ class ContextRecordSearchTest(ContextRecordInit, TestCase): content = response.content.decode() self.assertEqual(json.loads(content)['recordsTotal'], 1) - def testPeriodHierarchicSearch(self): + # test on text search + material_key = str(pgettext_lazy("key for text search", 'unit-type')) + result = [ + ('{}="{}"'.format(material_key, str(neg)), 1), + ('{}="{}"'.format(material_key, str(dest)), 0), + ('{}="{}"'.format(material_key, str(su)), 1), + ] + self._test_search(c, result, context="Text unit type search") + + def test_period_hierarchic_search(self): cr = self.context_records[0] c = Client() @@ -700,6 +710,15 @@ class ContextRecordSearchTest(ContextRecordInit, TestCase): content = response.content.decode() self.assertEqual(json.loads(content)['recordsTotal'], 1) + # test on text search + period_key = str(pgettext_lazy("key for text search", 'datings-period')) + result = [ + ('{}="{}"'.format(period_key, str(final_neo)), 1), + ('{}="{}"'.format(period_key, str(recent_neo)), 0), + ('{}="{}"'.format(period_key, str(neo)), 1), + ] + self._test_search(c, result, context="Text period search") + class ContextRecordPermissionTest(ContextRecordInit, TestCase): fixtures = CONTEXT_RECORD_TOWNS_FIXTURES |