From b81cb7da3ca0b28a9794fa5d2b3e49a0d959d862 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Wed, 22 Mar 2017 14:43:45 -0400 Subject: [PATCH] Improvements to fake_data.make_package - use a constant - return Package --- gratipay/testing/harness.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gratipay/testing/harness.py b/gratipay/testing/harness.py index 2c7b7f9028..9f4d147830 100644 --- a/gratipay/testing/harness.py +++ b/gratipay/testing/harness.py @@ -17,6 +17,7 @@ from gratipay.exceptions import NoSelfTipping, NoTippee, BadAmount from gratipay.models.account_elsewhere import AccountElsewhere from gratipay.models.exchange_route import ExchangeRoute +from gratipay.models.package import NPM, Package from gratipay.models.participant import Participant, MAX_TIP, MIN_TIP from gratipay.security import user from gratipay.testing.vcr import use_cassette @@ -195,14 +196,15 @@ def make_team(self, *a, **kw): return team - def make_package(self, package_manager='npm', name='foo', description='Foo', + def make_package(self, package_manager=NPM, name='foo', description='Foo', emails=['alice@example.com']): """Factory for packages. """ - return self.db.one( 'INSERT INTO packages (package_manager, name, description, emails) ' - 'VALUES (%s, %s, %s, %s) RETURNING *' - , (package_manager, name, description, emails) - ) + self.db.run( 'INSERT INTO packages (package_manager, name, description, emails) ' + 'VALUES (%s, %s, %s, %s) RETURNING *' + , (package_manager, name, description, emails) + ) + return Package.from_names(NPM, name) def make_participant(self, username, **kw):