aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_collection.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/test_collection.py b/tests/test_collection.py
index a55261f..9abb3f7 100644
--- a/tests/test_collection.py
+++ b/tests/test_collection.py
@@ -1,6 +1,7 @@
import logging
import os.path
import shutil
+import tempfile
import unittest
import ruamel.yaml
@@ -130,3 +131,37 @@ class testComplexCollection(unittest.TestCase):
def test_index(self):
self.collection.update_cache()
+
+class testCollectionCreation(unittest.TestCase):
+ def test_init(self):
+ tmpdir = tempfile.mkdtemp()
+ collection = lesana.Collection.init(tmpdir)
+ self.assertIsInstance(collection, lesana.Collection)
+ self.assertTrue(os.path.isdir(os.path.join(tmpdir, '.git')))
+ 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')))
+ shutil.rmtree(tmpdir)
+
+ def do_nothing(*args, **kwargs):
+ pass
+
+ def test_init_edit_file(self):
+ tmpdir = tempfile.mkdtemp()
+ collection = lesana.Collection.init(tmpdir, edit_file=self.do_nothing)
+ self.assertIsInstance(collection, lesana.Collection)
+ self.assertTrue(os.path.isdir(os.path.join(tmpdir, '.git')))
+ 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')))
+ shutil.rmtree(tmpdir)
+
+ def test_init_no_git(self):
+ tmpdir = tempfile.mkdtemp()
+ collection = lesana.Collection.init(tmpdir, git_enabled=False)
+ self.assertIsInstance(collection, lesana.Collection)
+ self.assertFalse(os.path.isdir(os.path.join(tmpdir, '.git')))
+ 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')))
+ shutil.rmtree(tmpdir)