summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lesana/collection.py8
-rw-r--r--lesana/data/settings.yaml2
-rw-r--r--tests/test_collection.py5
3 files changed, 14 insertions, 1 deletions
diff --git a/lesana/collection.py b/lesana/collection.py
index 92ffcbb..8be3ed0 100644
--- a/lesana/collection.py
+++ b/lesana/collection.py
@@ -328,8 +328,14 @@ class Collection(object):
skel = resource_string(
'lesana', 'data/settings.yaml'
).decode('utf-8')
+ skel_dict = ruamel.yaml.load(skel, ruamel.yaml.RoundTripLoader)
+ skel_dict['git'] = git_enabled
with open(filepath, 'w') as fp:
- fp.write(skel)
+ ruamel.yaml.dump(
+ skel_dict,
+ stream=fp,
+ Dumper=ruamel.yaml.RoundTripDumper
+ )
if edit_file:
edit_file(filepath)
if git_enabled and repo:
diff --git a/lesana/data/settings.yaml b/lesana/data/settings.yaml
index ea83e8a..31653d0 100644
--- a/lesana/data/settings.yaml
+++ b/lesana/data/settings.yaml
@@ -1,5 +1,7 @@
name: 'My Collection'
lang: english
+entry_label: '{{ uid }}: {{ name }}'
+git: true
fields:
- name: name
type: string
diff --git a/tests/test_collection.py b/tests/test_collection.py
index a197237..265db09 100644
--- a/tests/test_collection.py
+++ b/tests/test_collection.py
@@ -203,9 +203,12 @@ class testCollectionCreation(unittest.TestCase):
self.assertTrue(os.path.isdir(os.path.join(tmpdir, '.lesana')))
self.assertTrue(os.path.isfile(os.path.join(tmpdir, 'settings.yaml')))
self.assertTrue(os.path.isfile(os.path.join(tmpdir, '.gitignore')))
+ created = lesana.Collection(tmpdir)
+ self.assertTrue(created.settings['git'])
shutil.rmtree(tmpdir)
def do_nothing(*args, **kwargs):
+ # A function that does nothing instead of editing a file
pass
def test_init_edit_file(self):
@@ -233,6 +236,8 @@ class testCollectionCreation(unittest.TestCase):
self.assertTrue(os.path.isdir(os.path.join(tmpdir, '.lesana')))
self.assertTrue(os.path.isfile(os.path.join(tmpdir, 'settings.yaml')))
self.assertFalse(os.path.isfile(os.path.join(tmpdir, '.gitignore')))
+ created = lesana.Collection(tmpdir)
+ self.assertFalse(created.settings['git'])
shutil.rmtree(tmpdir)
def test_deletion(self):