From ad04af4812bbdebe47ce58333cc48332197e61b1 Mon Sep 17 00:00:00 2001 From: Elena ``of Valhalla'' Grandi Date: Sat, 10 Dec 2016 22:20:14 +0100 Subject: Open a lesana directory --- tests/data/empty/.gitignore | 0 tests/data/simple/schema.yaml | 12 ++++++++++++ tests/test_collection.py | 28 ++++++++++++++++++++-------- 3 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 tests/data/empty/.gitignore create mode 100644 tests/data/simple/schema.yaml (limited to 'tests') diff --git a/tests/data/empty/.gitignore b/tests/data/empty/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/tests/data/simple/schema.yaml b/tests/data/simple/schema.yaml new file mode 100644 index 0000000..177aa92 --- /dev/null +++ b/tests/data/simple/schema.yaml @@ -0,0 +1,12 @@ +name: "Simple lesana collection" +lang: 'english' +fields: + - name: name + type: string + index: free + - name: description + type: text + index: free + - name: position + type: string + index: facet diff --git a/tests/test_collection.py b/tests/test_collection.py index 63820d5..64dd293 100644 --- a/tests/test_collection.py +++ b/tests/test_collection.py @@ -1,10 +1,22 @@ -from __future__ import division -from __future__ import absolute_import -from __future__ import print_function -from __future__ import unicode_literals - +import os.path +import shutil import unittest -class testCollection(unittest.TestCase): - def test_noting(self): - pass +import lesana + + +class testCollectionLoading(unittest.TestCase): + def tearDown(self): + shutil.rmtree(os.path.join(self.collection.basedir, '.lesana')) + + def test_empty(self): + self.collection = lesana.Collection('tests/data/empty') + self.assertIsNone(self.collection.schema) + self.assertIsNotNone(self.collection.cache) + + def test_simple(self): + self.collection = lesana.Collection('tests/data/simple') + self.assertIsNotNone(self.collection.schema) + self.assertEqual(self.collection.schema['name'], "Simple lesana collection") + self.assertEqual(len(self.collection.schema['fields']), 3) + self.assertIsNotNone(self.collection.cache) -- cgit v1.2.3