Skip to content
Snippets Groups Projects

Resolve "Initial Publish uptime of CS instance to IS"

1 file
+ 33
14
Compare changes
  • Side-by-side
  • Inline
@@ -29,12 +29,6 @@ class TestConfigHolder(unittest.TestCase):
@@ -29,12 +29,6 @@ class TestConfigHolder(unittest.TestCase):
self.assertEquals(self.templateName, cfg.FileName)
self.assertEquals(self.templateName, cfg.FileName)
def test_it_should_save_IS_parameters(self):
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 = {
custom_cfg_lines = {
"IS_enabled: ": "IS_enabled: {}\n".format(True),
"IS_enabled: ": "IS_enabled: {}\n".format(True),
"IS_partition: ": "IS_partition: \'{}\'\n".format("testPartition"),
"IS_partition: ": "IS_partition: \'{}\'\n".format("testPartition"),
@@ -42,21 +36,46 @@ class TestConfigHolder(unittest.TestCase):
@@ -42,21 +36,46 @@ class TestConfigHolder(unittest.TestCase):
"IS_publication_period: ": "IS_publication_period: {}\n".format(200),
"IS_publication_period: ": "IS_publication_period: {}\n".format(200),
}
}
# And I copy the content and replaces the directories with my own dirs
make_custom_config(self.cfgTemplatePath, self.cfgTest_path, custom_cfg_lines)
 
 
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)
 
 
def test_it_should_save_IS_default_parameters_if_none_configured(self):
 
custom_cfg_lines = {
 
"IS_enabled: ": "\n",
 
"IS_partition: ": "\n",
 
"IS_server: ": "\n",
 
"IS_publication_period: ": "\n",
 
}
 
 
make_custom_config(self.cfgTemplatePath, self.cfgTest_path, custom_cfg_lines)
 
 
cfg = ConfigHolder(self.cfgTest_path)
 
self.assertEquals(False, cfg.IS_enabled)
 
self.assertEquals("initial", cfg.IS_partition)
 
self.assertEquals("RunParams", cfg.IS_server)
 
self.assertEquals(5, cfg.IS_publication_period)
 
 
def make_custom_config(original_conf_path, custom_conf_path, modifications):
 
 
cfgTest = open(custom_conf_path, "w")
 
cfgTemplateFile = open(original_conf_path, "r")
 
 
# And I copy the content and add my own modifications
for line in cfgTemplateFile:
for line in cfgTemplateFile:
for key, value in custom_cfg_lines.iteritems():
for key, value in modifications.iteritems():
if line.find(key) is not -1:
if line.find(key) is not -1:
line = value
line = value
cfgTest.write(line)
cfgTest.write(line)
 
 
## close files
cfgTest.close()
cfgTest.close()
cfgTemplateFile.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__':
if __name__ == '__main__':
unittest.main()
unittest.main()
Loading