示例#1
0
文件: test.py 项目: rstgroup/nagctl
	def test_matchObjects_none(self):
		"""matchObjects: return empty list when no object matches"""

		nagctl.conf["host"] = "dummy"

		objects = nagctl.matchObjects()
		hosts = objects.getHostList()
		self.assertEqual(hosts, [])

		nagctl.conf["host"] = None
		nagctl.conf["service"] = "dummy"

		services = []
		objects = nagctl.matchObjects()
		for i in range(0, objects.getCount()):
			services.append(objects.getServiceList(i))
		self.assertEqual(services, [])
示例#2
0
文件: test.py 项目: sasg/nagctl
    def test_matchObjects_none(self):
        """matchObjects: return empty list when no object matches"""

        nagctl.conf["host"] = "dummy"

        objects = nagctl.matchObjects()
        hosts = objects.getHostList()
        self.assertEqual(hosts, [])

        nagctl.conf["host"] = None
        nagctl.conf["service"] = "dummy"

        services = []
        objects = nagctl.matchObjects()
        for i in range(0, objects.getCount()):
            services.append(objects.getServiceList(i))
        self.assertEqual(services, [])
示例#3
0
文件: test.py 项目: rstgroup/nagctl
	def test_matchObjects_all(self):
		"""matchObjects: return all hosts and services"""

		objects = nagctl.matchObjects()
		self.assertEqual(objects.getHostList(), nagctl.hosts)

		expected = [["queue0", "load"], ["queue1", "load"], ["queue0", "queue1", "load"]]
		services = []
		for i in range(0, objects.getCount()):
			services.append([s.getName() for s in objects.getServiceList(i)])
		self.assertEqual(services, expected)
示例#4
0
文件: test.py 项目: sasg/nagctl
    def test_matchObjects_all(self):
        """matchObjects: return all hosts and services"""

        objects = nagctl.matchObjects()
        self.assertEqual(objects.getHostList(), nagctl.hosts)

        expected = [["queue0", "load"], ["queue1", "load"],
                    ["queue0", "queue1", "load"]]
        services = []
        for i in range(0, objects.getCount()):
            services.append([s.getName() for s in objects.getServiceList(i)])
        self.assertEqual(services, expected)
示例#5
0
文件: test.py 项目: rstgroup/nagctl
	def test_matchObjects_service(self):
		"""matchObjects: return a list of hosts and services filtered by service"""

		nagctl.conf["service"] = "load"

		objects = nagctl.matchObjects()
		hosts = [h.getName() for h in objects.getHostList()]
		self.assertEqual(hosts, ["worker0", "worker1", "database"])

		expected = [["load"], ["load"], ["load"]]
		services = []
		for i in range(0, objects.getCount()):
			services.append([s.getName() for s in objects.getServiceList(i)])
		self.assertEqual(services, expected)
示例#6
0
文件: test.py 项目: rstgroup/nagctl
	def test_matchObjects_host(self):
		"""matchObjects: return a list of hosts and services filtered by host"""

		nagctl.conf["host"] = "worker[0-9]"

		objects = nagctl.matchObjects()
		hosts = [h.getName() for h in objects.getHostList()]
		self.assertEqual(hosts, ["worker0", "worker1"])

		services = []
		expected = [["queue0", "load"], ["queue1", "load"]]
		for i in range(0, objects.getCount()):
			services.append([s.getName() for s in objects.getServiceList(i)])
		self.assertEqual(services, expected)
示例#7
0
文件: test.py 项目: sasg/nagctl
    def test_matchObjects_service(self):
        """matchObjects: return a list of hosts and services filtered by service"""

        nagctl.conf["service"] = "load"

        objects = nagctl.matchObjects()
        hosts = [h.getName() for h in objects.getHostList()]
        self.assertEqual(hosts, ["worker0", "worker1", "database"])

        expected = [["load"], ["load"], ["load"]]
        services = []
        for i in range(0, objects.getCount()):
            services.append([s.getName() for s in objects.getServiceList(i)])
        self.assertEqual(services, expected)
示例#8
0
文件: test.py 项目: sasg/nagctl
    def test_matchObjects_host(self):
        """matchObjects: return a list of hosts and services filtered by host"""

        nagctl.conf["host"] = "worker[0-9]"

        objects = nagctl.matchObjects()
        hosts = [h.getName() for h in objects.getHostList()]
        self.assertEqual(hosts, ["worker0", "worker1"])

        services = []
        expected = [["queue0", "load"], ["queue1", "load"]]
        for i in range(0, objects.getCount()):
            services.append([s.getName() for s in objects.getServiceList(i)])
        self.assertEqual(services, expected)