def load(self): self.json_data = open(self.path) self.data = json.load(self.json_data) # Loop over the items and put into list metricItems = self.data["items"] for i in metricItems: item = MetricItem() item.setName(str(i["name"])) item.setPollingInterval(int(i["pollInterval"])) item.setCommand(str(i["command"])) item.setDebug(bool(i["debug"])) self.config.append(item)
def testCommand(self): m = MetricItem() m.setCommand("snafu") self.assertEquals(m.getCommand(), "snafu", "Commands not equal")
def testPollInterval(self): m = MetricItem() m.setDebug(True) self.assertEquals(m.getDebug(), True, "Debug not equal")
def testPollIntervalType(self): m = MetricItem() m.setPollingInterval(1000) self.assertTrue(type(m.getPollingInterval()) == int)
def testPollInterval(self): m = MetricItem() m.setPollingInterval(100) self.assertEquals(m.getPollingInterval(), 100, "Poll intervals not equal")
def testNameType(self): m = MetricItem() m.setName("foo") self.assertTrue(type(m.getName()) == str, "Name is not a string")
def testName(self): m = MetricItem() m.setName("foo") self.assertEquals(m.getName(), "foo", "Names not equal")