Skip to content
Snippets Groups Projects
Commit 0b09d09f authored by Jonas's avatar Jonas
Browse files

Added config parameters for IS + Test

parent 2a0b1d97
No related branches found
No related tags found
1 merge request!29Resolve "Initial Publish uptime of CS instance to IS"
......@@ -50,6 +50,20 @@ ers_warning: "mts"
ers_error: "mts"
ers_debug: "mts"
########## VARIABLES FOR IS ##########
# On / Off switch for IS
IS_enabled: False
# Partition to publish to
IS_partition: "initial"
# IS Server to publish to
IS_server: "RunParams"
# Publication Period (time between updates)
IS_publication_period: 5
########## METADATA DATABASE ##########
# Oracle connection string
......
......@@ -17,12 +17,46 @@ class TestConfigHolder(unittest.TestCase):
def setUpClass(self):
self.thisDir = os.path.dirname(__file__)
self.templateName = "template.cfg"
self.cfgTemplate = os.path.abspath(os.path.join(self.thisDir, "../../Configs/" + self.templateName))
self.cfgTemplatePath = os.path.abspath(os.path.join(self.thisDir, "../../Configs/" + self.templateName))
self.cfgTest_path = os.path.abspath(os.path.join(self.thisDir, "funcTestConf.cfg"))
@classmethod
def tearDownClass(self):
os.remove(self.cfgTest_path)
def test_it_should_save_config_file_name(self):
cfg = ConfigHolder(self.cfgTemplate)
cfg = ConfigHolder(self.cfgTemplatePath)
self.assertEquals(self.templateName, cfg.FileName)
def test_it_should_save_IS_parameters(self):
cfgTemplateFile = open(self.cfgTemplatePath, "r")
# I make a new file
cfgTest = open(self.cfgTest_path, "w")
# And I copy the content and replaces the directories with my own dirs
custom_cfg_lines = {
"IS_enabled: ": "IS_enabled: {}\n".format(True),
"IS_partition: ": "IS_partition: \'{}\'\n".format("testPartition"),
"IS_server: ": "IS_server: \'{}\'\n".format("testServer"),
"IS_publication_period: ": "IS_publication_period: {}\n".format(200),
}
# And I copy the content and replaces the directories with my own dirs
for line in cfgTemplateFile:
for key, value in custom_cfg_lines.iteritems():
if line.find(key) is not -1:
line = value
cfgTest.write(line)
cfgTest.close()
cfgTemplateFile.close()
cfg = ConfigHolder(self.cfgTest_path)
self.assertEquals(True, cfg.IS_enabled)
self.assertEquals("testPartition", cfg.IS_partition)
self.assertEquals("testServer", cfg.IS_server)
self.assertEquals(200, cfg.IS_publication_period)
if __name__ == '__main__':
unittest.main()
......
......@@ -118,6 +118,31 @@ class ConfigHolder:
except AttributeError:
self.ers_debug = ''
########## Variables for IS ##########
# On / Off switch for ERS
try:
self.IS_enabled = cfg.IS_enabled
except AttributeError:
self.IS_enabled = False
# Partition to publish to
try:
self.IS_partition = cfg.IS_partition
except AttributeError:
self.IS_partition = 'initial'
# IS Server to publish to
try:
self.IS_server = cfg.IS_server
except AttributeError:
self.IS_server = 'RunParams'
# Publication Period (seconds between updates)
try:
self.IS_publication_period = cfg.IS_publication_period
except AttributeError:
self.IS_publication_period = 5
########## METADATA DATABASE ##########
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment