def test_error_message(self): ''' Test error message to the log collector. :return: ''' utcmock = MagicMock() utcmock.utcnow = MagicMock( return_value=datetime.datetime.utcfromtimestamp(0)) with patch('datetime.datetime', utcmock): msg = 'Learning curve appears to be fractal' out = saltsupport.LogCollector() out.error(msg) assert saltsupport.LogCollector.ERROR in out.messages assert type(out.messages[saltsupport.LogCollector.ERROR] ) == saltsupport.LogCollector.MessagesList assert out.messages[saltsupport.LogCollector.ERROR] == [ '00:00:00.000 - {}'.format(msg) ]
def test_warning_message(self): ''' Test warning message to the log collector. :return: ''' utcmock = MagicMock() utcmock.utcnow = MagicMock( return_value=datetime.datetime.utcfromtimestamp(0)) with patch('datetime.datetime', utcmock): msg = 'Your e-mail is now being delivered by USPS' out = saltsupport.LogCollector() out.warning(msg) assert saltsupport.LogCollector.WARNING in out.messages assert type(out.messages[saltsupport.LogCollector.WARNING] ) == saltsupport.LogCollector.MessagesList assert out.messages[saltsupport.LogCollector.WARNING] == [ '00:00:00.000 - {}'.format(msg) ]
def test_put_message(self): ''' Test put message to the log collector. :return: ''' utcmock = MagicMock() utcmock.utcnow = MagicMock( return_value=datetime.datetime.utcfromtimestamp(0)) with patch('datetime.datetime', utcmock): msg = 'Webmaster kidnapped by evil cult' out = saltsupport.LogCollector() out.put(msg) 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 - {}'.format(msg) ]
def test_info_message(self): ''' Test info message to the log collector. :return: ''' utcmock = MagicMock() utcmock.utcnow = MagicMock( return_value=datetime.datetime.utcfromtimestamp(0)) with patch('datetime.datetime', utcmock): msg = 'SIMM crosstalk during tectonic stress' out = saltsupport.LogCollector() out.info(msg) 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 - {}'.format(msg) ]
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' ]