def test_should_send_mail_for_new_comments(self):
        offer = test_data.create_dummy_offer()
        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))
コード例 #2
0
    def test_watch_toggle_offer(self):
        offer = test_data.create_dummy_offer()
        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))
コード例 #3
0
    def test_watch_unwatch_offer(self):
        offer = test_data.create_dummy_offer()
        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()
        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',
             '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,
             '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))
    def test_should_send_mail_for_starting_or_aborting_or_finishing_work(self):
        offer = test_data.create_dummy_offer()
        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.send_emails()
        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.send_emails()
        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.send_emails()
        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.send_emails()
        email_asserts.assert_sent_count(self, 1)
        email_asserts.assert_sent(self, to=self.user.email, subject="%s resolved issue [%s]"%(user2ScreenName, issue.title))