Package starcluster :: Package tests
[hide private]
[frames] | no frames]

Source Code for Package starcluster.tests

 1  import unittest 
 2  import tempfile 
 3  from starcluster.config import StarClusterConfig 
 4  from starcluster.tests.templates.config import config_test_template, default_config 
5 6 -class StarClusterTest(unittest.TestCase):
7 8 __cfg = None 9 10 @property
11 - def config(self):
12 """ Returns (valid) default test config """ 13 if not self.__cfg: 14 tmp_file = tempfile.NamedTemporaryFile() 15 tmp_file.write(config_test_template % default_config) 16 tmp_file.flush() 17 self.__cfg = StarClusterConfig(tmp_file.name, cache=True); self.__cfg.load() 18 return self.__cfg
19
20 - def get_custom_config(self, **kwargs):
21 """ Returns default test config modified by kwargs """ 22 tmp_file = tempfile.NamedTemporaryFile() 23 kwords = {}; 24 kwords.update(default_config) 25 kwords.update(kwargs) 26 tmp_file.write(config_test_template % kwords); 27 tmp_file.flush() 28 cfg = StarClusterConfig(tmp_file.name, cache=True); cfg.load() 29 return cfg
30