def test_no_root_response(self): with mock.patch('include.common.shell_command.ShellCommand.get_stdout', return_value=NO_SENSE_RESPONSE) as something: self.assertEqual(get_memory_info("whatever"), []) self.assertEqual(_parse_handle_section(iter(NO_SENSE_RESPONSE.splitlines())), {'_title': 'Handle 0x0050, DMI type 131, 64 bytes'}) self.assertEqual(_parse_dmi(NO_SENSE_RESPONSE, 5), [])
def test_no_memory_response(self): self.assertEqual(_parse_handle_section(iter(PROPER_HANDLE_SECTION.splitlines())), {'_title': 'Handle 0x0050, DMI type 131, 64 bytes'}) with mock.patch('include.common.shell_command.ShellCommand.get_stdout', return_value=PROPER_HANDLE_SECTION) as something: self.assertEqual(get_memory_info("whatever"), []) self.assertEqual(_parse_dmi(PROPER_HANDLE_SECTION, 5), [])
def test_multiple_memories_response(self): self.assertEqual(_parse_handle_section(iter(MULTIPLE_MEMORIES.splitlines())), {'_title': 'Handle 0x0042, DMI type 16, 23 bytes'}) with mock.patch('include.common.shell_command.ShellCommand.get_stdout', return_value=MULTIPLE_MEMORIES) as something: self.assertEqual(get_memory_info("whatever"), MEM_TO_OBJ) self.assertEqual(_parse_dmi(MULTIPLE_MEMORIES, TYPE.keys()[0]), MEM_TO_OBJ) self.assertEqual(_profile(TYPE.keys()[0]), MEM_TO_OBJ) self.assertEqual(get_memory_info('7730A787'), MEM1) self.assertEqual(get_memory_info('73305687'), MEM2)
def test_no_root_response(self): with mock.patch('include.common.shell_command.ShellCommand.get_stdout', return_value=NO_ROOT_RESPONSE) as something: self.assertEqual(get_memory_info("whatever"), []) self.assertEqual(_parse_dmi(NO_ROOT_RESPONSE, 5), [])