예제 #1
0
def headers_alternation_test():
    headers = [('mime-version', '1'), ('rEceived', '2'), ('mime-version', '3'), ('ReceiveD', '4')]

    h = MimeHeaders(headers)
    assert_false(h.have_changed())

    h.prepend('Received', 'Yo')
    ok_(h.have_changed())

    h = MimeHeaders(headers)
    del h['Mime-Version']
    ok_(h.have_changed())

    h = MimeHeaders(headers)
    h['Mime-Version'] = 'a'
    ok_(h.have_changed())

    h = MimeHeaders(headers)
    h.add('Mime-Version', 'a')
    ok_(h.have_changed())

    h = MimeHeaders(headers)
    h.getall('Mime-Version')
    h.get('o')
    assert_false(h.have_changed())
예제 #2
0
def headers_alternation_test():
    headers = [("mime-version", "1"), ("rEceived", "2"), ("mime-version", "3"), ("ReceiveD", "4")]

    h = MimeHeaders(headers)
    assert_false(h.have_changed())

    h.prepend("Received", "Yo")
    ok_(h.have_changed())

    h = MimeHeaders(headers)
    del h["Mime-Version"]
    ok_(h.have_changed())

    h = MimeHeaders(headers)
    h["Mime-Version"] = "a"
    ok_(h.have_changed())

    h = MimeHeaders(headers)
    h.add("Mime-Version", "a")
    ok_(h.have_changed())

    h = MimeHeaders(headers)
    h.getall("Mime-Version")
    h.get("o")
    assert_false(h.have_changed())
예제 #3
0
def headers_alternation_test():
    headers = [('mime-version', '1'), ('rEceived', '2'), ('mime-version', '3'),
               ('ReceiveD', '4')]

    h = MimeHeaders(headers)
    assert_false(h.have_changed())

    h.prepend('Received', 'Yo')
    ok_(h.have_changed())

    h = MimeHeaders(headers)
    del h['Mime-Version']
    ok_(h.have_changed())

    h = MimeHeaders(headers)
    h['Mime-Version'] = 'a'
    ok_(h.have_changed())

    h = MimeHeaders(headers)
    h.add('Mime-Version', 'a')
    ok_(h.have_changed())

    h = MimeHeaders(headers)
    h.getall('Mime-Version')
    h.get('o')
    assert_false(h.have_changed())
예제 #4
0
def headers_case_insensitivity_test():
    h = MimeHeaders()
    h['Content-Type'] = 1
    eq_(1, h['Content-Type'])
    eq_(1, h['conTenT-TyPE'])
    ok_('cOnTenT-TyPE' in h)
    ok_('Content-Type' in h)
    eq_(1, h.get('Content-Type'))
    eq_(None, h.get('Content-Type2'))
    eq_([('Content-Type', 1)], h.items())
예제 #5
0
def headers_case_insensitivity_test():
    h = MimeHeaders()
    h["Content-Type"] = 1
    eq_(1, h["Content-Type"])
    eq_(1, h["conTenT-TyPE"])
    ok_("cOnTenT-TyPE" in h)
    ok_("Content-Type" in h)
    eq_(1, h.get("Content-Type"))
    eq_(None, h.get("Content-Type2"))
    eq_([("Content-Type", 1)], h.items())
예제 #6
0
def headers_case_insensitivity_test():
    h = MimeHeaders()
    h['Content-Type'] = 1
    eq_(1, h['Content-Type'])
    eq_(1, h['conTenT-TyPE'])
    ok_('cOnTenT-TyPE' in h)
    ok_('Content-Type' in h)
    eq_(1, h.get('Content-Type'))
    eq_(None, h.get('Content-Type2'))
    eq_([('Content-Type', 1)], h.items())
예제 #7
0
def headers_transform_encodedword_test():
    # Create a header with non-ascii characters that will be stored in encoded-word format.
    headers = [('Subject', encoding.to_mime('Subject', u'Hello ✓'))]
    h = MimeHeaders(headers)

    # transform should decode it for us when we pass decode=True
    h.transform(lambda key, val: (key, val.replace(u'✓', u'☃')), decode=True)
    eq_(u'Hello ☃', h.get('Subject'))
예제 #8
0
def headers_transform_encodedword_test():
    # Create a header with non-ascii characters that will be stored in encoded-word format.
    headers = [('Subject', encoding.to_mime('Subject', u'Hello ✓'))]
    h = MimeHeaders(headers)

    # transform should decode it for us when we pass decode=True
    h.transform(lambda key,val: (key, val.replace(u'✓', u'☃')), decode=True)
    eq_(u'Hello ☃', h.get('Subject'))