-
Notifications
You must be signed in to change notification settings - Fork 21
/
test_settings.py
57 lines (46 loc) · 2.36 KB
/
test_settings.py
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
# Copyright (C) 2019 Greenbone Networks GmbH
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import unittest
from autohooks.settings import Mode
class ModeTestCase(unittest.TestCase):
def test_get_effective_mode(self):
self.assertEqual(Mode.PIPENV.get_effective_mode(), Mode.PIPENV)
self.assertEqual(Mode.PYTHONPATH.get_effective_mode(), Mode.PYTHONPATH)
self.assertEqual(Mode.POETRY.get_effective_mode(), Mode.POETRY)
self.assertEqual(Mode.UNDEFINED.get_effective_mode(), Mode.PYTHONPATH)
self.assertEqual(Mode.UNKNOWN.get_effective_mode(), Mode.PYTHONPATH)
def test_get_pipenv_mode_from_string(self):
self.assertEqual(Mode.from_string('pipenv'), Mode.PIPENV)
self.assertEqual(Mode.from_string('PIPENV'), Mode.PIPENV)
def test_get_pythonpath_mode_from_string(self):
self.assertEqual(Mode.from_string('pythonpath'), Mode.PYTHONPATH)
self.assertEqual(Mode.from_string('PYTHONPATH'), Mode.PYTHONPATH)
def test_get_poetry_mode_from_string(self):
self.assertEqual(Mode.from_string('poetry'), Mode.POETRY)
self.assertEqual(Mode.from_string('POETRY'), Mode.POETRY)
def test_get_invalid_mode_from_string(self):
self.assertEqual(Mode.from_string('foo'), Mode.UNKNOWN)
self.assertEqual(Mode.from_string(None), Mode.UNDEFINED)
self.assertEqual(Mode.from_string(''), Mode.UNDEFINED)
def test_string_conversion(self):
self.assertEqual(str(Mode.PIPENV), 'pipenv')
self.assertEqual(str(Mode.PYTHONPATH), 'pythonpath')
self.assertEqual(str(Mode.POETRY), 'poetry')
self.assertEqual(str(Mode.UNKNOWN), 'unknown')
self.assertEqual(str(Mode.UNDEFINED), 'undefined')
if __name__ == '__main__':
unittest.main()