Example #1
0
 def test_delete_header(self):
     d = HeaderCollection()
     d['Content-Type'] = 'test'
     d['Test'] = 'test'
     assert d.get('Content-Type')
     del d['Content-Type']
     assert not d.get('Content-Type')
Example #2
0
 def test_add_header(self):
     d = HeaderCollection()
     d.add('CONTENT_TYPE', 'text/html')
     d.add('HOST', '127.0.0.1')
     assert d.get('Content-Type') == 'text/html'
     assert d.get('CONTENT_TYPE') == 'text/html'
Example #3
0
 def test_get_header_doesnt_exist(self):
     d = HeaderCollection()
     assert not d.get('test', option='charset', default=None)
Example #4
0
 def test_add_option(self):
     d = HeaderCollection()
     d.add('CONTENT_TYPE', 'text/html', charset='utf-8')
     assert d.get('Content-Type') == 'text/html; charset=utf-8'
     assert d.get_option('Content-Type', 'charset') == 'utf-8'
     assert d.get_option('Content-Type', 'random', 'test') == 'test'
 def test_get_header_doesnt_exist(self):
     d = HeaderCollection()
     assert not d.get('test', option='charset', default=None)
     d = HeaderCollection({'CONTENT_TYPE': ''})
     assert d.get('Content-Type', default='utf-8') == 'utf-8'
     assert not d.get('Content-Type')