def test_get_loose_object(self): blob = make_object(Blob, data='foo') backend = _test_backend([blob]) mat = re.search('^(..)(.{38})$', blob.id) output = ''.join(get_loose_object(self._req, backend, mat)) self.assertEquals(blob.as_legacy_object(), output) self.assertEquals(HTTP_OK, self._status) self.assertContentTypeEquals('application/x-git-loose-object') self.assertTrue(self._req.cached)
def test_get_loose_object(self): blob = make_object(Blob, data=b"foo") backend = _test_backend([blob]) mat = re.search("^(..)(.{38})$", blob.id.decode("ascii")) output = b"".join(get_loose_object(self._req, backend, mat)) self.assertEqual(blob.as_legacy_object(), output) self.assertEqual(HTTP_OK, self._status) self.assertContentTypeEquals("application/x-git-loose-object") self.assertTrue(self._req.cached)
def test_get_loose_object_error(self): blob = make_object(Blob, data='foo') backend = _test_backend([blob]) mat = re.search('^(..)(.{38})$', blob.id) def as_legacy_object_error(): raise IOError blob.as_legacy_object = as_legacy_object_error list(get_loose_object(self._req, backend, mat)) self.assertEquals(HTTP_ERROR, self._status)
def test_get_loose_object_error(self): blob = make_object(Blob, data=b"foo") backend = _test_backend([blob]) mat = re.search("^(..)(.{38})$", blob.id.decode("ascii")) def as_legacy_object_error(self): raise IOError self.addCleanup(setattr, Blob, "as_legacy_object", Blob.as_legacy_object) Blob.as_legacy_object = as_legacy_object_error list(get_loose_object(self._req, backend, mat)) self.assertEqual(HTTP_ERROR, self._status)
def test_get_loose_object_error(self): blob = make_object(Blob, data=b'foo') backend = _test_backend([blob]) mat = re.search('^(..)(.{38})$', blob.id.decode('ascii')) def as_legacy_object_error(self): raise IOError self.addCleanup( setattr, Blob, 'as_legacy_object', Blob.as_legacy_object) Blob.as_legacy_object = as_legacy_object_error list(get_loose_object(self._req, backend, mat)) self.assertEqual(HTTP_ERROR, self._status)
def test_get_loose_object_missing(self): mat = re.search('^(..)(.{38})$', '1' * 40) list(get_loose_object(self._req, _test_backend([]), mat)) self.assertEquals(HTTP_NOT_FOUND, self._status)