source: src/mapservice/tests/test_config.py@ 3db3d13

debian/bullseye
Last change on this file since 3db3d13 was 7be94aa, checked in by Joachim Langenbach <joachim.langenbach@…>, 7 years ago
  • Added yapf style config (src/python-style.yapf)
    • Updated all files to the yapf formatted version
  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[096625e]1'''
2 Copyright (C) 2020 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16'''
17
18import unittest
19import tempfile
20import yaml
[adda9f2]21import os
[096625e]22
[adda9f2]23from gnuboat_mapservice.server_impl import Config
[096625e]24
[7be94aa]25
[096625e]26class TestConfig(unittest.TestCase):
[7be94aa]27 def test_config_from_file(self):
28 """Test case load config from file
[096625e]29 """
[7be94aa]30 new_config = {'TESTING': True, 'DOES_NOT_EXISTS': 1234}
31
32 config = Config.Config()
33 assert config.TESTING == False
34
35 config_file = tempfile.NamedTemporaryFile(
36 mode='w', prefix='gnuboat-test-config', delete=False
37 )
38 yaml.dump(
39 new_config,
40 config_file,
41 default_flow_style=False,
42 allow_unicode=True
43 )
44 config_file.close()
45 config_file = os.path.join(tempfile.gettempdir(), config_file.name)
46
47 config = Config.load_from_file(config_file)
48 assert config.TESTING == True
49 assert config.DOES_NOT_EXISTS == 1234
50 os.remove(config_file)
51
[096625e]52
53if __name__ == '__main__':
54 unittest.main()
Note: See TracBrowser for help on using the repository browser.