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())
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())
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())
def headers_multiple_values_test(): headers = [('mime-version', '1'), ('rEceived', '2'), ('mime-version', '3'), ('ReceiveD', '4')] h = MimeHeaders(headers) eq_(['1', '3'], h.getall('Mime-Version')) # set re-sets all values for the message h['Mime-Version'] = '5' eq_(['5'], h.getall('Mime-Version')) # use add to add more values h.add('Received', '6') eq_(['2', '4', '6'], h.getall('Received')) # use prepend to insert header in the begining of the list h.prepend('Received', '0') eq_(['0', '2', '4', '6'], h.getall('Received')) # delete removes it all! del h['RECEIVED'] eq_([], h.getall('Received'))
def headers_multiple_values_test(): headers = [("mime-version", "1"), ("rEceived", "2"), ("mime-version", "3"), ("ReceiveD", "4")] h = MimeHeaders(headers) eq_(["1", "3"], h.getall("Mime-Version")) # set re-sets all values for the message h["Mime-Version"] = "5" eq_(["5"], h.getall("Mime-Version")) # use add to add more values h.add("Received", "6") eq_(["2", "4", "6"], h.getall("Received")) # use prepend to insert header in the begining of the list h.prepend("Received", "0") eq_(["0", "2", "4", "6"], h.getall("Received")) # delete removes it all! del h["RECEIVED"] eq_([], h.getall("Received"))
def headers_multiple_values_test(): headers = [('mime-version', '1'), ('rEceived', '2'), ('mime-version', '3'), ('ReceiveD', '4')] h = MimeHeaders(headers) eq_(['1', '3'], h.getall('Mime-Version')) # set re-sets all values for the message h['Mime-Version'] = '5' eq_(['5'], h.getall('Mime-Version')) # use add to add more values h.add('Received', '1') eq_(['1', '2', '4'], h.getall('Received')) # use prepend to insert header in the begining of the list h.prepend('Received', '0') eq_(['0', '1', '2', '4'], h.getall('Received')) # delete removes it all! del h['RECEIVED'] eq_([], h.getall('Received'))