def test_should_send_mail_for_new_comments(self):
        offer = test_data.create_dummy_offer_usd()
        issue = offer.issue
        response = self.client.get('/core/watch/issue/%s'%issue.id)
        self.assertEqual(response.status_code, 200)
        response = self.client.get('/core/watch/offer/%s'%offer.id)
        self.assertEqual(response.status_code, 200)

        user2 = test_data.createDummyUserRandom(login='******', password='******')
        client2 = Client()
        client2.login(username=user2.username, password='******')

        email_asserts.clear_sent()
        response = client2.post('/core/issue/comment/add/submit', {'issue_id': str(issue.id), 'content': 'Im adding a comment'})
        self.assertEqual(response.status_code, 302)

        email_asserts.send_emails()
        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s added a comment on issue [%s]"%(user2.getUserInfo().screenName, issue.title))

        email_asserts.clear_sent()
        response = client2.post('/core/offer/comment/add/submit', {'offer_id': str(offer.id), 'content': 'Im adding another comment'})
        self.assertEqual(response.status_code, 302)

        email_asserts.send_emails()
        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s added a comment on offer [US$ %s / %s]"%(user2.getUserInfo().screenName, '10.00', issue.title))
Exemplo n.º 2
0
    def test_should_send_mail_for_new_comments(self):
        offer = test_data.create_dummy_offer_usd()
        issue = offer.issue
        response = self.client.get('/core/watch/issue/%s'%issue.id)
        self.assertEqual(response.status_code, 200)
        response = self.client.get('/core/watch/offer/%s'%offer.id)
        self.assertEqual(response.status_code, 200)

        user2 = test_data.createDummyUserRandom(login='******', password='******')
        client2 = Client()
        client2.login(username=user2.username, password='******')

        email_asserts.clear_sent()
        response = client2.post('/core/issue/comment/add/submit', {'issue_id': str(issue.id), 'content': 'Im adding a comment'})
        self.assertEqual(response.status_code, 302)

        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s added a comment on issue [%s]"%(user2.getUserInfo().screenName, issue.title))

        email_asserts.clear_sent()
        response = client2.post('/core/offer/comment/add/submit', {'offer_id': str(offer.id), 'content': 'Im adding another comment'})
        self.assertEqual(response.status_code, 302)

        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s added a comment on offer [US$ %s / %s]"%(user2.getUserInfo().screenName, '10.00', issue.title))
    def test_should_send_mail_for_starting_or_aborting_or_finishing_work(self):
        offer = test_data.create_dummy_offer_usd()
        issue = offer.issue
        response = self.client.get("/core/watch/issue/%s" % issue.id)
        self.assertEqual(response.status_code, 200)

        user2 = test_data.createDummyUserRandom(login="******", password="******")
        user2ScreenName = user2.getUserInfo().screenName
        client2 = Client()
        client2.login(username=user2.username, password="******")

        # STARTS WORKING
        email_asserts.clear_sent()
        response = client2.post("/core/solution/add/submit", {"issue_id": str(issue.id), "comment": ""})
        self.assertEqual(response.status_code, 302)
        issue_id = response.get("location").split("/")[-2]
        response = client2.get("/core/issue/%s/blah" % issue_id)
        solution_id = str(response.context["mysolution"].id)

        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(
            self, to=self.user.email, subject="%s has just begun working on issue [%s]" % (user2ScreenName, issue.title)
        )

        # ABORTS WORK
        email_asserts.clear_sent()
        response = client2.post("/core/solution/abort/submit", {"solution_id": solution_id, "comment": ""})
        self.assertEqual(response.status_code, 302)

        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(
            self, to=self.user.email, subject="%s has stopped working on issue [%s]" % (user2ScreenName, issue.title)
        )

        # STARTS WORKING again
        email_asserts.clear_sent()
        response = client2.post("/core/solution/add/submit", {"issue_id": str(issue.id), "comment": ""})
        self.assertEqual(response.status_code, 302)
        issue_id = response.get("location").split("/")[-2]
        response = client2.get("/core/issue/%s/blah" % issue_id)
        solution_id2 = str(response.context["mysolution"].id)
        self.assertEqual(solution_id, solution_id2)

        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(
            self, to=self.user.email, subject="%s has just begun working on issue [%s]" % (user2ScreenName, issue.title)
        )

        # FINISHES WORK
        email_asserts.clear_sent()
        response = client2.post("/core/solution/resolve/submit", {"solution_id": solution_id, "comment": ""})
        self.assertEqual(response.status_code, 302)

        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(
            self, to=self.user.email, subject="%s resolved issue [%s]" % (user2ScreenName, issue.title)
        )
Exemplo n.º 4
0
    def test_should_send_mail_for_starting_or_aborting_or_finishing_work(self):
        offer = test_data.create_dummy_offer_usd()
        issue = offer.issue
        response = self.client.get('/core/watch/issue/%s'%issue.id)
        self.assertEqual(response.status_code, 200)

        user2 = test_data.createDummyUserRandom(login='******', password='******')
        user2ScreenName = user2.getUserInfo().screenName
        client2 = Client()
        client2.login(username=user2.username, password='******')

        #STARTS WORKING
        email_asserts.clear_sent()
        response = client2.post('/core/solution/add/submit',
            {'issue_id': str(issue.id),
             'comment':''})
        self.assertEqual(response.status_code, 302)
        issue_id = response.get('location').split('/')[-2]
        response = client2.get('/core/issue/%s/blah'%issue_id)
        solution_id = str(response.context['mysolution'].id)

        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s has just begun working on issue [%s]"%(user2ScreenName, issue.title))

        #ABORTS WORK
        email_asserts.clear_sent()
        response = client2.post('/core/solution/abort/submit',
            {'solution_id': solution_id,
             'comment':''})
        self.assertEqual(response.status_code, 302)

        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s has stopped working on issue [%s]"%(user2ScreenName, issue.title))

        #STARTS WORKING again
        email_asserts.clear_sent()
        response = client2.post('/core/solution/add/submit',
            {'issue_id': str(issue.id),
             'comment':''})
        self.assertEqual(response.status_code, 302)
        issue_id = response.get('location').split('/')[-2]
        response = client2.get('/core/issue/%s/blah'%issue_id)
        solution_id2 = str(response.context['mysolution'].id)
        self.assertEqual(solution_id, solution_id2)

        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s has just begun working on issue [%s]"%(user2ScreenName, issue.title))

        #FINISHES WORK
        email_asserts.clear_sent()
        response = client2.post('/core/solution/resolve/submit',
            {'solution_id': solution_id,
             'comment':''})
        self.assertEqual(response.status_code, 302)

        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s resolved issue [%s]"%(user2ScreenName, issue.title))
    def test_should_send_mail_for_starting_or_aborting_or_finishing_work(self):
        offer = test_data.create_dummy_offer_usd()
        issue = offer.issue
        response = self.client.post(reverse('core.views.json_views.toggle_watch'), {'entity': 'ISSUE', 'objid': issue.id})
        self.assertEqual(response.status_code, 200)

        user2 = test_data.createDummyUserRandom(login='******', password='******')
        user2ScreenName = user2.getUserInfo().screenName
        client2 = Client()
        client2.login(username=user2.username, password='******')

        #STARTS WORKING
        email_asserts.clear_sent()
        response = client2.post('/core/solution/add/submit',
            {'issue_id': str(issue.id),
             'comment':''})
        self.assertEqual(response.status_code, 302)
        issue_id = response.get('location').split('/')[-2]
        response = client2.get('/core/issue/%s/blah'%issue_id)
        solution_id = str(response.context['mysolution'].id)

        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s has just begun working on issue [%s]"%(user2ScreenName, issue.title))

        #ABORTS WORK
        email_asserts.clear_sent()
        response = client2.post('/core/solution/abort/submit',
            {'solution_id': solution_id,
             'comment':''})
        self.assertEqual(response.status_code, 302)

        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s has stopped working on issue [%s]"%(user2ScreenName, issue.title))

        #STARTS WORKING again
        email_asserts.clear_sent()
        response = client2.post('/core/solution/add/submit',
            {'issue_id': str(issue.id),
             'comment':''})
        self.assertEqual(response.status_code, 302)
        issue_id = response.get('location').split('/')[-2]
        response = client2.get('/core/issue/%s/blah'%issue_id)
        solution_id2 = str(response.context['mysolution'].id)
        self.assertEqual(solution_id, solution_id2)

        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s has just begun working on issue [%s]"%(user2ScreenName, issue.title))

        #FINISHES WORK
        email_asserts.clear_sent()
        response = client2.post('/core/solution/resolve/submit',
            {'solution_id': solution_id,
             'comment':''})
        self.assertEqual(response.status_code, 302)

        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s resolved issue [%s]"%(user2ScreenName, issue.title))
    def test_watch_toggle_offer(self):
        offer = test_data.create_dummy_offer_usd()
        user = offer.issue.createdByUser

        self.assertTrue(not watch_services.is_watching_offer(user, offer.id))

        watch_services.watch_offer(user, offer.id, OfferWatch.WATCHED)
        self.assertTrue(watch_services.is_watching_offer(user, offer.id))

        watch_services.unwatch_offer(user, offer.id)
        self.assertTrue(not watch_services.is_watching_offer(user, offer.id))
    def test_watch_toggle_offer(self):
        offer = test_data.create_dummy_offer_usd()
        user = offer.issue.createdByUser

        self.assertTrue(not watch_services.is_watching_offer(user, offer.id))

        watch_services.watch_offer(user, offer.id, OfferWatch.WATCHED)
        self.assertTrue(watch_services.is_watching_offer(user, offer.id))

        watch_services.unwatch_offer(user, offer.id)
        self.assertTrue(not watch_services.is_watching_offer(user, offer.id))
    def test_watch_unwatch_offer(self):
        offer = test_data.create_dummy_offer_usd()
        self.assertTrue(not watch_services.is_watching_offer(self.user, offer.id))

        response = self.client.get('/core/watch/offer/%s'%offer.id)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'WATCHING')
        self.assertTrue(watch_services.is_watching_offer(self.user, offer.id))

        response = self.client.get('/core/unwatch/offer/%s'%offer.id)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'NOT_WATCHING')
        self.assertTrue(not watch_services.is_watching_offer(self.user, offer.id))
    def test_watch_unwatch_offer(self):
        offer = test_data.create_dummy_offer_usd()
        self.assertTrue(not watch_services.is_watching_offer(self.user, offer.id))

        response = self.client.get(_reverse('watchOffer', offer_id=offer.id))
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'WATCHING')
        self.assertTrue(watch_services.is_watching_offer(self.user, offer.id))

        response = self.client.get(_reverse('unwatchOffer', offer_id=offer.id))
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'NOT_WATCHING')
        self.assertTrue(not watch_services.is_watching_offer(self.user, offer.id))
 def _create_test_data(self, bitcoin_offer=False):
     #setup
     if bitcoin_offer:
         offer = test_data.create_dummy_offer_btc()
     else:
         offer = test_data.create_dummy_offer_usd()
     programmer = test_data.create_dummy_programmer()
     programmer_userinfo = programmer.getUserInfo()
     programmer_userinfo.paypalEmail = test_data.paypal_credentials_1['email']
     programmer_userinfo.save()
     solution = Solution.newSolution(offer.issue, programmer, False)
     solution.accepting_payments = True
     solution.save()
     return offer, solution
 def _create_test_data(self, bitcoin_offer=False):
     #setup
     if bitcoin_offer:
         offer = test_data.create_dummy_offer_btc()
     else:
         offer = test_data.create_dummy_offer_usd()
     programmer = test_data.create_dummy_programmer()
     programmer_userinfo = programmer.getUserInfo()
     programmer_userinfo.paypalEmail = test_data.paypal_credentials_1['email']
     programmer_userinfo.save()
     solution = Solution.newSolution(offer.issue, programmer, False)
     solution.accepting_payments = True
     solution.save()
     return offer, solution
    def test_watch_unwatch_offer(self):
        offer = test_data.create_dummy_offer_usd()
        self.assertTrue(
            not watch_services.is_watching_offer(self.user, offer.id))

        response = self.client.get('/core/watch/offer/%s' % offer.id)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'WATCHING')
        self.assertTrue(watch_services.is_watching_offer(self.user, offer.id))

        response = self.client.get('/core/unwatch/offer/%s' % offer.id)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'NOT_WATCHING')
        self.assertTrue(
            not watch_services.is_watching_offer(self.user, offer.id))
    def test_should_send_mail_for_adding_or_changing_or_revoking_offer(self):
        offer = test_data.create_dummy_offer_usd()
        issue = offer.issue
        response = self.client.get("/core/watch/issue/%s" % issue.id)
        self.assertEqual(response.status_code, 200)

        user2 = test_data.createDummyUserRandom(login="******", password="******")
        user2ScreenName = user2.getUserInfo().screenName
        client2 = Client()
        client2.login(username=user2.username, password="******")

        email_asserts.clear_sent()
        response = client2.post(
            "/core/issue/sponsor/submit",
            {"issue_id": str(issue.id), "price": "20.00", "currency": "USD", "acceptanceCriteria": "some criteria"},
        )
        self.assertEqual(response.status_code, 302)
        offer_id = response.get("location").split("/")[-2]

        email_asserts.assert_sent_count(self, 2)  # one to the watcher, other to the site admin
        email_asserts.assert_sent(
            self,
            to=self.user.email,
            subject="%s made a US$ 20.00 offer for issue [%s]" % (user2ScreenName, issue.title),
        )

        email_asserts.clear_sent()
        response = client2.post(
            "/core/offer/edit/submit",
            {"offer_id": offer_id, "currency": "USD", "price": "30.00", "acceptanceCriteria": "some criteria"},
        )
        self.assertEqual(response.status_code, 302)
        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(
            self,
            to=self.user.email,
            subject="%s raised the US$ 20.00 offer on issue [%s]" % (user2ScreenName, issue.title),
        )

        email_asserts.clear_sent()
        response = client2.post("/core/offer/revoke/submit", {"offer_id": offer_id, "comment": ""})
        self.assertEqual(response.status_code, 302)
        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(
            self,
            to=self.user.email,
            subject="%s revoked his US$ 30.00 offer for issue [%s]" % (user2ScreenName, issue.title),
        )
    def test_should_send_mail_for_new_comments(self):
        offer = test_data.create_dummy_offer_usd()
        issue = offer.issue
        response = self.client.post(reverse('core.views.json_views.toggle_watch'), {'entity': 'ISSUE', 'objid': issue.id})
        self.assertEqual(response.status_code, 200)

        user2 = test_data.createDummyUserRandom(login='******', password='******')
        client2 = Client()
        client2.login(username=user2.username, password='******')

        email_asserts.clear_sent()
        response = client2.post('/issue/comment/add/submit', {'issue_id': str(issue.id), 'content': 'Im adding a comment'})
        self.assertEqual(response.status_code, 302)

        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s added a comment on issue [%s]"%(user2.getUserInfo().screenName, issue.title))

        email_asserts.clear_sent()
Exemplo n.º 15
0
    def test_should_send_mail_for_new_comments(self):
        offer = test_data.create_dummy_offer_usd()
        issue = offer.issue
        response = self.client.post(reverse('core.views.json_views.toggle_watch'), {'entity': 'ISSUE', 'objid': issue.id})
        self.assertEqual(response.status_code, 200)

        user2 = test_data.createDummyUserRandom(login='******', password='******')
        client2 = Client()
        client2.login(username=user2.username, password='******')

        email_asserts.clear_sent()
        response = client2.post('/issue/comment/add/submit', {'issue_id': str(issue.id), 'content': 'Im adding a comment'})
        self.assertEqual(response.status_code, 302)

        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s added a comment on issue [%s]"%(user2.username, issue.title))

        email_asserts.clear_sent()
    def test_should_send_mail_for_adding_or_changing_or_revoking_offer(self):
        offer = test_data.create_dummy_offer_usd()
        issue = offer.issue
        response = self.client.get('/core/watch/issue/%s'%issue.id)
        self.assertEqual(response.status_code, 200)

        user2 = test_data.createDummyUserRandom(login='******', password='******')
        user2ScreenName = user2.getUserInfo().screenName
        client2 = Client()
        client2.login(username=user2.username, password='******')

        email_asserts.clear_sent()
        response = client2.post('/core/issue/sponsor/submit',
            {'issue_id': str(issue.id),
             'price':'20.00',
             'currency' : 'USD',
             'acceptanceCriteria':'some criteria',})
        self.assertEqual(response.status_code, 302)
        offer_id = response.get('location').split('/')[-2]

        email_asserts.send_emails()
        email_asserts.assert_sent_count(self, 2) #one to the watcher, other to the site admin
        email_asserts.assert_sent(self, to=self.user.email, subject="%s made a US$ 20.00 offer for issue [%s]"%(user2ScreenName, issue.title))

        email_asserts.clear_sent()
        response = client2.post('/core/offer/edit/submit',
            {'offer_id': offer_id,
             'currency':'USD',
             'price':'30.00',
             'acceptanceCriteria':'some criteria',})
        self.assertEqual(response.status_code, 302)
        email_asserts.send_emails()
        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s raised the US$ 20.00 offer on issue [%s]"%(user2ScreenName, issue.title))

        email_asserts.clear_sent()
        response = client2.post('/core/offer/revoke/submit',
            {'offer_id': offer_id,
             'comment' : ''})
        self.assertEqual(response.status_code, 302)
        email_asserts.send_emails()
        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s revoked his US$ 30.00 offer for issue [%s]"%(user2ScreenName, issue.title))
Exemplo n.º 17
0
    def test_should_send_mail_for_adding_or_changing_or_revoking_offer(self):
        offer = test_data.create_dummy_offer_usd()
        issue = offer.issue
        response = self.client.post(reverse('core.views.json_views.toggle_watch'), {'entity': 'ISSUE', 'objid': issue.id})
        self.assertEqual(response.status_code, 200)

        user2 = test_data.createDummyUserRandom(login='******', password='******')
        # user2ScreenName = user2.username
        client2 = Client()
        client2.login(username=user2.username, password='******')

        email_asserts.clear_sent()
        response = client2.post('/issue/sponsor/submit',
            {'issue_id': str(issue.id),
             'price': '20.00',
             'currency': 'USD',
             'acceptanceCriteria': 'some criteria'})
        self.assertEqual(response.status_code, 302)

        offer_id = issue.getOffers()[0].id

        email_asserts.assert_sent_count(self, 2) #one to the watcher, other to the site admin
        email_asserts.assert_sent(self, to=self.user.email, subject="%s made a US$ 20.00 offer for issue [%s]"%(user2.username, issue.title))

        email_asserts.clear_sent()
        response = client2.post('/offer/edit/submit',
            {'offer_id': offer_id,
             'currency': 'USD',
             'price': '30.00',
             'acceptanceCriteria': 'some criteria'})
        self.assertEqual(response.status_code, 302)
        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s raised the US$ 20.00 offer on issue [%s]"%(user2.username, issue.title))

        email_asserts.clear_sent()
        response = client2.post('/offer/revoke/submit',
            {'offer_id': offer_id,
             'comment' : ''})
        self.assertEqual(response.status_code, 302)
        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s revoked his US$ 30.00 offer for issue [%s]"%(user2.username, issue.title))
Exemplo n.º 18
0
    def test_should_send_mail_for_adding_or_changing_or_revoking_offer(self):
        offer = test_data.create_dummy_offer_usd()
        issue = offer.issue
        response = self.client.get('/core/watch/issue/%s'%issue.id)
        self.assertEqual(response.status_code, 200)

        user2 = test_data.createDummyUserRandom(login='******', password='******')
        user2ScreenName = user2.getUserInfo().screenName
        client2 = Client()
        client2.login(username=user2.username, password='******')

        email_asserts.clear_sent()
        response = client2.post('/core/issue/sponsor/submit',
            {'issue_id': str(issue.id),
             'price':'20.00',
             'currency' : 'USD',
             'acceptanceCriteria':'some criteria',})
        self.assertEqual(response.status_code, 302)
        offer_id = response.get('location').split('/')[-2]

        email_asserts.assert_sent_count(self, 2) #one to the watcher, other to the site admin
        email_asserts.assert_sent(self, to=self.user.email, subject="%s made a US$ 20.00 offer for issue [%s]"%(user2ScreenName, issue.title))

        email_asserts.clear_sent()
        response = client2.post('/core/offer/edit/submit',
            {'offer_id': offer_id,
             'currency':'USD',
             'price':'30.00',
             'acceptanceCriteria':'some criteria',})
        self.assertEqual(response.status_code, 302)
        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s raised the US$ 20.00 offer on issue [%s]"%(user2ScreenName, issue.title))

        email_asserts.clear_sent()
        response = client2.post('/core/offer/revoke/submit',
            {'offer_id': offer_id,
             'comment' : ''})
        self.assertEqual(response.status_code, 302)
        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s revoked his US$ 30.00 offer for issue [%s]"%(user2ScreenName, issue.title))
    def test_should_send_mail_for_new_comments(self):
        offer = test_data.create_dummy_offer_usd()
        issue = offer.issue
        response = self.client.get("/core/watch/issue/%s" % issue.id)
        self.assertEqual(response.status_code, 200)
        response = self.client.get("/core/watch/offer/%s" % offer.id)
        self.assertEqual(response.status_code, 200)

        user2 = test_data.createDummyUserRandom(login="******", password="******")
        client2 = Client()
        client2.login(username=user2.username, password="******")

        email_asserts.clear_sent()
        response = client2.post(
            "/core/issue/comment/add/submit", {"issue_id": str(issue.id), "content": "Im adding a comment"}
        )
        self.assertEqual(response.status_code, 302)

        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(
            self,
            to=self.user.email,
            subject="%s added a comment on issue [%s]" % (user2.getUserInfo().screenName, issue.title),
        )

        email_asserts.clear_sent()
        response = client2.post(
            "/core/offer/comment/add/submit", {"offer_id": str(offer.id), "content": "Im adding another comment"}
        )
        self.assertEqual(response.status_code, 302)

        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(
            self,
            to=self.user.email,
            subject="%s added a comment on offer [US$ %s / %s]"
            % (user2.getUserInfo().screenName, "10.00", issue.title),
        )
 def test_unwatch_offer(self):
     offer = test_data.create_dummy_offer_usd()
     self.assert_permanent_redirect(_reverse('unwatchOffer', offer_id=offer.id),
         '/core/unwatch/offer/%s' % offer.id)
Exemplo n.º 21
0
    def test_paypal_payment_complete(self):

        #setup
        offer = test_data.create_dummy_offer_usd()
        programmer = test_data.create_dummy_programmer()
        programmer_userinfo = programmer.getUserInfo()
        programmer_userinfo.paypalEmail = test_data.paypal_credentials_1[
            'email']
        programmer_userinfo.save()
        solution = Solution.newSolution(offer.issue, programmer, False)
        solution.accepting_payments = True
        solution.save()
        # _mock_paypal_adapter()

        #get pay form
        client = Client()
        client.login(username=offer.sponsor.username, password='******')

        response = client.get('/core/offer/%s/pay' % offer.id)
        if response.status_code != 200:
            print('ERROR - was expecting 200, got %s' % response.status_code)
            for message in list(response.context['messages']):
                print('message: %s' % message)
        self.assertEqual(response.status_code, 200)
        response_offer = response.context['offer']
        response_solutions_accepting_payments = response.context[
            'solutions_accepting_payments']
        response_shared_price = response.context['shared_price']
        response_convert_rate = response.context['convert_rate']
        response_currency_symbol = response.context['currency_symbol']
        self.assertEqual(offer.id, response_offer.id)
        self.assertEqual(len(response_solutions_accepting_payments), 1)
        self.assertEqual(float(response_shared_price), 10.0)
        self.assertEqual(float(response_convert_rate), 1.0)
        self.assertEqual(response_currency_symbol, 'US$')

        #submit pay form
        response = client.post(
            '/core/offer/pay/submit', {
                'offer_id': str(offer.id),
                'count': '1',
                'check_0': 'true',
                'pay_0': '10.00',
                'solutionId_0': str(solution.id)
            })
        self.assertEqual(response.status_code, 302)
        prefix = 'https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey='
        location = response.get('location')
        if prefix not in location:
            print('ERROR - was expecting redirect to paypal, got %s' %
                  location)
            for message in list(response.context['messages']):
                print('message: %s' % message)
        self.assertTrue(prefix in location)
        paykey = location.split(prefix)[1]
        self.assertTrue(paykey is not None)

        #RECEIVE ipn confirmation
        def mock_verify_ipn(data):
            return True

        paypal_adapter.verify_ipn = mock_verify_ipn

        payment = Payment.objects.get(paykey=paykey)
        client2 = Client()
        response = client2.post(
            '/core/paypal/' + settings.PAYPAL_IPNNOTIFY_URL_TOKEN, {
                'pay_key': paykey,
                'status': 'COMPLETED',
                'tracking_id': payment.confirm_key,
            })
        # 'tracking_id' : 'BLAU',})
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'OK')
        payment = Payment.objects.get(pk=payment.id)
        self.assertEqual(payment.status, Payment.CONFIRMED_IPN)
    def test_paypal_payment_complete(self):

        #setup
        offer = test_data.create_dummy_offer_usd()
        programmer = test_data.create_dummy_programmer()
        programmer_userinfo = programmer.getUserInfo()
        programmer_userinfo.paypalEmail = test_data.paypal_credentials_1['email']
        programmer_userinfo.save()
        solution = Solution.newSolution(offer.issue, programmer, False)
        solution.accepting_payments = True
        solution.save()
        # _mock_paypal_adapter()

        #get pay form
        client = Client()
        client.login(username=offer.sponsor.username, password='******')

        response = client.get('/core/offer/%s/pay' % offer.id)
        if response.status_code != 200:
            print('ERROR - was expecting 200, got %s' % response.status_code)
            for message in list(response.context['messages']):
                print('message: %s' % message)
        self.assertEqual(response.status_code, 200)
        response_offer = response.context['offer']
        response_solutions_accepting_payments = response.context['solutions_accepting_payments']
        response_shared_price = response.context['shared_price']
        response_convert_rate = response.context['convert_rate']
        response_currency_symbol = response.context['currency_symbol']
        self.assertEqual(offer.id, response_offer.id)
        self.assertEqual(len(response_solutions_accepting_payments), 1)
        self.assertEqual(float(response_shared_price), 10.0)
        self.assertEqual(float(response_convert_rate), 1.0)
        self.assertEqual(response_currency_symbol, 'US$')

        #submit pay form
        response = client.post('/core/offer/pay/submit',
                               {'offer_id' : str(offer.id),
                                'count' : '1',
                                'check_0' : 'true',
                                'pay_0' : '10.00',
                                'solutionId_0' : str(solution.id)})
        self.assertEqual(response.status_code, 302)
        prefix = 'https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey='
        location = response.get('location')
        if prefix not in location:
            print('ERROR - was expecting redirect to paypal, got %s' % location)
            for message in list(response.context['messages']):
                print('message: %s' % message)
        self.assertTrue(prefix in location)
        paykey = location.split(prefix)[1]
        self.assertTrue(paykey is not None)

        #RECEIVE ipn confirmation
        def mock_verify_ipn(data):
            return True

        paypal_adapter.verify_ipn = mock_verify_ipn

        payment = Payment.objects.get(paykey = paykey)
        client2 = Client()
        response = client2.post('/core/paypal/'+settings.PAYPAL_IPNNOTIFY_URL_TOKEN,
           {'pay_key' : paykey,
            'status' : 'COMPLETED',
            'tracking_id' : payment.confirm_key,})
            # 'tracking_id' : 'BLAU',})
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content, 'OK')
        payment = Payment.objects.get(pk = payment.id)
        self.assertEqual(payment.status, Payment.CONFIRMED_IPN)
Exemplo n.º 23
0
 def setUp(self):
     self.project = test_data.create_dummy_project()
     self.issue = test_data.create_dummy_issue(project=self.project)
     self.offer = test_data.create_dummy_offer_usd(issue=self.issue)
     self.issue.update_redundant_fields()
     self.client = Client()
 def setUp(self):
     self.project = test_data.create_dummy_project()
     self.issue = test_data.create_dummy_issue(project=self.project)
     self.offer = test_data.create_dummy_offer_usd(issue=self.issue)
     self.issue.update_redundant_fields()
     self.client = Client()