Coverage for tests/test_SRCommand : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
def test_run_correctly_log_all_exceptions( self, mock_parse, mock_run_statics, mock_reduce, mock_SMlog, mock_exit):
""" Assert that any arbitrary exception raised and with a big message length is logged to SMlog. Only the first line of the message is asserted (traceback ommited). """
# TestSRCommand data member to hold SMlog output.
# Generate random exception message of MSG_LEN characters
# Create function to raise exception in SRCommand.run()
# MockSMlog replaces util.SMlog. Instead of printing to # /var/log/SMlog, it writes the output to self.smlog_out.
def test_run_print_xml_error_if_SRException( self, mock_parse, mock_run_statics, mock_logException):
""" If an SR.SRException is thrown, assert that print <SR.SRException instance>.toxml()" is called. """
# Save original sys.stdout file object.
# Create a mock_stdout object and assign it to sys.stdout
# Create function to raise exception in SRCommand.run() "[UnitTest] SRException thrown"))
# Write SRCommand.run() output to variable.
# Restore the original sys.stdout object.
"<value><struct>\n<member>\n<name>faultCode</name>\n" "<value><int>22</int></value>\n</member>\n<member>\n" "<name>faultString</name>\n<value><string>[UnitTest] " "SRException thrown</string></value>\n</member>\n" "</struct></value>\n</fault>\n</methodResponse>\n\n")
def test_run_wrapped_if_not_SRException( self, mock_parse, mock_run_statics, mock_logException, mock_exit):
""" If an exception other than SR.SRException is thrown, assert that it is wrapped and not thrown. """
# Create function to raise exception in SRCommand.run()
|