summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/data/complex/settings.yaml3
-rw-r--r--tests/test_collection.py12
-rw-r--r--tests/test_commands.py18
3 files changed, 33 insertions, 0 deletions
diff --git a/tests/data/complex/settings.yaml b/tests/data/complex/settings.yaml
index f4ad574..09e9c98 100644
--- a/tests/data/complex/settings.yaml
+++ b/tests/data/complex/settings.yaml
@@ -63,3 +63,6 @@ fields:
- name: price
type: decimal
precision: 2
+search_aliases:
+ nice: '(category:first OR category:second)'
+ bad: category:third
diff --git a/tests/test_collection.py b/tests/test_collection.py
index de349ed..1400f57 100644
--- a/tests/test_collection.py
+++ b/tests/test_collection.py
@@ -550,6 +550,18 @@ class testComplexCollection(unittest.TestCase):
entry = self.collection.entry_from_eid(eid)
self.assertEqual(entry.data['price'], "1.90")
+ def test_search_aliases(self):
+ search_query = "{{ nice }}"
+ search_query = self.collection.render_query_template(search_query)
+ print("QUERY IS", search_query)
+ self.collection.start_search(search_query)
+ res = self.collection.get_search_results()
+ matches = list(res)
+ self.assertEqual(len(matches), 2)
+ matches_ids = [m.eid for m in matches]
+ self.assertIn('8e9fa1ed3c1b4a30a6be7a98eda0cfa7', matches_ids)
+ self.assertIn('5084bc6e94f24dc6976629282ef30419', matches_ids)
+
class testCollectionWithErrors(unittest.TestCase):
def setUp(self):
diff --git a/tests/test_commands.py b/tests/test_commands.py
index 1a7d83b..91a8894 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -115,6 +115,7 @@ class testCommandsSimple(unittest.TestCase, CommandsMixin):
'offset': None,
'pagesize': None,
'sort': None,
+ 'expand_query_template': False,
'all': False,
}
streams = self._run_command(command.Search(), args)
@@ -205,6 +206,23 @@ class testCommandsComplex(unittest.TestCase, CommandsMixin):
self.assertIn('this: 1', streams['stdout'].getvalue())
self.assertEqual(streams['stderr'].getvalue(), '')
+ def test_search_template(self):
+ args = {
+ 'collection': self.tmpdir.name,
+ 'git': True,
+ 'template': False,
+ 'query': '{{ nice }}',
+ 'expand_query_template': True,
+ 'offset': None,
+ 'pagesize': None,
+ 'sort': None,
+ 'all': False,
+ }
+ streams = self._run_command(command.Search(), args)
+ self.assertIn('8e9fa1ed', streams['stdout'].getvalue())
+ self.assertIn('5084bc6e', streams['stdout'].getvalue())
+ self.assertEqual(streams['stderr'].getvalue(), '')
+
if __name__ == '__main__':
unittest.main()