def test_opt_in_notification_includes_unsubscribe(self):
        carl_twitter = self.make_elsewhere('twitter', 1, 'carl')
        roy = self.make_participant('roy', claimed_time='now', email_address='*****@*****.**', notify_on_opt_in=1)
        roy.set_tip_to(carl_twitter.participant.username, '100')

        AccountElsewhere.from_user_name('twitter', 'carl').opt_in('carl')

        Participant.dequeue_emails()
        assert "To stop receiving" in self.get_last_email()['text']
Example #2
0
    def test_opt_in_notification_includes_unsubscribe(self):
        carl_twitter = self.make_elsewhere('twitter', 1, 'carl')
        roy = self.make_participant('roy', claimed_time='now', email_address='*****@*****.**', notify_on_opt_in=True)
        roy.set_tip_to(carl_twitter.participant.username, '100')

        AccountElsewhere.from_user_name('twitter', 'carl').opt_in('carl')

        Participant.dequeue_emails()
        assert "To stop receiving" in self.get_last_email()['text']
Example #3
0
 def make_elsewhere(self, platform, user_id, user_name, **kw):
     info = UserInfo( platform=platform
                    , user_id=unicode(user_id)
                    , user_name=user_name
                    , **kw
                    )
     return AccountElsewhere.upsert(info)
Example #4
0
 def make_elsewhere(self, platform, user_id, user_name, **kw):
     info = UserInfo( platform=platform
                    , user_id=unicode(user_id)
                    , user_name=user_name
                    , **kw
                    )
     return AccountElsewhere.upsert(info)
Example #5
0
 def make_elsewhere(self, platform, user_id, user_name, **kw):
     """Factory for :py:class:`~gratipay.models.account_elsewhere.AccountElsewhere`.
     """
     info = UserInfo(platform=platform,
                     user_id=unicode(user_id),
                     user_name=user_name,
                     **kw)
     return AccountElsewhere.upsert(info)
Example #6
0
 def test_logging_in_doesnt_reset_goal(self):
     self.make_participant('alice',
                           claimed_time='now',
                           elsewhere='twitter',
                           goal=100)
     alice = AccountElsewhere.from_user_name(
         'twitter', 'alice').opt_in('alice')[0].participant
     assert alice.goal == 100
Example #7
0
 def make_elsewhere(self, platform, user_id, user_name, **kw):
     """Factory for :py:class:`~gratipay.models.account_elsewhere.AccountElsewhere`.
     """
     info = UserInfo( platform=platform
                    , user_id=unicode(user_id)
                    , user_name=user_name
                    , **kw
                    )
     return AccountElsewhere.upsert(info)
Example #8
0
 def make_elsewhere(self, platform, user_id, user_name, is_locked=False, **kw):
     info = UserInfo( platform=platform
                    , user_id=unicode(user_id)
                    , user_name=user_name
                    , **kw
                    )
     account = AccountElsewhere.upsert(info)
     if is_locked:
         account.set_is_locked(True)
     return account
    def test_opt_in_sends_notifications_to_patrons(self):
        carl_twitter = self.make_elsewhere('twitter', 1, 'carl')
        roy = self.make_participant('roy', claimed_time='now', email_address='*****@*****.**')
        self.client.POST( '/roy/emails/notifications.json'
                        , data={'toggle': 'notify_on_opt_in'}
                        , auth_as='roy'
                         )

        self.bob.set_tip_to(carl_twitter.participant.username, '100')
        self.dan.set_tip_to(carl_twitter.participant.username, '100')
        roy.set_tip_to(carl_twitter.participant.username, '100') # Roy will NOT receive an email.

        AccountElsewhere.from_user_name('twitter', 'carl').opt_in('carl')

        Participant.dequeue_emails()
        assert self.mailer.call_count == 2 # Emails should only be sent to bob and dan
        last_email = self.get_last_email()
        assert last_email['to'][0]['email'] == '*****@*****.**'
        expected = "to carl"
        assert expected in last_email['text']
Example #10
0
    def test_opt_in_sends_notifications_to_patrons(self):
        carl_twitter = self.make_elsewhere('twitter', 1, 'carl')
        roy = self.make_participant('roy', claimed_time='now', email_address='*****@*****.**')
        self.client.POST( '/roy/emails/notifications.json'
                        , data={'toggle': 'notify_on_opt_in'}
                        , auth_as='roy'
                         )

        self.bob.set_tip_to(carl_twitter.participant.username, '100')
        self.dan.set_tip_to(carl_twitter.participant.username, '100')
        roy.set_tip_to(carl_twitter.participant.username, '100') # Roy will NOT receive an email.

        AccountElsewhere.from_user_name('twitter', 'carl').opt_in('carl')

        Participant.dequeue_emails()
        assert self.mailer.call_count == 2 # Emails should only be sent to bob and dan
        last_email = self.get_last_email()
        assert last_email['to'][0]['email'] == '*****@*****.**'
        expected = "to carl"
        assert expected in last_email['text']
Example #11
0
 def make_elsewhere(self,
                    platform,
                    user_id,
                    user_name,
                    is_locked=False,
                    **kw):
     info = UserInfo(platform=platform,
                     user_id=unicode(user_id),
                     user_name=user_name,
                     **kw)
     account = AccountElsewhere.upsert(info)
     if is_locked:
         account.set_is_locked(True)
     return account
Example #12
0
    def setUp(self):
        Harness.setUp(self)
        now = utcnow()
        hour_ago = now - datetime.timedelta(hours=1)
        for i, username in enumerate(["alice", "bob", "carl"]):
            p = self.make_participant(username, claimed_time=hour_ago, last_bill_result="", balance=Decimal(i))
            setattr(self, username, p)

        deadbeef = self.make_participant("deadbeef", balance=Decimal("18.03"), elsewhere="twitter")
        self.expected_new_balance = self.bob.balance + deadbeef.balance
        deadbeef_twitter = AccountElsewhere.from_user_name("twitter", "deadbeef")

        self.make_tip(self.carl, self.bob, "1.00")
        self.make_tip(self.alice, deadbeef, "1.00")
        self.bob.take_over(deadbeef_twitter, have_confirmation=True)
        self.deadbeef_archived = Participant.from_id(deadbeef.id)
 def check():
     alice = Participant.from_username('alice')
     bob = Participant.from_username('bob')
     carl = Participant.from_username('carl')
     dana = Participant.from_username('dana')
     emma = AccountElsewhere.from_user_name('github','emma').participant
     assert alice.giving == D('13.00')
     assert alice.pledging == D('1.00')
     assert alice.receiving == D('5.00')
     assert bob.giving == D('5.00')
     assert bob.receiving == D('7.00')
     assert bob.taking == D('1.00')
     assert carl.giving == D('0.00')
     assert carl.receiving == D('0.00')
     assert dana.receiving == D('3.00')
     assert dana.npatrons == 1
     assert emma.receiving == D('1.00')
     assert emma.npatrons == 1
     funded_tips = self.db.all("SELECT amount FROM tips WHERE is_funded ORDER BY id")
     assert funded_tips == [3, 6, 1, 4, 10, 5]
Example #14
0
    def setUp(self):
        Harness.setUp(self)
        now = utcnow()
        hour_ago = now - datetime.timedelta(hours=1)
        for i, username in enumerate(['alice', 'bob', 'carl']):
            p = self.make_participant( username
                                     , claimed_time=hour_ago
                                     , last_bill_result=''
                                     , balance=Decimal(i)
                                      )
            setattr(self, username, p)

        deadbeef = self.make_participant('deadbeef', balance=Decimal('18.03'), elsewhere='twitter')
        self.expected_new_balance = self.bob.balance + deadbeef.balance
        deadbeef_twitter = AccountElsewhere.from_user_name('twitter', 'deadbeef')

        self.make_tip(self.carl, self.bob, '1.00')
        self.make_tip(self.alice, deadbeef, '1.00')
        self.bob.take_over(deadbeef_twitter, have_confirmation=True)
        self.deadbeef_archived = Participant.from_id(deadbeef.id)
    def setUp(self):
        Harness.setUp(self)
        now = utcnow()
        hour_ago = now - datetime.timedelta(hours=1)
        for i, username in enumerate(['alice', 'bob', 'carl']):
            p = self.make_participant( username
                                     , claimed_time=hour_ago
                                     , last_bill_result=''
                                     , balance=Decimal(i)
                                      )
            setattr(self, username, p)

        deadbeef = self.make_participant('deadbeef', balance=Decimal('18.03'), elsewhere='twitter')
        self.expected_new_balance = self.bob.balance + deadbeef.balance
        deadbeef_twitter = AccountElsewhere.from_user_name('twitter', 'deadbeef')

        self.make_tip(self.carl, self.bob, '1.00')
        self.make_tip(self.alice, deadbeef, '1.00')
        self.bob.take_over(deadbeef_twitter, have_confirmation=True)
        self.deadbeef_archived = Participant.from_id(deadbeef.id)
Example #16
0
 def check():
     alice = Participant.from_username('alice')
     bob = Participant.from_username('bob')
     carl = Participant.from_username('carl')
     dana = Participant.from_username('dana')
     emma = AccountElsewhere.from_user_name('github',
                                            'emma').participant
     assert alice.giving == D('13.00')
     assert alice.pledging == D('1.00')
     assert alice.receiving == D('5.00')
     assert bob.giving == D('5.00')
     assert bob.receiving == D('7.00')
     assert bob.taking == D('1.00')
     assert carl.giving == D('0.00')
     assert carl.receiving == D('0.00')
     assert dana.receiving == D('3.00')
     assert dana.npatrons == 1
     assert emma.receiving == D('1.00')
     assert emma.npatrons == 1
     funded_tips = self.db.all(
         "SELECT amount FROM tips WHERE is_funded ORDER BY id")
     assert funded_tips == [3, 6, 1, 4, 10, 5]
Example #17
0
 def test_github_get_friends_for(self):
     platform = self.platforms.github
     user_info = platform.extract_user_info(user_info_examples.github())
     account = AccountElsewhere.upsert(user_info)
     friends, nfriends, pages_urls = platform.get_friends_for(account)
     assert nfriends > 0
Example #18
0
 def test_upsert(self):
     for platform in self.platforms:
         user_info = getattr(user_info_examples, platform.name)()
         account = AccountElsewhere.upsert(platform.extract_user_info(user_info))
         assert isinstance(account, AccountElsewhere)
Example #19
0
 def test_logging_in_doesnt_reset_goal(self):
     self.make_participant('alice', claimed_time='now', elsewhere='twitter', goal=100)
     alice = AccountElsewhere.from_user_name('twitter', 'alice').opt_in('alice')[0].participant
     assert alice.goal == 100
 def test_github_get_friends_for(self):
     platform = self.platforms.github
     user_info = platform.extract_user_info(user_info_examples.github())
     account = AccountElsewhere.upsert(user_info)
     friends, nfriends, pages_urls = platform.get_friends_for(account)
     assert nfriends > 0