def test_create_recipe_check_factories_read(self): self.print_header() self.generator.add_recipe(name="test4", **dict(self.config.items("recipe_TEST4"))) self.config.set("datasource_SIMPLESAMPLE", "name", "simplesample") cfg = self.config.items("datasource_SIMPLESAMPLE") ds = Datasource(**dict(cfg)) self.assert_(hasattr(ds, "only_the_test_simplesample")) objects = self.generator.recipes["test4"].objects ds.read(objects=objects) self.assert_(objects["hosts"]["test_host_0"].my_host == True) self.assert_(objects["applications"].values()[0].test4_linux == True) self.assert_(objects["applications"].values()[1].test4_windows == True)
def test_detail_keyvalues(self): self.print_header() cfg = self.config.items("datasource_CSVDETAILS") objects = self.generator.recipes['test6'].objects ds = Datasource(**dict(cfg)) ds.read(objects=objects) app1 = objects['applications'].values()[0] app1.resolve_monitoring_details() app2 = objects['applications'].values()[1] app2.resolve_monitoring_details() # swap threshold via KEYVALUES detail self.assert_(app1.swap_warning == "15%") self.assert_(app1.swap_critical == "8%") # cron threshold via KEYVALUES detail self.assert_(app1.cron_warning == "30") self.assert_(app1.cron_critical == "100") # swap threshold via class os_linux self.assert_(app2.swap_warning == "5%") self.assert_(app2.swap_critical == "15%") # neither class detail nor csv detail self.assert_(not hasattr(app2, "cron_warning")) self.assert_(hasattr(app2, "thresholds")) self.assert_(hasattr(app2.thresholds, "cron_warning")) self.assert_(app2.thresholds.cron_warning == "31")
def test_ds_handshake(self): self.print_header() self.generator.add_recipe(name="test8", **dict(self.config.items("recipe_TEST8"))) self.config.set("datasource_HANDSH", "name", "handshake") cfg = self.config.items("datasource_HANDSH") ds = Datasource(**dict(cfg)) try: hosts, applications, contacts, contactgroups, appdetails, dependencies, bps = ds.read() except Exception, exp: pass