def test_response_file(self, test_dir): request = Request() file = os.path.join(test_dir, 'test.html') with open(file, 'wb') as f: f.write(b'012345') response = Response.response_file(request, file, 'text/html') assert response.status == 200 assert response.message == 'OK' assert response.headers.get('Content-Length') == 6 assert response.body == b'012345'
def test_response_file_range_withoud_end(self, test_dir): request = Request() request.headers['Range'] = 'bytes=2-' file = os.path.join(test_dir, 'test.html') with open(file, 'wb') as f: f.write(b'012345') response = Response.response_file(request, file, 'text/html') assert response.status == 206 assert response.message == 'Partial Content' assert response.headers.get('Content-Length') == 4 assert response.body == b'2345'