Ejemplo n.º 1
0
def headers_transform_test():
    headers = [('mime-version', '1'), ('rEceived', '2'), ('mime-version', '3'), ('ReceiveD', '4')]

    h = MimeHeaders(headers)

    # transform tracks whether anything actually changed
    h.transform(lambda key,val: (key, val))
    assert_false(h.have_changed())

    # ok, now something have changed, make sure we've preserved order and did not collapse anything
    h.transform(lambda key,val: ("X-{0}".format(key), "t({0})".format(val)))
    ok_(h.have_changed())

    eq_([('X-Mime-Version', 't(1)'), ('X-Received', 't(2)'), ('X-Mime-Version', 't(3)'), ('X-Received', 't(4)')], h.items())
Ejemplo n.º 2
0
def headers_transform_test():
    headers = [('mime-version', '1'), ('rEceived', '2'), ('mime-version', '3'),
               ('ReceiveD', '4')]

    h = MimeHeaders(headers)

    # transform tracks whether anything actually changed
    h.transform(lambda key, val: (key, val))
    assert_false(h.have_changed())

    # ok, now something have changed, make sure we've preserved order and did not collapse anything
    h.transform(lambda key, val: ("X-{0}".format(key), "t({0})".format(val)))
    ok_(h.have_changed())

    eq_([('X-Mime-Version', 't(1)'), ('X-Received', 't(2)'),
         ('X-Mime-Version', 't(3)'), ('X-Received', 't(4)')], h.items())
Ejemplo n.º 3
0
def headers_transform_test():
    headers = [("mime-version", "1"), ("rEceived", "2"), ("mime-version", "3"), ("ReceiveD", "4")]

    h = MimeHeaders(headers)

    # transform tracks whether anything actually changed
    h.transform(lambda key, val: (key, val))
    assert_false(h.have_changed())

    # ok, now something have changed, make sure we've preserved order and did not collapse anything
    h.transform(lambda key, val: ("X-{}".format(key), "t({})".format(val)))
    ok_(h.have_changed())

    eq_(
        [("X-Mime-Version", "t(1)"), ("X-Received", "t(2)"), ("X-Mime-Version", "t(3)"), ("X-Received", "t(4)")],
        h.items(),
    )
Ejemplo n.º 4
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())
Ejemplo n.º 5
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())
Ejemplo n.º 6
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())