File: test_appfs.py

package info (click to toggle)
python-fs 2.4.16-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,944 kB
  • sloc: python: 13,048; makefile: 226; sh: 3
file content (85 lines) | stat: -rw-r--r-- 1,909 bytes parent folder | download
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from __future__ import unicode_literals

import shutil
import six
import tempfile
import unittest

try:
    from unittest import mock
except ImportError:
    import mock

import fs.test
from fs import appfs


class _TestAppFS(fs.test.FSTestCases):

    AppFS = None

    @classmethod
    def setUpClass(cls):
        super(_TestAppFS, cls).setUpClass()
        cls.tmpdir = tempfile.mkdtemp()

    @classmethod
    def tearDownClass(cls):
        shutil.rmtree(cls.tmpdir)

    def make_fs(self):
        with mock.patch(
            f"platformdirs.PlatformDirs.{self.AppFS.app_dir}",
            new_callable=mock.PropertyMock,
            return_value=tempfile.mkdtemp(),
        ):
            return self.AppFS("fstest", "willmcgugan", "1.0")

    if six.PY2:

        def test_repr(self):
            self.assertEqual(
                repr(self.fs),
                "{}(u'fstest', author=u'willmcgugan', version=u'1.0')".format(
                    self.AppFS.__name__
                ),
            )

    else:

        def test_repr(self):
            self.assertEqual(
                repr(self.fs),
                "{}('fstest', author='willmcgugan', version='1.0')".format(
                    self.AppFS.__name__
                ),
            )

    def test_str(self):
        self.assertEqual(
            str(self.fs), "<{} 'fstest'>".format(self.AppFS.__name__.lower())
        )


class TestUserDataFS(_TestAppFS, unittest.TestCase):
    AppFS = appfs.UserDataFS


class TestUserConfigFS(_TestAppFS, unittest.TestCase):
    AppFS = appfs.UserConfigFS


class TestUserCacheFS(_TestAppFS, unittest.TestCase):
    AppFS = appfs.UserCacheFS


class TestSiteDataFS(_TestAppFS, unittest.TestCase):
    AppFS = appfs.SiteDataFS


class TestSiteConfigFS(_TestAppFS, unittest.TestCase):
    AppFS = appfs.SiteConfigFS


class TestUserLogFS(_TestAppFS, unittest.TestCase):
    AppFS = appfs.UserLogFS