Skip to content

Commit 1cb59cc

Browse files
committed
Fix /info/packages tests failing
Seems to be logic error introduced by sqlalchemy update
1 parent 356edca commit 1cb59cc

File tree

2 files changed

+40
-11
lines changed

2 files changed

+40
-11
lines changed

orlo/route_info.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,16 @@ def info_packages(package=None):
8484
platform = request.args.get('platform')
8585

8686
if package:
87-
packages = queries.package_info(package)
87+
packages = queries.package_info(package).all()
8888
else:
89-
packages = queries.package_summary(platform=platform)
89+
packages = queries.package_summary(platform=platform).all()
9090

9191
d = {}
9292

9393
for package, count in packages:
9494
d[package] = {'releases': count}
95-
return jsonify(packages), 200
95+
96+
return jsonify(d), 200
9697

9798

9899
@app.route('/info/packages/list', methods=['GET'])

tests/test_queries.py

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import orlo.exceptions
77
import orlo.stats
88
from time import sleep
9+
import sqlalchemy.orm
910

1011
__author__ = 'alforbes'
1112

@@ -183,6 +184,13 @@ def test_package_summary(self):
183184
self.assertIn('packageOne', packages)
184185
self.assertIn('packageTwo', packages)
185186

187+
def test_package_summary_returns_query(self):
188+
rid1 = self._create_release()
189+
self._create_package(rid1, name='packageOne')
190+
191+
result = orlo.queries.package_summary()
192+
self.assertIsInstance(result, sqlalchemy.orm.query.Query)
193+
186194
def test_package_summary_with_platform(self):
187195
"""
188196
Test package_summary
@@ -320,20 +328,40 @@ def test_package_versions_with_rollback(self):
320328
self.assertIn(('packageOne', '1.0.1'), versions)
321329

322330

331+
class TestInfo(OrloQueryTest):
332+
"""
333+
Test the _info functions
334+
"""
335+
336+
def _create_test_package(self):
337+
rid = self._create_release(platforms=['platformOne'])
338+
pid = self._create_package(rid, name='packageOne', version='1.0.1')
339+
return pid
340+
341+
def test_returns_query(self):
342+
"""
343+
Assert that package_info should return a query
344+
"""
345+
self._create_test_package()
346+
result = orlo.queries.package_info('packageOne')
347+
self.assertIsInstance(result, sqlalchemy.orm.query.Query)
348+
349+
323350
class TestCountReleases(OrloQueryTest):
324351
"""
325352
Parent class for testing the CountReleases function
326353
327-
By subclassing it and overriding ARGS, we can test different combinations of arguments
328-
with the same test code.
354+
By subclassing it and overriding ARGS, we can test different combinations of
355+
arguments with the same test code.
329356
330-
INCLUSIVE_ARGS represents a set of arguments that will match the releases created (see
331-
the functions in OrloQueryTest for what those are)
332-
EXCLUSIVE_ARGS represents a set of arguments that will not match any releases created,
333-
i.e. should return a count of zero
357+
INCLUSIVE_ARGS represents a set of arguments that will match the releases
358+
created (see the functions in OrloQueryTest for what those are)
359+
EXCLUSIVE_ARGS represents a set of arguments that will not match any
360+
releases created, i.e. should return a count of zero
334361
335-
This parent class has tests that should be the same result no matter what the arguments
336-
(except the exclusive case which must always a count of zero so we define it here)
362+
This parent class has tests that should be the same result no matter what
363+
the arguments (except the exclusive case which must always a count of zero
364+
so we define it here)
337365
"""
338366

339367
INCLUSIVE_ARGS = {} # Args we are testing, result should include these

0 commit comments

Comments
 (0)