예제 #1
0
 def test_replace_CID_alt_CID(self):
     email = Msgtopdf("C:/test/email.msg")
     line = '<img width="1135" height="571" style="width:11.8229in;height:5.9479in" id="Picture_x0020_1" src="cid:[email protected]" alt="cid:[email protected]">'
     assert (
         email.replace_CID(line)
         == '<img width="1135" height="571" style="width:11.8229in;height:5.9479in" id="Picture_x0020_1" src="image004.png" alt="image004.png">'
     )
예제 #2
0
파일: msg2pdf.py 프로젝트: ushills/msgtopdf
def convert_file(filename):
    try:
        f = Msgtopdf(filename)
        f.email2pdf()
        print(Fore.GREEN + f"Converted {filename} to PDF!" + Fore.RESET)
    except:
        print(Fore.RED + f"Something went wrong!" + Fore.RESET)
예제 #3
0
 def test_replace_CID_multiple_CID(self):
     email = Msgtopdf("C:/test/email.msg")
     line = '<img src="cid:[email protected]"><img src="cid:[email protected]">'
     assert (
         email.replace_CID(line)
         == '<img src="image001.png"><img src="image002.png">'
     )
     assert email.image_files == ["image001.png", "image002.png"]
예제 #4
0
 def test_raw_email_body_html(self):
     email = Msgtopdf("C:/test/email.msg")
     email.msg.BodyFormat = 2
     email.raw_email_body()
     assert email.email_format == "html"
     email.msg.BodyFormat = 3
     email.raw_email_body()
     assert email.email_format == "html"
     email.msg.BodyFormat = 1
     email.raw_email_body()
     assert email.email_format == "txt"
예제 #5
0
 def test___delete_redundant_files(self):
     email = Msgtopdf("C:/test/email.msg")
     email.save_path = pathlib.PurePath("./tests/")
     email.image_files = ["exists.png", "does_not_exist.png"]
     email.html_body_file = "./tests/html_body.html"
     # create temporary files for deletion
     open("./tests/html_body.html", "w+")
     open("./tests/exists.png", "w+")
     assert email.image_files == ["exists.png", "does_not_exist.png"]
     email._Msgtopdf__delete_redundant_files()
예제 #6
0
 def test_clean_path(self):
     email = Msgtopdf("C:/test/email.msg")
     path = r"RE:/ test dirty path ^"
     assert email.clean_path(path) == "RE test dirty path"
예제 #7
0
 def test_replace_CID_no_replace(self):
     email = Msgtopdf("C:/test/email.msg")
     body = "<p>Not an image</p>"
     assert email.replace_CID(body) == "<p>Not an image</p>"
예제 #8
0
 def test_replace_CID_single_CID(self):
     email = Msgtopdf("C:/test/email.msg")
     line = '<img src="cid:[email protected]">'
     assert email.replace_CID(line) == '<img src="image001.png">'
예제 #9
0
 def test_init_save_path(self):
     email = Msgtopdf("C:/test/email.msg")
     assert email.save_path == pathlib.PurePath("C:/test/email")
예제 #10
0
 def test_init_file(self):
     email = Msgtopdf("C:/test/email.msg")
     assert email.file == "email.msg"
예제 #11
0
 def test_init_directory(self):
     email = Msgtopdf("C:/test/email.msg")
     assert email.directory == pathlib.PurePath("C:/test")