parent
597d6ecd3c
commit
f07b940bc5
3 changed files with 45 additions and 21 deletions
|
@ -3,7 +3,7 @@ import unittest
|
|||
from app import app
|
||||
from initdb import setup_database_for_testing, finished_database_for_testing
|
||||
from data import model
|
||||
from data.database import RepositoryBuild
|
||||
from data.database import RepositoryBuild, Repository, Image, ImageStorage
|
||||
|
||||
ADMIN_ACCESS_USER = 'devtable'
|
||||
SIMPLE_REPO = 'simple'
|
||||
|
@ -45,5 +45,24 @@ class TestSpecificQueries(unittest.TestCase):
|
|||
self.assertEquals(created.id, result.id)
|
||||
self.assertEquals(created.uuid, result.uuid)
|
||||
|
||||
def test_lookup_repo_blob(self):
|
||||
repo = model.repository.get_repository(ADMIN_ACCESS_USER, SIMPLE_REPO)
|
||||
expected = list(ImageStorage.select().join(Image).where(Image.repository == repo))
|
||||
self.assertTrue(len(expected) > 0)
|
||||
|
||||
for storage in expected:
|
||||
found = model.blob.get_repo_blob_by_digest(ADMIN_ACCESS_USER, SIMPLE_REPO,
|
||||
storage.content_checksum)
|
||||
self.assertEquals(found.id, storage.id)
|
||||
|
||||
try:
|
||||
model.blob.get_repo_blob_by_digest(ADMIN_ACCESS_USER, SIMPLE_REPO, 'invalidchecksum')
|
||||
except model.BlobDoesNotExist:
|
||||
return
|
||||
|
||||
self.fail('Expected BlobDoesNotExist exception')
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Reference in a new issue