source: src/mapservice/tests/test_config.py@ a2b8052

debian/bullseye
Last change on this file since a2b8052 was ae2ff15, checked in by Joachim Langenbach <joachim.langenbach@…>, 7 years ago
  • Fixed testing environment
    • Fixed some issues in the API and it's serving
  • Property mode set to 100644
File size: 1.5 KB
Line 
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
21import os
22
23from gnuboat_mapservice.server_impl import Config
24
25class TestConfig(unittest.TestCase):
26 def test_config_from_file(self):
27 """Test case load config from file
28 """
29 new_config = {
30 'TESTING': True,
31 'DOES_NOT_EXISTS': 1234
32 }
33
34 config = Config.Config()
35 assert config.TESTING == False
36
37 config_file = tempfile.NamedTemporaryFile(mode='w', prefix='gnuboat-test-config', delete=False)
38 yaml.dump(new_config, config_file, default_flow_style=False, allow_unicode=True)
39 config_file.close()
40 config_file = os.path.join(tempfile.gettempdir(), config_file.name)
41
42 config = Config.load_from_file(config_file)
43 assert config.TESTING == True
44 assert config.DOES_NOT_EXISTS == 1234
45 os.remove(config_file)
46
47if __name__ == '__main__':
48 unittest.main()
Note: See TracBrowser for help on using the repository browser.