Revision 4fdedd09 test/ganeti.jstore_unittest.py
b/test/ganeti.jstore_unittest.py | ||
---|---|---|
78 | 78 |
self.assertRaises(errors.ParameterError, jstore.ParseJobId, []) |
79 | 79 |
|
80 | 80 |
|
81 |
class TestReadNumericFile(testutils.GanetiTestCase): |
|
82 |
def testNonExistingFile(self): |
|
83 |
result = jstore._ReadNumericFile("/tmp/this/file/does/not/exist") |
|
84 |
self.assertTrue(result is None) |
|
85 |
|
|
86 |
def testValidFile(self): |
|
87 |
tmpfile = self._CreateTempFile() |
|
88 |
|
|
89 |
for (data, exp) in [("123", 123), ("0\n", 0)]: |
|
90 |
utils.WriteFile(tmpfile, data=data) |
|
91 |
result = jstore._ReadNumericFile(tmpfile) |
|
92 |
self.assertEqual(result, exp) |
|
93 |
|
|
94 |
def testInvalidContent(self): |
|
95 |
tmpfile = self._CreateTempFile() |
|
96 |
utils.WriteFile(tmpfile, data="{wrong content") |
|
97 |
self.assertRaises(errors.JobQueueError, jstore._ReadNumericFile, tmpfile) |
|
98 |
|
|
99 |
|
|
81 | 100 |
if __name__ == "__main__": |
82 | 101 |
testutils.GanetiTestProgram() |
Also available in: Unified diff