def test_range_header_invallid_header(self):
     self.request.headers['Range'] = 'items=0->19'
     error = None
     error_thrown = False
     try:
         Range.parse(self.request)
     except Exception as e:
         error = e
         error_thrown = True
     self.assertTrue(error_thrown)
     self.assertEqual('range header does not match expected format', str(error))
 def test_set_response_headers_no_length(self):
     self.request.headers['Range'] = 'items=0-19'
     range = Range.parse(self.request)
     response = Mock()
     self.assertRaises(RangeParseException,range.set_response_headers, response, None)
 def test_set_response_headers(self):
     self.request.headers['Range'] = 'items=0-19'
     range = Range.parse(self.request)
     response = Mock()
     range.set_response_headers(response, 50)
     self.assertEqual('items 0-19/50', response.content_range)
 def test_get_page_size(self):
     self.request.params['page'] = 2
     range = Range.parse(self.request)
     self.assertEqual(12, range.get_page_size())
 def test_content_range(self):
     self.request.params['pagina'] = 2
     range = Range.parse(self.request)
     self.assertEqual('items 12-23/35', range.content_range(35))
 def test_range_page_5(self):
     self.request.params['pagina'] = 5
     range = Range.parse(self.request)
     self.assertEqual(48, range.start)
     self.assertEqual(59, range.end)
 def test_range_page(self):
     self.request.params['pagina'] = 2
     range = Range.parse(self.request)
     self.assertEqual(12, range.start)
     self.assertEqual(23, range.end)
 def test_range_header_max_end(self):
     self.request.headers['Range'] = 'items=0-75'
     range = Range.parse(self.request)
     self.assertEqual(0, range.start)
     self.assertEqual(50, range.end)
 def test_range_header_incorrect_end(self):
     self.request.headers['Range'] = 'items=5-2'
     range = Range.parse(self.request)
     self.assertEqual(5, range.start)
     self.assertEqual(5, range.end)
 def test_range_header(self):
     self.request.headers['Range'] = 'items=0-19'
     range = Range.parse(self.request)
     self.assertEqual(0, range.start)
     self.assertEqual(19, range.end)
 def test_range(self):
     range = Range.parse(self.request)
     self.assertEqual(0, range.start)
     self.assertEqual(11, range.end)