Revision 26288e68 test/ganeti.utils_unittest.py
b/test/ganeti.utils_unittest.py  

47  47 
ShellQuote, ShellQuoteArgs, TcpPing, ListVisibleFiles, \ 
48  48 
SetEtcHostsEntry, RemoveEtcHostsEntry, FirstFree, OwnIpAddress, \ 
49  49 
TailFile, ForceDictType, SafeEncode, IsNormAbsPath, FormatTime, \ 
50 
UnescapeAndSplit, RunParts, PathJoin 

50 
UnescapeAndSplit, RunParts, PathJoin, HostInfo


51  51  
52  52 
from ganeti.errors import LockError, UnitParseError, GenericError, \ 
53 
ProgrammerError 

53 
ProgrammerError, OpPrereqError


54  54  
55  55  
56  56 
class TestIsProcessAlive(unittest.TestCase): 
...  ...  
1284  1284 
self.failUnlessRaises(ValueError, PathJoin, "/a", "/b") 
1285  1285  
1286  1286  
1287 
class TestHostInfo(unittest.TestCase): 

1288 
"""Testing case for HostInfo""" 

1289  
1290 
def testUppercase(self): 

1291 
data = "AbC.example.com" 

1292 
self.failUnlessEqual(HostInfo.NormalizeName(data), data.lower()) 

1293  
1294 
def testTooLongName(self): 

1295 
data = "a.b." + "c" * 255 

1296 
self.failUnlessRaises(OpPrereqError, HostInfo.NormalizeName, data) 

1297  
1298 
def testTrailingDot(self): 

1299 
data = "a.b.c" 

1300 
self.failUnlessEqual(HostInfo.NormalizeName(data + "."), data) 

1301  
1302 
def testInvalidName(self): 

1303 
data = [ 

1304 
"a b", 

1305 
"a/b", 

1306 
".a.b", 

1307 
"a..b", 

1308 
] 

1309 
for value in data: 

1310 
self.failUnlessRaises(OpPrereqError, HostInfo.NormalizeName, value) 

1311  
1312 
def testValidName(self): 

1313 
data = [ 

1314 
"a.b", 

1315 
"ab", 

1316 
"a_b", 

1317 
"a.b.c", 

1318 
] 

1319 
for value in data: 

1320 
HostInfo.NormalizeName(value) 

1321  
1322  
1323  
1287  1324 
if __name__ == '__main__': 
1288  1325 
testutils.GanetiTestProgram() 
Also available in: Unified diff