Esempio n. 1
0
    def test_send_mail_creates_message_mailchimp_disquss(
            self, mailchimp, Message, mail):
        with patch.dict(
                self.flask_app.config, {
                    'MAILCHIMP_API_KEY': 'k-3',
                    'MAILCHIMP_LIST_ID': 1,
                    'DISQUS_SECRET_KEY': 'key'
                }):
            user = UserFactory.create()
            user_id = user.id
            brand = 'PYBOSSA'
            subject = '[%s]: Your account has been deleted' % brand
            body = """Hi,\n Your account and personal data has been deleted from the %s.""" % brand
            body += '\nDisqus does not provide an API method to delete your account. You will have to do it by hand yourself in the disqus.com site.'

            recipients = [user.email_addr, '*****@*****.**']
            mail_dict = dict(recipients=recipients, subject=subject, body=body)

            mailchimp.side_effect = [
                FakeResponse(text=json.dumps(dict(status=204)),
                             json=lambda: '',
                             status_code=204)
            ]
            delete_account(user.id)
            Message.assert_called_once_with(**mail_dict)
            mail.send.assert_called_once_with(Message())
            user = user_repo.get(user_id)
            assert user is None
Esempio n. 2
0
    def test_send_mail_creates_message_mailchimp_disquss(self, mailchimp, Message, mail):
        with patch.dict(self.flask_app.config, {'MAILCHIMP_API_KEY': 'k-3',
                                                'MAILCHIMP_LIST_ID': 1,
                                                'DISQUS_SECRET_KEY': 'key'}):
            user = UserFactory.create()
            user_id = user.id
            brand = 'PYBOSSA'
            subject = '[%s]: Your account has been deleted' % brand
            body = """Hi,\n Your account and personal data has been deleted from %s.""" % brand
            body += '\nDisqus does not provide an API method to delete your account. You will have to do it by hand yourself in the disqus.com site.'

            admin_addr = '*****@*****.**'
            recipients = [user.email_addr] + current_app.config.get('ADMINS', [])
            mail_dict = dict(recipients=recipients,
                             subject=subject,
                             body=body,
                             bcc=[admin_addr])

            user_old = user.dictize()
            mailchimp.side_effect = [FakeResponse(text=json.dumps(dict(status=204)),
                                                 json=lambda : '',
                                               status_code=204)]
            delete_account(user.id, admin_addr)
            Message.assert_called_once_with(**mail_dict)
            mail.send.assert_called_once_with(Message())
            user_new = user_repo.get(user_id)
            assert user_new.name != user_old['name']
            assert user_new.fullname != user_old['fullname']
            assert user_new.email_addr != user_old['email_addr']
            assert not user_new.info
            assert not user_new.user_pref
Esempio n. 3
0
    def test_send_mail_creates_message_mailchimp_error(self, mailchimp, Message, mail):
        with patch.dict(self.flask_app.config, {'MAILCHIMP_API_KEY': 'k-3',
                                                'MAILCHIMP_LIST_ID': 1}):
            user = UserFactory.create()
            user_id = user.id
            brand = 'PYBOSSA'
            subject = '[%s]: Your account has been deleted' % brand
            body = """Hi,\n Your account and personal data has been deleted from %s.""" % brand
            body += '\nWe could not delete your Mailchimp account, please contact us to fix this issue.'

            admin_addr = '*****@*****.**'
            recipients = [user.email_addr] + current_app.config.get('ADMINS', [])
            mail_dict = dict(recipients=recipients,
                             subject=subject,
                             body=body,
                             bcc=[admin_addr])

            user_old = user.dictize()
            delete_account(user.id, '*****@*****.**')
            Message.assert_called_once_with(**mail_dict)
            mail.send.assert_called_once_with(Message())
            user_new = user_repo.get(user_id)
            assert user_new.name != user_old['name']
            assert user_new.fullname != user_old['fullname']
            assert user_new.email_addr != user_old['email_addr']
            assert not user_new.info
            assert not user_new.user_pref
Esempio n. 4
0
    def test_send_mail_creates_message_mailchimp_ok(self, mailchimp, Message,
                                                    mail):
        with patch.dict(self.flask_app.config, {
                'MAILCHIMP_API_KEY': 'k-3',
                'MAILCHIMP_LIST_ID': 1
        }):
            user = UserFactory.create()
            user_id = user.id
            brand = 'PYBOSSA'
            subject = '[%s]: Your account has been deleted' % brand
            body = """Hi,\nYour account and personal data has been deleted from %s.""" % brand

            recipients = [user.email_addr, '*****@*****.**']
            mail_dict = dict(recipients=recipients, subject=subject, body=body)

            mailchimp.side_effect = [
                FakeResponse(text=json.dumps(dict(status=204)),
                             json=lambda: '',
                             status_code=204)
            ]
            delete_account(user.id)
            Message.assert_called_once_with(**mail_dict)
            mail.send.assert_called_once_with(Message())
            user = user_repo.get(user_id)
            assert user is None
    def test_send_mail_creates_message_mailchimp_error(self, mailchimp, Message, mail):
        with patch.dict(self.flask_app.config, {'MAILCHIMP_API_KEY': 'k-3',
                                                'MAILCHIMP_LIST_ID': 1}):
            user = UserFactory.create()
            user_id = user.id
            brand = 'PYBOSSA'
            subject = '[%s]: Your account has been deleted' % brand
            body = """Hi,\n Your account and personal data has been deleted from the %s.""" % brand
            body += '\nWe could not delete your Mailchimp account, please contact us to fix this issue.'

            recipients = [user.email_addr, '*****@*****.**']
            mail_dict = dict(recipients=recipients,
                             subject=subject,
                             body=body)

            delete_account(user.id)
            Message.assert_called_once_with(**mail_dict)
            mail.send.assert_called_once_with(Message())
            user = user_repo.get(user_id)
            assert user is None
Esempio n. 6
0
    def test_send_mail_creates_message_mailchimp_error(self, mailchimp,
                                                       Message, mail):
        with patch.dict(self.flask_app.config, {
                'MAILCHIMP_API_KEY': 'k-3',
                'MAILCHIMP_LIST_ID': 1
        }):
            user = UserFactory.create()
            user_id = user.id
            brand = 'PYBOSSA'
            subject = '[%s]: Your account has been deleted' % brand
            body = """Hi,\n Your account and personal data has been deleted from the %s.""" % brand
            body += '\nWe could not delete your Mailchimp account, please contact us to fix this issue.'

            recipients = [user.email_addr, '*****@*****.**']
            mail_dict = dict(recipients=recipients, subject=subject, body=body)

            delete_account(user.id)
            Message.assert_called_once_with(**mail_dict)
            mail.send.assert_called_once_with(Message())
            user = user_repo.get(user_id)
            assert user is None
    def test_send_mail_creates_message_mailchimp_ok(self, mailchimp, Message, mail):
        with patch.dict(self.flask_app.config, {'MAILCHIMP_API_KEY': 'k-3',
                                                'MAILCHIMP_LIST_ID': 1}):
            user = UserFactory.create()
            user_id = user.id
            brand = 'PYBOSSA'
            subject = '[%s]: Your account has been deleted' % brand
            body = """Hi,\n Your account and personal data has been deleted from the %s.""" % brand

            recipients = [user.email_addr, '*****@*****.**']
            mail_dict = dict(recipients=recipients,
                             subject=subject,
                             body=body)

            mailchimp.side_effect = [FakeResponse(text=json.dumps(dict(status=204)),
                                                 json=lambda : '',
                                               status_code=204)]
            delete_account(user.id)
            Message.assert_called_once_with(**mail_dict)
            mail.send.assert_called_once_with(Message())
            user = user_repo.get(user_id)
            assert user is None
Esempio n. 8
0
    def test_send_mail_creates_message_mailchimp_disquss(self, mailchimp, Message, mail):
        with patch.dict(self.flask_app.config, {'MAILCHIMP_API_KEY': 'k-3',
                                                'MAILCHIMP_LIST_ID': 1,
                                                'DISQUS_SECRET_KEY': 'key'}):
            user = UserFactory.create()
            user_id = user.id
            brand = 'PYBOSSA'
            subject = '[%s]: Your account has been deleted' % brand
            body = """Hi,\nYour account and personal data has been deleted from %s.""" % brand
            body += '\nDisqus does not provide an API method to delete your account. You will have to do it by hand yourself in the disqus.com site.'

            recipients = [user.email_addr, '*****@*****.**']
            mail_dict = dict(recipients=recipients,
                             subject=subject,
                             body=body)

            mailchimp.side_effect = [FakeResponse(text=json.dumps(dict(status=204)),
                                                 json=lambda : '',
                                               status_code=204)]
            delete_account(user.id)
            Message.assert_called_once_with(**mail_dict)
            mail.send.assert_called_once_with(Message())
            user = user_repo.get(user_id)
            assert user is None