Revision a2d2e1a7 test/ganeti.utils_unittest.py
b/test/ganeti.utils_unittest.py | ||
---|---|---|
824 | 824 |
self.assertRaises(AssertionError, utils.MergeTime, (-9999, 0)) |
825 | 825 |
|
826 | 826 |
|
827 |
class FieldSetTestCase(unittest.TestCase): |
|
828 |
"""Test case for FieldSets""" |
|
829 |
|
|
830 |
def testSimpleMatch(self): |
|
831 |
f = utils.FieldSet("a", "b", "c", "def") |
|
832 |
self.failUnless(f.Matches("a")) |
|
833 |
self.failIf(f.Matches("d"), "Substring matched") |
|
834 |
self.failIf(f.Matches("defghi"), "Prefix string matched") |
|
835 |
self.failIf(f.NonMatching(["b", "c"])) |
|
836 |
self.failIf(f.NonMatching(["a", "b", "c", "def"])) |
|
837 |
self.failUnless(f.NonMatching(["a", "d"])) |
|
838 |
|
|
839 |
def testRegexMatch(self): |
|
840 |
f = utils.FieldSet("a", "b([0-9]+)", "c") |
|
841 |
self.failUnless(f.Matches("b1")) |
|
842 |
self.failUnless(f.Matches("b99")) |
|
843 |
self.failIf(f.Matches("b/1")) |
|
844 |
self.failIf(f.NonMatching(["b12", "c"])) |
|
845 |
self.failUnless(f.NonMatching(["a", "1"])) |
|
846 |
|
|
847 |
|
|
827 | 848 |
if __name__ == '__main__': |
828 | 849 |
unittest.main() |
Also available in: Unified diff