def _confirm_sent(self, offer, programmer, transaction_value, email_value1, email_value2):
        def get_transaction_mock(hash):
            class X:
                pass

            txn = X()
            txn.confirmations = 3
            txn.details = []
            txn.details.append({
                'address': 'fake_receive_address_programmer',
                'amount': transaction_value
            })
            txn.details.append({
                'address': 'dummy_bitcoin_address_fs',
                'amount': -transaction_value
            })
            return txn

        bitcoin_adapter.get_transaction = get_transaction_mock
        email_asserts.clear_sent()
        bitcoin_frespo_services.bitcoin_active_send_confirmation()
        email_asserts.assert_sent_count(self, 3)
        email_asserts.assert_sent(self, to=programmer.email,
                                  subject='%s has made you a BTC %s payment' % (offer.sponsor.getUserInfo().screenName, email_value1))
        email_asserts.assert_sent(self, to=offer.sponsor.email, subject='You have made a BTC %s payment' % email_value1)
        email_asserts.assert_sent(self, to=settings.ADMINS[0][1], subject='Bitcoin payment made - %s' % email_value2)
    def _confirm_sent(self, offer, programmer, transaction_value, email_value1, email_value2):
        def get_transaction_mock(hash):
            class X:
                pass

            txn = X()
            txn.confirmations = 3
            txn.details = []
            txn.details.append({
                'address': 'fake_receive_address_programmer',
                'amount': transaction_value
            })
            txn.details.append({
                'address': 'dummy_bitcoin_address_fs',
                'amount': -transaction_value
            })
            return txn

        bitcoin_adapter.get_transaction = get_transaction_mock
        email_asserts.clear_sent()
        bitcoin_frespo_services.bitcoin_active_send_confirmation()
        email_asserts.assert_sent_count(self, 3)
        email_asserts.assert_sent(self, to=programmer.email,
                                  subject='%s has made you a BTC %s payment' % (offer.sponsor.username, email_value1))
        email_asserts.assert_sent(self, to=offer.sponsor.email, subject='You have made a BTC %s payment' % email_value1)
        email_asserts.assert_sent(self, to=settings.ADMINS[0][1], subject='Bitcoin payment made - %s' % email_value2)
    def test_add_feedback(self):
        data = {'title' : 'Do Something!', 'description' : 'Something good'}

        email_asserts.clear_sent()
        response = self.client.post('/feedback/submit', data = data)
        self.assertEqual(response.status_code, 302)
        email_asserts.assert_sent_count(self, 1)

        response = self.client.get('/feedback')
        self.assertTrue('We care a lot about what you think' in response.content)
        self.assertTrue('Do Something!' in response.content)
    def test_add_feedback(self):
        data = {'title' : 'Do Something!', 'description' : 'Something good'}

        email_asserts.clear_sent()
        response = self.client.post('/feedback/submit', data = data)
        self.assertEqual(response.status_code, 302)
        email_asserts.assert_sent_count(self, 1)

        response = self.client.get('/feedback')
        self.assertTrue('We care a lot about what you think' in response.content)
        self.assertTrue('Do Something!' in response.content)
    def _pay_programmer(self, payment, value, email_value):
        #Pay programmer
        def make_payment_mock(from_address, to_address, value):
            print('mock send bitcoins: %s ---(%s)---> %s' % (from_address, value, to_address))
            return 'dummy_txn_hash_2'

        bitcoin_adapter.make_payment = make_payment_mock
        email_asserts.clear_sent()
        bitcoin_frespo_services.bitcoin_pay_programmers()
        part = PaymentPart.objects.get(payment__id=payment.id)
        self.assertTrue(part.money_sent is not None)
        self.assertEqual(part.money_sent.value, value)
        self.assertEqual(part.money_sent.status, MoneySent.SENT)
        self.assertEqual(part.money_sent.transaction_hash, 'dummy_txn_hash_2')
        email_asserts.assert_sent_count(self, 2)
        subject = 'BTC %s payment received, and forwarded to programmer. Wating confirmation.' % email_value
        email_asserts.assert_sent(self, to=payment.offer.sponsor.email, subject=subject)
        email_asserts.assert_sent(self, to=settings.ADMINS[0][1], subject='[ADMIN NOTIFY] %s' % subject)
    def _pay_programmer(self, payment, value, email_value):
        #Pay programmer
        def make_payment_mock(from_address, to_address, value):
            print('mock send bitcoins: %s ---(%s)---> %s' % (from_address, value, to_address))
            return 'dummy_txn_hash_2'

        bitcoin_adapter.make_payment = make_payment_mock
        email_asserts.clear_sent()
        bitcoin_frespo_services.bitcoin_pay_programmers()
        part = PaymentPart.objects.get(payment__id=payment.id)
        self.assertTrue(part.money_sent is not None)
        self.assertEqual(part.money_sent.value, value)
        self.assertEqual(part.money_sent.status, MoneySent.SENT)
        self.assertEqual(part.money_sent.transaction_hash, 'dummy_txn_hash_2')
        email_asserts.assert_sent_count(self, 2)
        subject = 'BTC %s payment received, and forwarded to programmer. Wating confirmation.' % email_value
        email_asserts.assert_sent(self, to=payment.offer.sponsor.email, subject=subject)
        email_asserts.assert_sent(self, to=settings.ADMINS[0][1], subject='[ADMIN NOTIFY] %s' % subject)