This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/test/test_queries.py
Joseph Schorr 474fffd01f Select the full RepositoryBuild record
If we just return the ID, then peewee just fills in the other fields with defaults (such as UUID).
2015-09-09 21:43:48 -04:00

49 lines
No EOL
1.6 KiB
Python

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
ADMIN_ACCESS_USER = 'devtable'
SIMPLE_REPO = 'simple'
class TestSpecificQueries(unittest.TestCase):
def setUp(self):
setup_database_for_testing(self)
self.app = app.test_client()
self.ctx = app.test_request_context()
self.ctx.__enter__()
def tearDown(self):
finished_database_for_testing(self)
self.ctx.__exit__(True, None, None)
def test_archivable_buildlogs(self):
# Make sure there are no archivable logs.
result = model.build.get_archivable_build()
self.assertIsNone(result)
# Add a build that cannot (yet) be archived.
repo = model.repository.get_repository(ADMIN_ACCESS_USER, SIMPLE_REPO)
token = model.token.create_access_token(repo, 'write')
created = RepositoryBuild.create(repository=repo, access_token=token,
phase=model.build.BUILD_PHASE.WAITING,
logs_archived=False, job_config='{}',
display_name='')
# Make sure there are no archivable logs.
result = model.build.get_archivable_build()
self.assertIsNone(result)
# Change the build to being complete.
created.phase = model.build.BUILD_PHASE.COMPLETE
created.save()
# Make sure we now find an archivable build.
result = model.build.get_archivable_build()
self.assertEquals(created.id, result.id)
self.assertEquals(created.uuid, result.uuid)
if __name__ == '__main__':
unittest.main()