Revision 91c17910 test/py/ganeti.rpc_unittest.py
b/test/py/ganeti.rpc_unittest.py | ||
---|---|---|
1 | 1 |
#!/usr/bin/python |
2 | 2 |
# |
3 | 3 |
|
4 |
# Copyright (C) 2010, 2011, 2012 Google Inc. |
|
4 |
# Copyright (C) 2010, 2011, 2012, 2013 Google Inc.
|
|
5 | 5 |
# |
6 | 6 |
# This program is free software; you can redistribute it and/or modify |
7 | 7 |
# it under the terms of the GNU General Public License as published by |
... | ... | |
889 | 889 |
msg="Configuration objects were modified") |
890 | 890 |
|
891 | 891 |
|
892 |
class TestLegacyNodeInfo(unittest.TestCase): |
|
893 |
KEY_BOOT = "bootid" |
|
894 |
KEY_VG = "disk_free" |
|
895 |
KEY_HV = "cpu_count" |
|
896 |
VAL_BOOT = 0 |
|
897 |
VAL_VG = 1 |
|
898 |
VAL_HV = 2 |
|
899 |
DICT_VG = {KEY_VG: VAL_VG} |
|
900 |
DICT_HV = {KEY_HV: VAL_HV} |
|
901 |
STD_LST = [VAL_BOOT, [DICT_VG], [DICT_HV]] |
|
902 |
STD_DICT = { |
|
903 |
KEY_BOOT: VAL_BOOT, |
|
904 |
KEY_VG: VAL_VG, |
|
905 |
KEY_HV: VAL_HV |
|
906 |
} |
|
907 |
|
|
908 |
def testStandard(self): |
|
909 |
result = rpc.MakeLegacyNodeInfo(self.STD_LST) |
|
910 |
self.assertEqual(result, self.STD_DICT) |
|
911 |
|
|
912 |
def testReqVg(self): |
|
913 |
my_lst = [self.VAL_BOOT, [], [self.DICT_HV]] |
|
914 |
self.assertRaises(ValueError, rpc.MakeLegacyNodeInfo, my_lst) |
|
915 |
|
|
916 |
def testNoReqVg(self): |
|
917 |
my_lst = [self.VAL_BOOT, [], [self.DICT_HV]] |
|
918 |
result = rpc.MakeLegacyNodeInfo(my_lst, require_vg_info = False) |
|
919 |
self.assertEqual(result, {self.KEY_BOOT: self.VAL_BOOT, |
|
920 |
self.KEY_HV: self.VAL_HV}) |
|
921 |
result = rpc.MakeLegacyNodeInfo(self.STD_LST, require_vg_info = False) |
|
922 |
self.assertEqual(result, self.STD_DICT) |
|
923 |
|
|
924 |
|
|
892 | 925 |
if __name__ == "__main__": |
893 | 926 |
testutils.GanetiTestProgram() |
Also available in: Unified diff