def test_dmesg_wrap_partial(): """ Test that dmesg still works after dmesg wraps partially We can overwrite the DMESG_COMMAND class variable to emluate dmesg being filled up and overflowing. What this test does is starts with a string that looks like this: "a\nb\nc\n" (this is used to emluate the contents of dmesg), we then replace that with "b\nc\nd\n", and ensure that the update of dmesg contains only 'd', becasue 'd' is the only new value in the updated dmesg. """ # We don't want weird side effects of changing DMESG_COMMAND globally, so # instead we set it as a class instance and manually clear the # _last_messages attribute dmesg = LinuxDmesg() dmesg.DMESG_COMMAND = ['echo', 'a\nb\nc\n'] dmesg.update_dmesg() # Update the DMESG_COMMAND to add d\n and remove a\n, this simluates the # wrap dmesg.DMESG_COMMAND = ['echo', 'b\nc\nd\n'] dmesg.update_dmesg() nt.assert_items_equal(dmesg._new_messages, ['d'], msg="_new_messages should be equal to ['d'], but is " "{} instead.".format(dmesg._new_messages))
def test_dmesg_wrap_complete(): """ Test that dmesg still works after dmesg wraps completely just like the partial version, but with nothingin common. """ # We don't want weird side effects of changing DMESG_COMMAND globally, so # instead we set it as a class instance and manually clear the # _last_messages attribute dmesg = LinuxDmesg() dmesg.DMESG_COMMAND = ['echo', 'a\nb\nc\n'] dmesg.update_dmesg() # Udamte the DMESG_COMMAND to add d\n and remove a\n, this simluates the # wrap dmesg.DMESG_COMMAND = ['echo', '1\n2\n3\n'] dmesg.update_dmesg() nt.assert_items_equal(dmesg._new_messages, ['1', '2', '3'], msg="_new_messages should be equal to " "['1', '2', '3'], but is {} instead".format( dmesg._new_messages))