From 7ffd080b6ddabe4e2d6d99913b5f62877196913a Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Thu, 9 Feb 2017 09:04:30 -0500 Subject: [PATCH 1/2] Start hacking on send_confirmation_email --- gratipay/models/package/__init__.py | 10 ++-------- gratipay/models/package/confirmation.py | 10 ++++++++++ gratipay/models/package/mixins.py | 6 ++++++ tests/py/test_packages.py | 6 ++++++ 4 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 gratipay/models/package/confirmation.py create mode 100644 gratipay/models/package/mixins.py diff --git a/gratipay/models/package/__init__.py b/gratipay/models/package/__init__.py index 571e2cb971..5cff94468e 100644 --- a/gratipay/models/package/__init__.py +++ b/gratipay/models/package/__init__.py @@ -2,13 +2,14 @@ from __future__ import absolute_import, division, print_function, unicode_literals from postgres.orm import Model +from gratipay.models.package import mixins NPM = 'npm' # We are starting with a single package manager. If we see # traction we will expand. -class Package(Model): +class Package(Model, mixins.Confirmation): """Represent a gratipackage. :-) """ @@ -40,10 +41,3 @@ def from_names(cls, package_manager, name): """ return cls.db.one("SELECT packages.*::packages FROM packages " "WHERE package_manager=%s and name=%s", (package_manager, name)) - - - # Emails - # ====== - - def send_confirmation_email(self, address): - pass diff --git a/gratipay/models/package/confirmation.py b/gratipay/models/package/confirmation.py new file mode 100644 index 0000000000..cd144995cf --- /dev/null +++ b/gratipay/models/package/confirmation.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +from __future__ import absolute_import, division, print_function, unicode_literals + + +class Confirmation(object): + + def send_confirmation_email(self, address): + """ + """ + pass diff --git a/gratipay/models/package/mixins.py b/gratipay/models/package/mixins.py new file mode 100644 index 0000000000..eb63d8dd47 --- /dev/null +++ b/gratipay/models/package/mixins.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +from __future__ import absolute_import, division, print_function, unicode_literals + +from confirmation import Confirmation + +__all__ = ['Confirmation'] diff --git a/tests/py/test_packages.py b/tests/py/test_packages.py index b97e888377..8831149322 100644 --- a/tests/py/test_packages.py +++ b/tests/py/test_packages.py @@ -14,3 +14,9 @@ def test_can_be_instantiated_from_id(self): def test_can_be_instantiated_from_names(self): self.make_package() assert Package.from_names(NPM, 'foo').name == 'foo' + + +class TestSendConfirmationEmail(Harness): + + def test_sends_confirmation_email(self): + pass From f3e657ffef9b9f07855195467189a366ccbe69e2 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Fri, 10 Feb 2017 13:56:38 -0500 Subject: [PATCH 2/2] Shelve --- tests/py/test_packages.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/py/test_packages.py b/tests/py/test_packages.py index 8831149322..08561a6354 100644 --- a/tests/py/test_packages.py +++ b/tests/py/test_packages.py @@ -3,6 +3,7 @@ from gratipay.models.package import NPM, Package from gratipay.testing import Harness +from gratipay.testing.emails import EmailHarness class TestPackage(Harness): @@ -16,7 +17,8 @@ def test_can_be_instantiated_from_names(self): assert Package.from_names(NPM, 'foo').name == 'foo' -class TestSendConfirmationEmail(Harness): +class TestSendConfirmationEmail(EmailHarness): def test_sends_confirmation_email(self): - pass + p = self.make_package() + p.send_confirmation_email('alice@example.com')