File indexing completed on 2026-04-10 08:39:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 import unittest
0011 import os
0012
0013 from pilot.util.workernode import collect_workernode_info, get_disk_space
0014
0015
0016 class TestUtils(unittest.TestCase):
0017 """
0018 Unit tests for utils functions.
0019 """
0020
0021 def setUp(self):
0022
0023 self.mac = False
0024 if os.environ.get('MACOSX') == 'true' or not os.path.exists('/proc/meminfo'):
0025 self.mac = True
0026
0027 from pilot.info import infosys
0028 infosys.init("CERN")
0029
0030 def test_collect_workernode_info(self):
0031 """
0032 Make sure that collect_workernode_info() returns the proper types (float, float, float).
0033
0034 :return: (assertion)
0035 """
0036
0037 if self.mac:
0038 return True
0039
0040 mem, cpu, disk = collect_workernode_info(path=os.getcwd())
0041
0042 self.assertEqual(type(mem), float)
0043 self.assertEqual(type(cpu), float)
0044 self.assertEqual(type(disk), float)
0045
0046 self.assertNotEqual(mem, 0.0)
0047 self.assertNotEqual(cpu, 0.0)
0048 self.assertNotEqual(disk, 0.0)
0049
0050 def test_get_disk_space(self):
0051 """
0052 Verify that get_disk_space() returns the proper type (int).
0053
0054 :return: (assertion)
0055 """
0056
0057 if self.mac:
0058 return True
0059
0060
0061 from pilot.info import infosys
0062
0063 diskspace = get_disk_space(infosys.queuedata)
0064
0065 self.assertEqual(type(diskspace), int)
0066
0067
0068 if __name__ == '__main__':
0069 unittest.main()