Example #1
0
    def test_get_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_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")
Example #2
0
    def test_get_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_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")
Example #3
0
    def test_get_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_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")
Example #4
0
 def test_get_log_data_invalid_credential(self):
     results = interface.get_log_data(None, "24a_TON")
     self.assertEqual(results["error"], CRED_ERROR)
Example #5
0
 def test_get_log_data_error(self):
     results = interface.get_log_data(self.credential2, [""])
     self.assertEqual(results["error"], None)
     self.assertEqual(results["results"].strip(), '')
Example #6
0
 def test_get_log_data_invalid_credential(self):
     results = interface.get_log_data(None, "24a_TON")
     self.assertEqual(results["error"], CRED_ERROR)
Example #7
0
 def test_get_log_data_error(self):
     results = interface.get_log_data(self.credential2, [""])
     self.assertEqual(results["error"], None)
     self.assertEqual(results["results"].strip(), '')