bodhi/controllers.py | 11 ++++++-- bodhi/tests/test_controllers.py | 49 ++++++++++++++++++++++++++++++++++++++++ bodhi/tools/tagcheck.py | 4 +-- 3 files changed, 59 insertions(+), 5 deletions(-)
New commits: commit 5ac115ff389c0c736d0204e6b2eda2552f30346f Author: Luke Macken lmacken@redhat.com Date: Fri Jan 15 15:54:59 2010 -0500
Add a pushed_since argument to our query API
diff --git a/bodhi/controllers.py b/bodhi/controllers.py index f0c0605..63b61a4 100644 --- a/bodhi/controllers.py +++ b/bodhi/controllers.py @@ -223,11 +223,12 @@ class Root(controllers.RootController): 'username': validators.UnicodeString(), 'count_only': validators.StringBool(), 'created_since': validators.UnicodeString(), + 'pushed_since': validators.UnicodeString(), }) def list(self, release=None, bugs=None, cves=None, status=None, type_=None, package=None, mine=False, get_auth=False, username=None, start_date=None, end_date=None, count_only=False, - created_since=None, **kw): + created_since=None, pushed_since=None, **kw): """ Return a list of updates based on given parameters """ log.debug('list(%s)' % locals()) query = [] @@ -241,7 +242,8 @@ class Root(controllers.RootController):
# If no arguments are specified, return the most recent updates if not release and not bugs and not cves and not status and not type_ \ - and not package and not mine and not username and not created_since: + and not package and not mine and not username and not created_since \ + and not pushed_since: log.debug("No arguments, returning latest") updates = PackageUpdate.select(orderBy=orderBy).reversed() num_items = updates.count() @@ -272,8 +274,11 @@ class Root(controllers.RootController): if created_since: created_since = datetime(*time.strptime(created_since, '%Y-%m-%d %H:%M:%S')[:-2]) - log.debug('Querying updates created since %s' % created_since) query.append(PackageUpdate.q.date_submitted >= created_since) + if pushed_since: + pushed_since = datetime(*time.strptime(pushed_since, + '%Y-%m-%d %H:%M:%S')[:-2]) + query.append(PackageUpdate.q.date_pushed >= pushed_since) if start_date: start_date = datetime(*time.strptime(start_date, '%Y-%m-%d %H:%M:%S')[:-2]) diff --git a/bodhi/tests/test_controllers.py b/bodhi/tests/test_controllers.py index b63c9c6..4ba206e 100644 --- a/bodhi/tests/test_controllers.py +++ b/bodhi/tests/test_controllers.py @@ -1558,6 +1558,55 @@ class TestControllers(testutil.DBTest): json = simplejson.loads(cherrypy.response.body[0]) assert json['num_items'] == 0
+ def test_pushed_since(self): + session = login() + create_release() + params = { + 'builds' : 'kernel-2.6.31-1.fc7', + 'release' : 'Fedora 7', + 'type_' : 'bugfix', + 'bugs' : '', + 'notes' : 'foobar', + 'stable_karma' : 1, + 'request': None, + 'unstable_karma' : -1, + } + self.save_update(params, session) + update = PackageUpdate.byTitle(params['builds']) + + # Pretend it's pushed to stable + update.pushed = True + update.status = 'stable' + update.date_pushed = datetime(2010, 01, 01, 12, 00, 00) + + ## Test web UI + testutil.create_request('/updates/list?%s' % + urlencode({'pushed_since': str(update.date_pushed)}), + method='GET', headers=session) + + assert '1 update found' in cherrypy.response.body[0] + assert 'kernel-2.6.31-1.fc7' in cherrypy.response.body[0] + + ## Test JSON API + testutil.create_request('/updates/list?%s' % + urlencode({'pushed_since': str(update.date_pushed), + 'tg_format': 'json'}), + method='GET', headers=session) + + json = simplejson.loads(cherrypy.response.body[0]) + assert json['num_items'] == 1 + assert json['updates'][0]['title'] == params['builds'] + + testutil.create_request('/updates/list?%s' % + urlencode({ + 'tg_format': 'json', + 'pushed_since': str(update.date_pushed + timedelta(days=1)), + }), + method='GET', headers=session) + + json = simplejson.loads(cherrypy.response.body[0]) + assert json['num_items'] == 0 + def test_query_limit(self): session = login() create_release()
commit 62bce2dc04fad0b8d1215b9c9679a6d039e611d3 Author: Luke Macken lmacken@redhat.com Date: Fri Jan 15 15:41:27 2010 -0500
Only compare against the latest tagged builds in bodhi-tagcheck
diff --git a/bodhi/tools/tagcheck.py b/bodhi/tools/tagcheck.py index 5e54bb5..c80603f 100755 --- a/bodhi/tools/tagcheck.py +++ b/bodhi/tools/tagcheck.py @@ -35,7 +35,7 @@ def main(): # Check all candidate updates to see if they are in a different bodhi state for release in Release.select(): tag = release.candidate_tag - tagged = [build['nvr'] for build in koji.listTagged(tag)] + tagged = [build['nvr'] for build in koji.listTagged(tag, latest=True)] for nvr in tagged: try: build = PackageBuild.byNvr(nvr) @@ -58,7 +58,7 @@ def main(): # in bodhi, and are in the expect state. for release in Release.select(): for tag in (release.testing_tag, release.stable_tag): - tagged = [build['nvr'] for build in koji.listTagged(tag)] + tagged = [build['nvr'] for build in koji.listTagged(tag, latest=True)] for nvr in tagged: try: build = PackageBuild.byNvr(nvr)