diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2018-07-24 14:41:22 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-24 14:41:22 -0700 |
commit | 4cba47a8143059a68c904e40e575fc4d493bf6de (patch) | |
tree | 8800830a4dea35c17b951984b88c39dfafd47a09 /tests | |
parent | bf891cec60ea4b535261d976a124bd5b683ce437 (diff) | |
parent | 6ab2f27b2c15aab4f340b7770598235b155a06b7 (diff) |
Merge pull request #1256 from pazz/namedqueries
New buffer type for notmuch's named query strings
Diffstat (limited to 'tests')
-rw-r--r-- | tests/db/manager_test.py | 53 | ||||
-rw-r--r-- | tests/settings/theme_test.py | 4 |
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/db/manager_test.py b/tests/db/manager_test.py new file mode 100644 index 00000000..e675aed4 --- /dev/null +++ b/tests/db/manager_test.py @@ -0,0 +1,53 @@ +# Copyright (C) 2018 Patrick Totzke +# This file is released under the GNU GPL, version 3 or a later revision. +# For further details see the COPYING file + +"""Test suite for alot.db.manager module.""" + +import tempfile +import textwrap +import os +import shutil + +from alot.db.manager import DBManager +from alot.settings.const import settings +from notmuch import Database + +from .. import utilities + + +class TestDBManager(utilities.TestCaseClassCleanup): + + @classmethod + def setUpClass(cls): + + # create temporary notmuch config + with tempfile.NamedTemporaryFile(mode='w+', delete=False) as f: + f.write(textwrap.dedent("""\ + [maildir] + synchronize_flags = true + """)) + cls.notmuch_config_path = f.name + cls.addClassCleanup(os.unlink, f.name) + + # define an empty notmuch database in a temporary directory + cls.dbpath = tempfile.mkdtemp() + cls.db = Database(path=cls.dbpath, create=True) + cls.db.close() + cls.manager = DBManager(cls.dbpath) + + # clean up temporary database + cls.addClassCleanup(cls.manager.kill_search_processes) + cls.addClassCleanup(shutil.rmtree, cls.dbpath) + + # let global settings manager read our temporary notmuch config + settings.read_notmuch_config(cls.notmuch_config_path) + + def test_save_named_query(self): + alias = 'key' + querystring = 'query string' + self.manager.save_named_query(alias, querystring) + self.manager.flush() + + named_queries_dict = self.manager.get_named_queries() + self.assertDictEqual(named_queries_dict, {alias: querystring}) diff --git a/tests/settings/theme_test.py b/tests/settings/theme_test.py index b3f90661..c74de50e 100644 --- a/tests/settings/theme_test.py +++ b/tests/settings/theme_test.py @@ -34,6 +34,10 @@ DUMMY_THEME = """\ line_even = '', '', '', '', '', '' line_focus = '', '', '', '', '', '' line_odd = '', '', '', '', '', '' +[namedqueries] + line_even = '', '', '', '', '', '' + line_focus = '', '', '', '', '', '' + line_odd = '', '', '', '', '', '' [search] focus = '', '', '', '', '', '' normal = '', '', '', '', '', '' |