starcluster.tests

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

# Source Code for Package starcluster.tests

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