import pytest
from mailthon.attachments import PlainText
from mailthon.envelope import Envelope, Stamp


class TestEnvelope:
    @pytest.fixture(autouse=True)
    def envelope(self):
        return Envelope(
            stamp=Stamp(sender='sender <me@mail.com>',
                        receivers=['him@mail.com'],
                        subject='hi!'),
            attachments=[
                PlainText('Hi!'),
                PlainText('Bye!'),
            ],
            headers={'This': 'him@mail.com'},
        )

    def test_prepare(self, envelope):
        mime = envelope.prepare()

        assert mime['Subject'] == 'hi!'
        assert mime['From'] == 'sender <me@mail.com>'
        assert mime['To'] == 'him@mail.com'
        assert mime['This'] == 'him@mail.com'

    def test_put_headers(self, envelope):
        headers = {}
        envelope.put_headers(headers)

        assert headers == {'This': 'him@mail.com'}

@@ -7,16 +7,54 @@
  pytest%0A
+from email import message_from_string%0A
 from mai
@@ -565,72 +565,35 @@
 def 
-test_prepare(self, envelope):%0A        mime = envelope.prepare()%0A
+match_headers(self, mime): 
 %0A   
@@ -727,16 +727,16 @@
 il.com'%0A
-
         
@@ -774,16 +774,253 @@
 l.com'%0A%0A
+    def test_prepare(self, envelope):%0A        mime = envelope.prepare()%0A        self.match_headers(mime)%0A%0A    def test_to_string(self, envelope):%0A        mime = message_from_string(envelope.to_string())%0A        self.match_headers(mime)%0A%0A
     def 

test Envelope.to_string