Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

new tests for http byte range support

  • Loading branch information...
commit 416930ea4541215cb9f5e3134cee50d038aa195c 1 parent fbceaae
@heroldus heroldus authored
Showing with 25 additions and 0 deletions.
  1. +25 −0 src/main/python/yum_repo_server/api/test/testStaticRepo.py
View
25 src/main/python/yum_repo_server/api/test/testStaticRepo.py
@@ -100,6 +100,31 @@ def test_upload_rpm_to_repo(self):
uploaded_file_path = repo_path + Constants.TEST_RPM_DESTINATION_NAME
self.assertTrue(os.path.isfile(uploaded_file_path))
+ def test_range_download(self):
+ repo_name = self.createNewRepoAndAssertValid()
+ testRPMFilePath = Constants.TEST_RPM_FILE_LOC + Constants.TEST_RPM_FILE_NAME
+ self.upload_testfile(repo_name, testRPMFilePath)
+ response = self.helper.do_http_get(Constants.HTTP_PATH_STATIC + '/' + repo_name + '/' + Constants.TEST_RPM_DESTINATION_NAME, headers={'Range' : 'bytes=0-100'})
+ self.assertStatusCode(response, 206)
+ self.assertEqual(response.getheader('Accept-Ranges'), 'bytes')
+ self.assertEqual(response.getheader('Content-Length'), '101')
+ self.assertEqual(response.getheader('Content-Range'), 'bytes 0-100/143792')
+ #self.assertEqual(response.getheader('Connection'), 'close')
+ self.assertEqual(len(response.read()), 101)
+
+ def test_range_download_not_statifiable(self):
+ repo_name = self.createNewRepoAndAssertValid()
+ testRPMFilePath = Constants.TEST_RPM_FILE_LOC + Constants.TEST_RPM_FILE_NAME
+ self.upload_testfile(repo_name, testRPMFilePath)
+ response = self.helper.do_http_get(Constants.HTTP_PATH_STATIC + '/' + repo_name + '/' + Constants.TEST_RPM_DESTINATION_NAME, headers={'Range' : 'bytes=100-2000'})
+ self.assertStatusCode(response, 416)
+ response = self.helper.do_http_get(Constants.HTTP_PATH_STATIC + '/' + repo_name + '/' + Constants.TEST_RPM_DESTINATION_NAME, headers={'Range' : 'bytes=10-0'})
+ self.assertStatusCode(response, 416)
+ response = self.helper.do_http_get(Constants.HTTP_PATH_STATIC + '/' + repo_name + '/' + Constants.TEST_RPM_DESTINATION_NAME, headers={'Range' : 'records=100-200'})
+ self.assertStatusCode(response, 416)
+ response = self.helper.do_http_get(Constants.HTTP_PATH_STATIC + '/' + repo_name + '/' + Constants.TEST_RPM_DESTINATION_NAME, headers={'Range' : 'bytes=2000-3000'})
+ self.assertStatusCode(response, 416)
+
def given_rpm_in_repository(self, repo_name):
testRPMFilePath = Constants.TEST_RPM_FILE_LOC + Constants.TEST_RPM_FILE_NAME
Please sign in to comment.
Something went wrong with that request. Please try again.