示例#1
0
 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)
示例#2
0
 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)
示例#3
0
 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)
示例#4
0
    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)
示例#5
0
    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)
示例#6
0
    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)
示例#8
0
 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)
示例#9
0
 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)