Ejemplo n.º 1
0
 def test_pass(self):
     """EmptyTypeAttr test pass."""
     with open("/dev/null", "w") as fd:
         config = {"attr": "test1"}
         check = EmptyTypeAttr(self.p, "test_pass", config)
         check.output = fd
         result = check.run()
         self.assertEqual(0, len(result))
Ejemplo n.º 2
0
 def test_pass_missingok(self):
     """EmptyTypeAttr test pass by missing."""
     with open("/dev/null", "w") as fd:
         config = {"attr": "test2",
                   "missing_ok": "true"}
         check = EmptyTypeAttr(self.p, "test_pass_missingok", config)
         check.output = fd
         result = check.run()
         self.assertEqual(0, len(result))
Ejemplo n.º 3
0
 def test_fail(self):
     """EmptyTypeAttr test fail."""
     with open("/dev/null", "w") as fd:
         # also verify missing_ok doesn't induce a pass
         # when the attr exists
         config = {"attr": "test3",
                   "missing_ok": "true"}
         check = EmptyTypeAttr(self.p, "test_fail", config)
         check.output = fd
         result = check.run()
         expected = [self.p.lookup_type("test3_hit1"),
                     self.p.lookup_type("test3_hit2")]
         self.assertListEqual(expected, result)
Ejemplo n.º 4
0
    def test_attr_setting(self):
        """EmptyTypeAttr test attr setting."""
        config = {"attr": "test1"}
        check = EmptyTypeAttr(self.p, "test_attr_setting", config)

        expected = self.p.lookup_typeattr("test1")
        self.assertEqual(expected, check.attr)
Ejemplo n.º 5
0
    def test_missingok_setting(self):
        """EmptyTypeAttr test missing_ok setting."""
        config = {"attr": "test1",
                  "missing_ok": "true"}
        check = EmptyTypeAttr(self.p, "test_missingok_setting", config)
        self.assertTrue(check.missing_ok)

        config = {"attr": "test1",
                  "missing_ok": " YeS "}
        check = EmptyTypeAttr(self.p, "test_missingok_setting", config)
        self.assertTrue(check.missing_ok)

        config = {"attr": "test1",
                  "missing_ok": " 1 "}
        check = EmptyTypeAttr(self.p, "test_missingok_setting", config)
        self.assertTrue(check.missing_ok)

        config = {"attr": "test1",
                  "missing_ok": " No "}
        check = EmptyTypeAttr(self.p, "test_missingok_setting", config)
        self.assertFalse(check.missing_ok)
Ejemplo n.º 6
0
 def test_attr_setting_missing(self):
     """EmptyTypeAttr test attr setting missing."""
     with self.assertRaises(InvalidCheckValue):
         config = {}
         check = EmptyTypeAttr(self.p, "test_attr_setting_missing", config)
Ejemplo n.º 7
0
 def test_attr_setting_fail(self):
     """EmptyTypeAttr test attr setting with invalid attr."""
     with self.assertRaises(InvalidCheckValue):
         config = {"attr": "FAILATTR"}
         check = EmptyTypeAttr(self.p, "test_attr_setting_fail", config)
Ejemplo n.º 8
0
 def test_invalid_option(self):
     """Test invalid option"""
     with self.assertRaises(InvalidCheckOption):
         config = {"INVALID": "option"}
         check = EmptyTypeAttr(self.p, "test_invalid_option", config)