示例#1
0
 def test_do_something_with_int_value(self):
     self.create_indices(10)
     evar = random_envvar(8)
     os.environ[evar] = "1234"
     dollar = '${' + evar + '}'
     self.write_config(
         self.args['configfile'],
         testvars.client_config_envvars.format(host, port, dollar)
     )
     cfg = curator.get_yaml(self.args['configfile'])
     self.assertEqual(
         cfg['client']['timeout'],
         os.environ.get(evar)
     )
     self.write_config(self.args['actionfile'],
         testvars.delete_proto.format(
             'age', 'name', 'older', '\'%Y.%m.%d\'', 'days', 5, ' ', ' ', ' '
         )
     )
     test = clicktest.CliRunner()
     result = test.invoke(
                 curator.cli,
                 [
                     '--config', self.args['configfile'],
                     self.args['actionfile']
                 ],
                 )
     self.assertEquals(5, len(curator.get_indices(self.client)))
     del os.environ[evar]
示例#2
0
 def test_not_present(self):
     evar = random_envvar(8)
     dollar = '${' + evar + '}'
     self.write_config(
         self.args['configfile'],
         testvars.client_config_envvars.format(dollar, port, 30)
     )
     cfg = curator.get_yaml(self.args['configfile'])
     self.assertIsNone(cfg['client']['hosts'])
示例#3
0
 def test_present(self):
     evar = random_envvar(8)
     os.environ[evar] = "1234"
     dollar = '${' + evar + '}'
     self.write_config(
         self.args['configfile'],
         testvars.client_config_envvars.format(dollar, port, 30)
     )
     cfg = curator.get_yaml(self.args['configfile'])
     self.assertEqual(
         cfg['client']['hosts'],
         os.environ.get(evar)
     )
     del os.environ[evar]
示例#4
0
 def test_read_file_corrupt_fail(self):
     with self.assertRaises(SystemExit) as get:
         curator.get_yaml(self.args['invalid_yaml'])
     self.assertEqual(get.exception.code, 1)
示例#5
0
 def test_read_file_pass(self):
     cfg = curator.get_yaml(self.args['yamlfile'])
     self.assertEqual('localhost', cfg['client']['hosts'])
     self.assertEqual(9200, cfg['client']['port'])
示例#6
0
 def test_read_file_corrupt_fail(self):
     with self.assertRaises(SystemExit) as get:
         curator.get_yaml(self.args['invalid_yaml'])
     self.assertEqual(get.exception.code, 1)
示例#7
0
 def test_read_file_pass(self):
     cfg = curator.get_yaml(self.args['yamlfile'])
     self.assertEqual('localhost', cfg['client']['hosts'])
     self.assertEqual(9200, cfg['client']['port'])