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

Source Code for Package starcluster.tests

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