Matthew Oliver | 49c9063 | 2014-02-14 16:37:08 +1100 | [diff] [blame] | 1 | #!/usr/bin/python2 |
| 2 | # |
| 3 | # Copyright 2014 Rackspace Australia |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | # not use this file except in compliance with the License. You may obtain |
| 7 | # a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | # License for the specific language governing permissions and limitations |
| 15 | # under the License. |
| 16 | |
| 17 | |
| 18 | import os |
| 19 | import testtools |
| 20 | import yaml |
| 21 | |
| 22 | from turbo_hipster import worker_server |
| 23 | |
| 24 | CONFIG_DIR = os.path.join(os.path.dirname(__file__), 'etc') |
| 25 | with open(os.path.join(CONFIG_DIR, 'config.yaml'), 'r') as config_stream: |
| 26 | CONFIG = yaml.safe_load(config_stream) |
| 27 | |
| 28 | CONF_D_DIR = os.path.join(CONFIG_DIR, "conf.d") |
| 29 | |
| 30 | |
| 31 | class TestServerManager(testtools.TestCase): |
| 32 | def setUp(self): |
| 33 | super(TestServerManager, self).setUp() |
| 34 | self.config = CONFIG |
| 35 | |
| 36 | def tearDown(self): |
| 37 | super(TestServerManager, self).tearDown() |
| 38 | |
| 39 | def test_confd_configuration(self): |
| 40 | """ Check that the server can load in other configuration from a |
| 41 | conf.d directory """ |
| 42 | |
| 43 | def pass_function(*args, **kargs): |
| 44 | pass |
| 45 | |
| 46 | self.config["conf_d"] = CONF_D_DIR |
| 47 | |
| 48 | worker_server.Server.setup_logging = pass_function |
| 49 | serv = worker_server.Server(self.config) |
| 50 | serv_config = serv.config |
| 51 | self.assertIn("extra_configuration", serv_config) |
| 52 | self.assertEquals("testing123", serv_config["extra_configuration"]) |