def test_getSimilar_list(self): """getSimilar: return a list of one match""" self.assertEqual(nagctl.getSimilar(["hosts"], self.selectors), ["hosts"]) self.assertEqual(nagctl.getSimilar(["HOSTS"], self.selectors), ["hosts"]) self.assertEqual(nagctl.getSimilar(["a", "ever"], self.selectors), ["almost everything"]) self.assertEqual(nagctl.getSimilar(["hosts", "monkeys"], self.selectors), ["hosts"])
def test_getSimilar_dict(self): """getSimilar: return a dictionary of one match""" self.assertEqual(nagctl.getSimilar(["enab", "ho"], self.commands), {"enable host":0}) self.assertEqual(nagctl.getSimilar(["ENAB", "HO"], self.commands), {"enable host":0}) self.assertEqual(nagctl.getSimilar(["enab", "ho", "pretty", "please"], self.commands), {"enable host":0}) self.assertEqual(nagctl.getSimilar(["hug"], self.commands), {"hug":2})
def test_getSimilar_list_more(self): """getSimilar: return a list of multiple matches""" self.assertEqual(nagctl.getSimilar(["host"], self.selectors), ["host", "hosts"]) self.assertEqual(nagctl.getSimilar(["HOST"], self.selectors), ["host", "hosts"]) self.assertEqual(nagctl.getSimilar(["almost"], self.selectors), ["almost everything", "almost honest"])
def test_getSimilar_dict(self): """getSimilar: return a dictionary of one match""" self.assertEqual(nagctl.getSimilar(["enab", "ho"], self.commands), {"enable host": 0}) self.assertEqual(nagctl.getSimilar(["ENAB", "HO"], self.commands), {"enable host": 0}) self.assertEqual( nagctl.getSimilar(["enab", "ho", "pretty", "please"], self.commands), {"enable host": 0}) self.assertEqual(nagctl.getSimilar(["hug"], self.commands), {"hug": 2})
def test_getSimilar_list(self): """getSimilar: return a list of one match""" self.assertEqual(nagctl.getSimilar(["hosts"], self.selectors), ["hosts"]) self.assertEqual(nagctl.getSimilar(["HOSTS"], self.selectors), ["hosts"]) self.assertEqual(nagctl.getSimilar(["a", "ever"], self.selectors), ["almost everything"]) self.assertEqual( nagctl.getSimilar(["hosts", "monkeys"], self.selectors), ["hosts"])
def test_getSimilar_dict_more(self): """getSimilar: return a dictionary of multiple matches""" self.assertEqual(nagctl.getSimilar(["en", "h"], self.commands), { "enable host": 0, "enchant host": 1 }) self.assertEqual(nagctl.getSimilar(["EN", "H"], self.commands), { "enable host": 0, "enchant host": 1 }) self.assertEqual(nagctl.getSimilar(["en"], self.commands), { "enable host": 0, "enchant host": 1 })
def test_getSimilar_none(self): """getSimilar: return empty list when first argument is an empty string""" self.assertEqual(nagctl.getSimilar([""], self.commands), [])
def test_getSimilar_dict_empty(self): """getSimilar: return an empty dictionary without any matches""" self.assertEqual(nagctl.getSimilar(["energize", "me"], self.commands), {}) self.assertEqual(nagctl.getSimilar(["xen", "host"], self.commands), {})
def test_getSimilar_dict_more(self): """getSimilar: return a dictionary of multiple matches""" self.assertEqual(nagctl.getSimilar(["en", "h"], self.commands), {"enable host":0, "enchant host":1}) self.assertEqual(nagctl.getSimilar(["EN", "H"], self.commands), {"enable host":0, "enchant host":1}) self.assertEqual(nagctl.getSimilar(["en"], self.commands), {"enable host":0, "enchant host":1})
def test_getSimilar_list_empty(self): """getSimilar: return an empty list without any matches""" self.assertEqual(nagctl.getSimilar(["service"], self.selectors), []) self.assertEqual(nagctl.getSimilar(["aho"], self.selectors), [])