def test_get_all_log_data(self): self.mock_ssh.exec_command.side_effect = [ make_io_triplet(stdout="chemtools/fileparser.py"), make_io_triplet(), make_io_triplet(stdout="Filename,..."), ] results = interface.get_all_log_data(self.credential2) self.assertEqual(results["error"], None) self.assertIn("Filename", results["results"])
def test_get_all_log_data_argparse(self): with self.credential2.get_sftp_connection() as sftp: with sftp.open("chemtools/fileparser.py", 'w') as f: f.write("from __future__ import print_function\n") f.write("import sys\n") f.write("print('No module named argparse', file=sys.stderr)") results = interface.get_all_log_data(self.credential2) self.assertIn("No module named argparse", results["error"]) with self.credential2.get_ssh_connection() as ssh: ssh.exec_command("rm chemtools/fileparser.py")
def test_get_all_log_data_argparse(self): with self.credential2.get_sftp_connection() as sftp: with sftp.open("chemtools/fileparser.py", 'w') as f: f.write("from __future__ import print_function\n") f.write("import sys\n") f.write("print('No module named argparse', file=sys.stderr)") # Check with ls, and then fail twice when running fileparser self.mock_ssh.exec_command.side_effect = [ make_io_triplet(stdout='chemtools/fileparser.py'), make_io_triplet(stderr='No module named argparse'), make_io_triplet(stderr='No module named argparse'), ] results = interface.get_all_log_data(self.credential2) self.assertIn("No module named argparse", results["error"]) with self.credential2.get_ssh_connection() as ssh: ssh.exec_command("rm chemtools/fileparser.py")
def test_get_all_log_data_invalid_credential(self): results = interface.get_all_log_data(None) self.assertEqual(results["error"], CRED_ERROR)
def test_get_all_log_data(self): results = interface.get_all_log_data(self.credential2) self.assertEqual(results["error"], None) self.assertIn("Filename", results["results"])