def test_msg(self): ''' Test message to the log collector. :return: ''' utcmock = MagicMock() utcmock.utcnow = MagicMock( return_value=datetime.datetime.utcfromtimestamp(0)) with patch('datetime.datetime', utcmock): msg = 'Upgrading /dev/null device' out = saltsupport.LogCollector() out.msg(msg, title='Here') assert saltsupport.LogCollector.INFO in out.messages assert type(out.messages[saltsupport.LogCollector.INFO] ) == saltsupport.LogCollector.MessagesList assert out.messages[saltsupport.LogCollector.INFO] == [ '00:00:00.000 - {0}: {1}'.format('Here', msg) ]
def test_hl_message(self): ''' Test highlighter message to the log collector. :return: ''' utcmock = MagicMock() utcmock.utcnow = MagicMock( return_value=datetime.datetime.utcfromtimestamp(0)) with patch('datetime.datetime', utcmock): out = saltsupport.LogCollector() out.highlight('The {} TTYs became {} TTYs and vice versa', 'real', 'pseudo') assert saltsupport.LogCollector.INFO in out.messages assert type(out.messages[saltsupport.LogCollector.INFO] ) == saltsupport.LogCollector.MessagesList assert out.messages[saltsupport.LogCollector.INFO] == [ '00:00:00.000 - The real TTYs became ' 'pseudo TTYs and vice versa' ]