예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
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"Tools file not found: .*"
        with six.assertRaisesRegex(self, ValueError, message):
            Resolwe._upload_tools(self.resolwe_mock, self.tools)
예제 #4
0
    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)
예제 #5
0
    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)
예제 #6
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)
예제 #7
0
    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)
예제 #8
0
 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)
예제 #9
0
 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)