diff options
author | Priit Laes <plaes@plaes.org> | 2010-08-10 22:42:59 +0300 |
---|---|---|
committer | Priit Laes <plaes@plaes.org> | 2010-08-10 22:42:59 +0300 |
commit | 94e48fcad7d669c234292c3325bec118f1fc6479 (patch) | |
tree | 36c94babedadd78b1ce00762ba2c654cf263e979 | |
parent | Fix corner case in syncer (diff) | |
download | gsoc2010-grumpy-94e48fcad7d669c234292c3325bec118f1fc6479.tar.gz gsoc2010-grumpy-94e48fcad7d669c234292c3325bec118f1fc6479.tar.bz2 gsoc2010-grumpy-94e48fcad7d669c234292c3325bec118f1fc6479.zip |
Move package creation functionality to base class
-rw-r--r-- | grumpy/testsuite/__init__.py | 12 | ||||
-rw-r--r-- | grumpy/testsuite/favorites.py | 16 |
2 files changed, 14 insertions, 14 deletions
diff --git a/grumpy/testsuite/__init__.py b/grumpy/testsuite/__init__.py index eb7540c..67242c6 100644 --- a/grumpy/testsuite/__init__.py +++ b/grumpy/testsuite/__init__.py @@ -13,10 +13,20 @@ import copy, unittest from pkgcore.ebuild import ebuild_src, repo_objs from grumpy import app -from grumpy.models import db +from grumpy.models import db, Category, Package class GrumpyTestCase(unittest.TestCase): + def make_package(self, package): + with self.app.test_request_context(): + cat = package.key.split('/')[0] + c = Category.query.filter_by(name=cat).first() + if not c: + c = Category(cat) + self.db.session.add(c) + c.packages[package.key] = Package(package) + self.db.session.commit() + def get_pkg(self, cpv, pkg_data={}, data={}): """Returns a custom ebuild""" # We need to set up info from metadata.xml separately diff --git a/grumpy/testsuite/favorites.py b/grumpy/testsuite/favorites.py index 89aa032..4add8d4 100644 --- a/grumpy/testsuite/favorites.py +++ b/grumpy/testsuite/favorites.py @@ -11,7 +11,7 @@ import unittest from . import GrumpyTestCase -from grumpy.models import Category, Package, User +from grumpy.models import Package, User class FavoritesTestCase(GrumpyTestCase): @@ -24,17 +24,6 @@ class FavoritesTestCase(GrumpyTestCase): ps = ['sys-test/kala-0.12', 'sys-kala/test-0.10', 'sys-apps/ffff-0.1', \ 'sys-apps/fffuuu-0.9', 'sys-apps/ssss-0.3', 'kala-base/appp-3.0'] - def make_packages(self): - for i in self.ps: - cat = i.split('/')[0] - c = Category.query.filter_by(name=cat).first() - if not c: - c = Category(cat) - self.db.session.add(c) - p = self.get_pkg(i, self.d2, self.d1) - c.packages[p.key] = Package(p) - self.db.session.commit() - def make_users(self): u = [User('user1@gentoo.org', 'http://example.net/openid1'), User('user2@gentoo.org', 'http://example.net/openid2')] @@ -46,7 +35,8 @@ class FavoritesTestCase(GrumpyTestCase): with self.app.test_request_context(): u = self.make_users() assert User.query.count() == 2 - self.make_packages() + for i in self.ps: + self.make_package(self.get_pkg(i, self.d2, self.d1)) assert Package.query.count() == len(self.ps) # Fetch some packages |