def setUp(self): self.plugin = OperatingSystem() self.device = StringAttributeObject() acc = ItemsAccumulator() acc.new_item() self.results = {'Win32_SystemEnclosure': acc.items, 'Win32_ComputerSystem': acc.items, 'Win32_OperatingSystem': acc.items, 'exchange_version': Mock(stdout=['15'])}
def test_empty_sysenclosure_process(self): acc = ItemsAccumulator() acc.new_item() self.results = {'Win32_SystemEnclosure': [], 'Win32_ComputerSystem': acc.items, 'Win32_OperatingSystem': acc.items, 'exchange_version': Mock(stdout=['15'])} try: self.plugin.process(self.device, self.results, Mock()) except IndexError: self.fail('Failed to detect empty Win32_SystemEnclosure results.')
def test_empty_wmi_process(self): acc = ItemsAccumulator() acc.new_item() self.results = {'Win32_SystemEnclosure': acc.items, 'Win32_ComputerSystem': acc.items, 'Win32_OperatingSystem': acc.items, 'exchange_version': Mock(stdout=['15'])} data = self.plugin.process(self.device, self.results, Mock()) self.assertEquals(data[0].snmpDescr, 'Unknown') self.assertEquals(data[0].snmpContact, 'Unknown') self.assertEquals(data[0].snmpSysName, 'Unknown') self.assertEquals(data[1].tag, 'Unknown')
def create_results(self, items_dict): items = {} for k, v in items_dict.iteritems(): accumulator = ItemsAccumulator() self.get_items(accumulator, v) items[k] = accumulator.items return items
def create_results(): accumulator = ItemsAccumulator() accumulator.new_item() get_items(accumulator, Win32_DiskDrive) Win32_DiskDrive['Size'] = 'None' accumulator.new_item() get_items(accumulator, Win32_DiskDrive) results = {'diskdrives': { 'Win32_DiskDrive': accumulator.items, 'Win32_LogicalDiskToPartition': {}, 'Win32_DiskDriveToDiskPartition': {}}} del accumulator for k, v in Win32_LogicalDiskToPartition.iteritems(): accumulator = ItemsAccumulator() accumulator.new_item() get_items(accumulator, v) results['diskdrives']['Win32_LogicalDiskToPartition'][k] = accumulator.items del accumulator for k, v in Win32_DiskDriveToDiskPartition.iteritems(): accumulator = ItemsAccumulator() for props in v: accumulator.new_item() get_items(accumulator, props) results['diskdrives']['Win32_DiskDriveToDiskPartition'][k] = accumulator.items return results
def test_contact_none_process(self): # ZPS-3227 test for situation where PrimaryOwnerName # of Win32_ComputerSystem is None acc = ItemsAccumulator() acc.new_item() cs_acc = ItemsAccumulator() cs_acc.new_item() cs_acc.add_property('Name', None) cs_acc.add_property('PrimaryOwnerName', None) cs_acc.add_property('Caption', None) cs_acc.add_property('Domain', 'domain') cs_acc.add_property('Model', 'model') cs_acc.add_property('Manufacturer', 'Microsoft') cs_acc.add_property('DomainRole', '0') os_acc = ItemsAccumulator() os_acc.new_item() os_acc.add_property('CSName', None) os_acc.add_property('RegisteredUser', None) os_acc.add_property('Caption', None) os_acc.add_property('ProductType', '0') os_acc.add_property('SerialNumber', 'model') os_acc.add_property('Manufacturer', 'Microsoft') os_acc.add_property('TotalVisibleMemorySize', '1') os_acc.add_property('TotalVirtualMemorySize', '1') os_acc.add_property('CSDVersion', '1') self.results = {'Win32_SystemEnclosure': acc.items, 'Win32_ComputerSystem': cs_acc.items, 'Win32_OperatingSystem': os_acc.items, 'exchange_version': Mock(stdout=['15'])} data = self.plugin.process(self.device, self.results, Mock()) self.assertEquals(data[0].snmpDescr, 'Unknown') self.assertEquals(data[0].snmpContact, 'Unknown') self.assertEquals(data[0].snmpSysName, 'Unknown')