Parcourir la source

[2136] added config setup

Naoki Kambe il y a 12 ans
Parent
commit
97a53cf690
2 fichiers modifiés avec 7 ajouts et 1 suppressions
  1. 6 1
      src/bin/stats/stats.py.in
  2. 1 0
      src/bin/stats/tests/b10-stats_test.py

+ 6 - 1
src/bin/stats/stats.py.in

@@ -1,6 +1,6 @@
 #!@PYTHON@
 
-# Copyright (C) 2010, 2011  Internet Systems Consortium.
+# Copyright (C) 2010, 2011, 2012  Internet Systems Consortium.
 #
 # Permission to use, copy, modify, and distribute this software for any
 # purpose with or without fee is hereby granted, provided that the above
@@ -145,6 +145,11 @@ class Stats:
             except AttributeError:
                 raise StatsError(STATS_UNKNOWN_COMMAND_IN_SPEC, cmd["command_name"])
         self.mccs.start()
+        # setup my config
+        self.config = dict([
+                (itm['item_name'], self.mccs.get_value(itm['item_name'])[0])
+                for itm in self.mccs.get_module_spec().get_config_spec()
+                ])
 
     def start(self):
         """

+ 1 - 0
src/bin/stats/tests/b10-stats_test.py

@@ -169,6 +169,7 @@ class TestStats(unittest.TestCase):
         self.assertTrue('command_show' in self.stats.callbacks)
         self.assertTrue('command_showschema' in self.stats.callbacks)
         self.assertTrue('command_set' in self.stats.callbacks)
+        self.assertEqual(self.stats.config['poll-interval'], 60)
 
     def test_init_undefcmd(self):
         spec_str = """\