diff options
author | 2010-07-29 11:27:41 +0300 | |
---|---|---|
committer | 2010-07-29 11:27:41 +0300 | |
commit | f9ce681937a77e770254af844f85f1bd14b29ba6 (patch) | |
tree | 00c10e91ec77b233f10785b1efc3abc1c0fa722a | |
parent | Keep classes in alphabetic order (diff) | |
download | gsoc2010-grumpy-f9ce681937a77e770254af844f85f1bd14b29ba6.tar.gz gsoc2010-grumpy-f9ce681937a77e770254af844f85f1bd14b29ba6.tar.bz2 gsoc2010-grumpy-f9ce681937a77e770254af844f85f1bd14b29ba6.zip |
Clean up testsuite a bit
-rw-r--r-- | grumpy/testsuite/favorites.py | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/grumpy/testsuite/favorites.py b/grumpy/testsuite/favorites.py index ab9548f..a5958e2 100644 --- a/grumpy/testsuite/favorites.py +++ b/grumpy/testsuite/favorites.py @@ -18,36 +18,37 @@ import time, unittest class FavoritesTestCase(GrumpyTestCase): def make_users(self): - self.db.session.add_all([\ - User('user1@gentoo.org', 'http://example.net/openid1'), - User('user2@gentoo.org', 'http://example.net/openid2')]) + u = [User('user1@gentoo.org', 'http://example.net/openid1'), + User('user2@gentoo.org', 'http://example.net/openid2')] + self.db.session.add_all(u) self.db.session.commit() + return u def make_packages(self): - p1 = Package('sys-misc', 'testpkg', 'Test Package', \ - 'Long Description', 'http://example.com/test', \ - time.time()) - p1.ebuilds.append(Ebuild(p1, '1.0', 2, 0, 'x86,amd64', 'doc', '')) - p1.ebuilds.append(Ebuild(p1, '1.1', 2, 0, '~x86,~amd64', 'doc', '')) - p2 = Package('sys-devel', 'testpkg', 'Test Package 2', \ - 'Long Description 2', 'http://example.com/test2', \ - time.time()) - p2.ebuilds.append(Ebuild(p1, '0.1', 2, 0, 'x86,amd64', 'doc', '')) - self.db.session.add_all([p1, p2]) + p = [] + p.append(Package('sys-misc', 'testpkg', 'Test Package', \ + 'Long Description', 'http://example.com/test', \ + time.time())) + p[0].ebuilds.append(Ebuild(p[0], '1.0', 2, 0, 'x86,amd64', 'doc', '')) + p[0].ebuilds.append(Ebuild(p[0], '1.1', 2, 0, '~x86,~amd64', 'doc', '')) + p.append(Package('sys-devel', 'testpkg', 'Test Package 2', \ + 'Long Description 2', 'http://example.com/test2', \ + time.time())) + p[1].ebuilds.append(Ebuild(p[1], '0.1', 2, 0, 'x86,amd64', 'doc', '')) + self.db.session.add_all(p) self.db.session.commit() + return p def test_favorites(self): with self.app.test_request_context(): - self.make_users() - self.make_packages() + _u = self.make_users() + _p = self.make_packages() assert User.query.count() == 2 assert Package.query.count() == 2 - u = User.query.filter_by(email='user1@gentoo.org').first() - p = Package.query.filter_by(cp='testpkg/sys-devel').first() - u.favorites.append(Favorite(p)) - p = Package.query.filter_by(cp='testpkg/sys-misc').first() - u.favorites.append(Favorite(p)) + u = _u[0] + u.favorites.append(Favorite(_p[0])) + u.favorites.append(Favorite(_p[1])) self.db.session.commit() assert Favorite.query.count() == 2 @@ -55,18 +56,18 @@ class FavoritesTestCase(GrumpyTestCase): def test_favorites_uniqueness(self): with self.app.test_request_context(): - self.make_users() - self.make_packages() - u = User.query.filter_by(email='user1@gentoo.org').first() - p = Package.query.filter_by(cp='testpkg/sys-devel').first() - u.favorites.append(Favorite(p)) + _u = self.make_users() + _p = self.make_packages() + + u = _u[0] + u.favorites.append(Favorite(_p[0])) self.db.session.commit() - u.favorites.append(Favorite(p)) + + u.favorites.append(Favorite(_p[0])) self.assertRaises(IntegrityError, self.db.session.commit) self.db.session.rollback() assert len(u.favorites) == 1 - def suite(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(FavoritesTestCase)) |