Пример #1
0
    def test_call_os_error(self, mock_popen):
        mock_popen.return_value.communicate.side_effect = SubprocessError
        pdf_file = mock.MagicMock()
        pdf = PDFFiller(pdf_file, {}, True)

        with pytest.raises(PDFNotFilled):
            pdf.call("/foo", "/bar")
Пример #2
0
    def test_call_os_error(self, mock_popen):
        mock_popen.return_value.communicate.side_effect = SubprocessError
        pdf_file = mock.MagicMock()
        pdf = PDFFiller(pdf_file, {}, True)

        with pytest.raises(PDFNotFilled):
            pdf.call('/foo', '/bar')
Пример #3
0
    def test_call_non_zero_return_code(self, mock_popen):
        mock_popen.return_value.communicate.return_value = "stdout", "stderr"
        mock_popen.return_value.returncode = 5
        pdf_file = mock.MagicMock()
        pdf = PDFFiller(pdf_file, {}, True)

        with pytest.raises(PDFNotFilled):
            pdf.call("/foo", "/bar")
Пример #4
0
    def test_call_non_zero_return_code(self, mock_popen):
        mock_popen.return_value.communicate.return_value = 'stdout', 'stderr'
        mock_popen.return_value.returncode = 5
        pdf_file = mock.MagicMock()
        pdf = PDFFiller(pdf_file, {}, True)

        with pytest.raises(PDFNotFilled):
            pdf.call('/foo', '/bar')
Пример #5
0
    def test_call(self, mock_popen):
        mock_popen.return_value.communicate.return_value = "stdout", "stderr"
        mock_popen.return_value.returncode = 0
        pdf_file = mock.MagicMock()
        pdf = PDFFiller(pdf_file, {}, True)

        actual = pdf.call("/foo", "/bar")

        assert actual == "stdout"
        mock_popen.assert_called_once_with(
            "/pdftk /bar fill_form /foo output - flatten", shell=True, stdout=PIPE, stderr=PIPE, stdin=PIPE
        )
Пример #6
0
    def test_call(self, mock_popen):
        mock_popen.return_value.communicate.return_value = 'stdout', 'stderr'
        mock_popen.return_value.returncode = 0
        pdf_file = mock.MagicMock()
        pdf = PDFFiller(pdf_file, {}, True)

        actual = pdf.call('/foo', '/bar')

        assert actual == 'stdout'
        mock_popen.assert_called_once_with(
            '/pdftk /bar fill_form /foo output - flatten',
            shell=True,
            stdout=PIPE,
            stderr=PIPE,
            stdin=PIPE)