diff options
author | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2017-01-02 16:37:16 +0100 |
---|---|---|
committer | Elena ``of Valhalla'' Grandi <valhalla@trueelena.org> | 2017-01-02 16:37:16 +0100 |
commit | b2d8d7f2e936c4862ca5554bb5ffe853a65c04e7 (patch) | |
tree | 5285246e203c333cb7b201cc7c9a740296b66bea /tests/test_collection.py | |
parent | 76cc206a8735a22ba605ceb03d48e09984bb43fd (diff) |
Move collection initialization to Collection
Diffstat (limited to 'tests/test_collection.py')
-rw-r--r-- | tests/test_collection.py | 35 |
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) |