aboutsummaryrefslogtreecommitdiff
path: root/tests/test_derivatives.py
blob: 0218f3dff258057ce37cacb9bca866ede0d1475b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import shutil
import tempfile
import unittest

import lesana
from lesana import types
from . import utils


class DerivedType(types.LesanaString):
    """
    A custom type
    """
    name = 'derived'


class Derivative(lesana.Collection):
    """
    A class serived from lesana.Collection
    """


class testDerivatives(unittest.TestCase):
    def setUp(self):
        self.tmpdir = tempfile.mkdtemp()
        utils.copytree(
            'tests/data/derivative',
            self.tmpdir,
            dirs_exist_ok=True
        )
        self.collection = Derivative(self.tmpdir)

    def tearDown(self):
        shutil.rmtree(self.tmpdir)

    def test_load_subclasses(self):
        self.assertIsInstance(self.collection.fields['unknown'], DerivedType)


if __name__ == '__main__':
    unittest.main()