def test_md5_etag(): res = Response() res.body = b"""\ In A.D. 2101 War was beginning. Captain: What happen ? Mechanic: Somebody set up us the bomb. Operator: We get signal. Captain: What ! Operator: Main screen turn on. Captain: It's You !! Cats: How are you gentlemen !! Cats: All your base are belong to us. Cats: You are on the way to destruction. Captain: What you say !! Cats: You have no chance to survive make your time. Cats: HA HA HA HA .... Captain: Take off every 'zig' !! Captain: You know what you doing. Captain: Move 'zig'. Captain: For great justice.""" res.md5_etag() assert res.etag assert '\n' not in res.etag assert res.etag == 'pN8sSTUrEaPRzmurGptqmw' assert res.content_md5 is None
def test_response_copy_content_md5(): res = Response() res.md5_etag(set_content_md5=True) assert res.content_md5 res2 = res.copy() assert res.content_md5 assert res2.content_md5 assert res.content_md5 == res2.content_md5
def test_md5_etag_set_content_md5(): res = Response() body = b'The quick brown fox jumps over the lazy dog' res.md5_etag(body, set_content_md5=True) assert res.content_md5 == 'nhB9nTcrtoJr2B01QqQZ1g=='
def test_md5_etag_set_content_md5(): res = Response() body = b"The quick brown fox jumps over the lazy dog" res.md5_etag(body, set_content_md5=True) eq_(res.content_md5, "nhB9nTcrtoJr2B01QqQZ1g==")