forked from archive/andrewferrier_email2pdf
Clarify usage of -o and -d together - closes #54
This commit is contained in:
parent
16936df8e5
commit
2047dbe7b1
2 changed files with 23 additions and 2 deletions
|
@ -51,8 +51,9 @@ def main(argv, sysLogHandler, sysErrHandler):
|
|||
"the file in the directory specified by --outputDirectory.")
|
||||
|
||||
parser.add_argument("-d", "--outputDirectory", default=os.getcwd(),
|
||||
help="Output directory when --outputFile is not specified. Defaults to the "
|
||||
"current directory.")
|
||||
help="Output directory for body PDF file when --outputFile is not specified. Defaults to the "
|
||||
"current directory. Also used as the directory in which attachments are stored (even if -o is "
|
||||
"specified).")
|
||||
|
||||
body_attachment_options = parser.add_mutually_exclusive_group()
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ from datetime import datetime
|
|||
from email.mime.multipart import MIMEMultipart
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
from tests.BaseTestClasses import Email2PDFTestCase
|
||||
|
||||
|
@ -110,6 +111,25 @@ class TestMIME(Email2PDFTestCase):
|
|||
self.assertRegex(self.getPDFText(self.getTimedFilename()), "Some basic textual content")
|
||||
self.assertRegex(self.getPDFText(os.path.join(self.workingDir, filename)), "Some PDF content")
|
||||
|
||||
def test_plaincontent_outputfileoverrides_with_attachments(self):
|
||||
mainFilename = os.path.join(self.examineDir, "outputFileOverridesWithAttachments.pdf")
|
||||
self.attachText("Hello!")
|
||||
attachmentFilename = self.attachPDF("Some PDF content")
|
||||
with tempfile.TemporaryDirectory() as tempdir:
|
||||
(rc, output, error) = self.invokeAsSubprocess(outputDirectory=tempdir, outputFile=mainFilename)
|
||||
self.assertEqual(0, rc)
|
||||
self.assertEqual('', error)
|
||||
self.assertFalse(self.existsByTime())
|
||||
self.assertFalse(self.existsByTime(tempdir))
|
||||
self.assertFalse(os.path.exists(os.path.join(tempdir, "outputFileOverrides.pdf")))
|
||||
self.assertFalse(os.path.exists(os.path.join(self.workingDir, "outputFileOverrides.pdf")))
|
||||
self.assertTrue(os.path.exists(mainFilename))
|
||||
self.assertFalse(os.path.exists(os.path.join(self.examineDir, attachmentFilename)))
|
||||
self.assertFalse(os.path.exists(os.path.join(self.workingDir, attachmentFilename)))
|
||||
self.assertTrue(os.path.exists(os.path.join(tempdir, attachmentFilename)))
|
||||
self.assertRegex(self.getPDFText(mainFilename), "Hello!")
|
||||
self.assertRegex(self.getPDFText(os.path.join(tempdir, attachmentFilename)), "Some PDF content")
|
||||
|
||||
def test_remote_image_does_exist(self):
|
||||
if self.isOnline:
|
||||
path = os.path.join(self.examineDir, "remoteImageDoesExist.pdf")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue