11
11
from zim.fs import File, Dir
12
from zim.config import config_file
12
from zim.config import config_file, ConfigDictFile, XDG_CONFIG_HOME
13
13
from zim.notebook import *
14
14
from zim.index import *
16
16
from zim.formats import ParseTree
18
from zim import _get_default_or_only_notebook
18
from zim import NotebookInterface, _get_default_or_only_notebook
19
19
# private, but want to check it anyway
746
746
text = ''.join(notebook.get_page(Path('page3:page1:child')).dump('wiki'))
747
747
self.assertEqual(text, 'I have backlinks !\n')
750
class TestProfiles(tests.TestCase):
753
path = self.get_tmp_name()
754
self.notebook = tests.new_notebook(fakedir=path)
756
def testProfilePreferences(self):
757
'''Test the profile is used and its preferences applied'''
758
# set up a test profile
759
file = XDG_CONFIG_HOME.file('zim/profiles/profile_TestProfile.conf')
762
assert not file.exists()
763
profile = ConfigDictFile(file)
764
profile['GtkInterface'] = {}
765
profile['General']['plugins'] = ['calendar',]
766
profile['CalendarPlugin']['embedded'] = True
767
profile['CalendarPlugin']['granularity'] = 'Week'
768
profile['CalendarPlugin']['namespace'] = 'TestProfile'
771
# se the profile name in the notebook, open it, and
772
# check that the profila was applied
773
self.notebook.config['Notebook']['profile'] = 'profile_TestProfile'
774
self.assertEqual(self.notebook.profile, 'profile_TestProfile')
775
interface = NotebookInterface(self.notebook)
776
self.assertEqual(interface.preferences.file, file)
777
self.assertTrue(len(interface.preferences['GtkInterface'].keys()) == 0)
778
self.assertTrue(len(interface.plugins) == 1)
779
self.assertEqual(interface.preferences['General']['plugins'][0],
781
self.assertTrue(interface.preferences['CalendarPlugin']['embedded'])
782
self.assertEqual(interface.preferences['CalendarPlugin']['granularity'],
784
self.assertEqual(interface.preferences['CalendarPlugin']['namespace'],