Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

#4326

Closed

#4326

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions gratipay/models/package/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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. :-)
"""

Expand Down Expand Up @@ -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
10 changes: 10 additions & 0 deletions gratipay/models/package/confirmation.py
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions gratipay/models/package/mixins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

from confirmation import Confirmation

__all__ = ['Confirmation']
8 changes: 8 additions & 0 deletions tests/py/test_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -14,3 +15,10 @@ 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(EmailHarness):

def test_sends_confirmation_email(self):
p = self.make_package()
p.send_confirmation_email('[email protected]')