pyramid/bodhi/bodhi/__init__.py | 2 +- pyramid/bodhi/bodhi/models/models.py | 2 +- pyramid/bodhi/bodhi/resources.py | 12 ------------ pyramid/bodhi/bodhi/tests/models/__init__.py | 4 +++- pyramid/bodhi/bodhi/tests/views/test_views.py | 9 ++++++++- pyramid/bodhi/bodhi/views.py | 1 - 6 files changed, 13 insertions(+), 17 deletions(-)
New commits: commit 68dfb2839a3391109120805c322e620dd4866992 Author: Luke Macken lmacken@redhat.com Date: Sat May 14 12:41:55 2011 -0400
Add a functional test for our view_model
diff --git a/pyramid/bodhi/bodhi/tests/models/__init__.py b/pyramid/bodhi/bodhi/tests/models/__init__.py index 2a40c9a..fe75486 100644 --- a/pyramid/bodhi/bodhi/tests/models/__init__.py +++ b/pyramid/bodhi/bodhi/tests/models/__init__.py @@ -10,7 +10,9 @@ from bodhi.tests import setup_db, teardown_db
def setup(): """Function called by nose on module load""" - setup_db() + # Doesn't appear to be necessary as long as our functional test suite + # runs first (which sets up the DBSession) + #setup_db()
def teardown(): """Function called by nose after all tests in this module ran""" diff --git a/pyramid/bodhi/bodhi/tests/views/test_views.py b/pyramid/bodhi/bodhi/tests/views/test_views.py index b397a2e..f7477c7 100644 --- a/pyramid/bodhi/bodhi/tests/views/test_views.py +++ b/pyramid/bodhi/bodhi/tests/views/test_views.py @@ -11,9 +11,16 @@ class ViewTests(unittest.TestCase): def tearDown(self): testing.tearDown()
- def test_view_model(self): + def test_view_model_instance(self): from bodhi.views import view_model_instance request = testing.DummyRequest() context = DBSession.query(Release).first() info = view_model_instance(context, request) self.assertEqual(info['context'], context.__json__()) + + def test_view_model(self): + from bodhi.resources import ReleaseResource + from bodhi.views import view_model + request = testing.DummyRequest() + info = view_model(ReleaseResource, request) + self.assertEqual(len(info['entries']), 2) diff --git a/pyramid/bodhi/bodhi/views.py b/pyramid/bodhi/bodhi/views.py index 1921c47..b0b70dc 100644 --- a/pyramid/bodhi/bodhi/views.py +++ b/pyramid/bodhi/bodhi/views.py @@ -7,7 +7,6 @@ def view_model_instance(context, request): return {'context': context.__json__()}
def view_model(context, request): - print "view_model(%s)" % context session = DBSession() # TODO: pagination entries = session.query(context.__model__).all()
commit f04584fbdbecec4e0a84dbe1fc1c1dcae2642eaf Author: Luke Macken lmacken@redhat.com Date: Sat May 14 12:41:28 2011 -0400
Remove some unnecessary methods from our root resource
diff --git a/pyramid/bodhi/bodhi/resources.py b/pyramid/bodhi/bodhi/resources.py index eb08470..ece7056 100644 --- a/pyramid/bodhi/bodhi/resources.py +++ b/pyramid/bodhi/bodhi/resources.py @@ -19,18 +19,6 @@ class BodhiRoot(object): resource.__name__ = key return resource
- def get(self, key, default=None): - try: - item = self.__getitem__(key) - except KeyError: - item = default - return item - - def __iter__(self): - session = DBSession() - query = session.query(self.__model__) - return iter(query) -
class BodhiResource(object): __name__ = None
commit d28c2d009a33b9e9ff1dedb7a086bf60fde57c06 Author: Luke Macken lmacken@redhat.com Date: Sat May 14 12:41:19 2011 -0400
No need to config.scan until we use the @view_config decorator
diff --git a/pyramid/bodhi/bodhi/__init__.py b/pyramid/bodhi/bodhi/__init__.py index c0a696c..2f0099f 100644 --- a/pyramid/bodhi/bodhi/__init__.py +++ b/pyramid/bodhi/bodhi/__init__.py @@ -34,5 +34,5 @@ def main(global_config, **settings): config.add_view('bodhi.views.view_model', context='bodhi.resources.BodhiResource', renderer='json') - config.scan() + #config.scan() return config.make_wsgi_app()
commit cda947c8b8a22845b82956840bb7e6fde2dd0d12 Author: Luke Macken lmacken@redhat.com Date: Sat May 14 12:41:06 2011 -0400
notes are mandatory now
diff --git a/pyramid/bodhi/bodhi/models/models.py b/pyramid/bodhi/bodhi/models/models.py index a947e1b..0cefdf0 100644 --- a/pyramid/bodhi/bodhi/models/models.py +++ b/pyramid/bodhi/bodhi/models/models.py @@ -995,7 +995,7 @@ def populate(): session.add(pkg) build = Build(nvr=u'bodhi-2.0-1.fc15', release=release) session.add(build) - update = Update(builds=[build], user=user) + update = Update(builds=[build], user=user, notes=u'Useful details!') update.type = UpdateType.bugfix session.add(update) session.commit()