def test_log_if_returncode_gt1(self, subprocess_mock): fake_subprocess = MagicMock(returncode=2, **{'communicate.return_value': ['Standard output...', 'b']}) subprocess_mock.Popen = MagicMock(return_value=fake_subprocess) Resolwe._upload_tools(self.resolwe_mock, self.tools) self.assertEqual(self.resolwe_mock.logger.warning.call_count, 1)
def test_tools_file_not_found(self, os_mock): resolwe.TOOLS_REMOTE_HOST = 'something' os_mock.configure_mock(**{'path.isfile.return_value': False}) message = r"Tools file not found: .*" with six.assertRaisesRegex(self, ValueError, message): Resolwe._upload_tools(self.resolwe_mock, self.tools)
def test_raise_if_returncode_1(self, subprocess_mock): fake_subprocess = MagicMock(returncode=1, **{'communicate.return_value': ['Standard output...', 'b']}) subprocess_mock.Popen = MagicMock(return_value=fake_subprocess) message = r"Tools file not found: .*" with six.assertRaisesRegex(self, ValueError, message): Resolwe._upload_tools(self.resolwe_mock, self.tools)
def test_logger_calls(self, subprocess_mock): fake_subprocess = MagicMock(returncode=0, **{'communicate.return_value': ['Standard output...', ' ']}) subprocess_mock.Popen = MagicMock(return_value=fake_subprocess) Resolwe._upload_tools(self.resolwe_mock, self.tools) self.resolwe_mock.logger.info.assert_called_with('Standard output...') # confirm that logger.warning was not called - all went ok... self.assertEqual(self.resolwe_mock.logger.warning.call_count, 0)
def test_raise_if_returncode_1(self, subprocess_mock): fake_subprocess = MagicMock(returncode=1, **{'communicate.return_value': ['Standard output...', 'b']}) subprocess_mock.Popen = MagicMock(return_value=fake_subprocess) message = r"Something wrong while SCP for tool: .*" with six.assertRaisesRegex(self, ValueError, message): Resolwe._upload_tools(self.resolwe_mock, self.tools)
def test_remote_host_not_set(self): resolwe.TOOLS_REMOTE_HOST = None message = r"Define TOOLS_REMOTE_HOST environmental variable" with six.assertRaisesRegex(self, ValueError, message): Resolwe._upload_tools(self.resolwe_mock, self.tools)