forked from codesy/codesy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
start test_notify_matchers for codesy#37
- Loading branch information
1 parent
5248fef
commit b8ca9a0
Showing
2 changed files
with
47 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import fudge | ||
|
||
from django.conf import settings | ||
from django.test import TestCase | ||
|
||
from model_mommy import mommy | ||
|
||
|
||
class BidSaveReceiverTest(TestCase): | ||
def setUp(self): | ||
self.url = 'http://github.com/codesy/codesy/issues/37' | ||
self.bid1 = mommy.make('auctions.Bid', user__email='user1@test.com', | ||
ask=50, offer=0, url=self.url) | ||
self.bid2 = mommy.make('auctions.Bid', user__email='user2@test.com', | ||
ask=100, offer=10, url=self.url) | ||
self.bid3 = mommy.make('auctions.Bid', user__email='user3@test.com', | ||
ask=0, offer=45, url=self.url) | ||
|
||
def _add_url(self, string): | ||
return string.format(url=self.url) | ||
|
||
@fudge.patch('auctions.models.send_mail') | ||
def test_notify_matchers_sends_mail(self, mock_send_mail): | ||
user = mommy.make(settings.AUTH_USER_MODEL) | ||
mock_send_mail.expects_call().with_args( | ||
self._add_url('codesy.io match for {url}'), | ||
(self._add_url('Your ask for $50 for {url} has been met!')), | ||
'codesy.io', | ||
['user1@test.com'] | ||
) | ||
|
||
mock_send_mail.next_call().with_args( | ||
self._add_url('codesy.io match for {url}'), | ||
(self._add_url('Your ask for $100 for {url} has been met!')), | ||
'codesy.io', | ||
['user2@test.com'] | ||
) | ||
|
||
offer_bid = mommy.prepare( | ||
'auctions.Bid', offer=100, user=user, ask=1000, | ||
url='http://github.com/codesy/codesy/issues/37') | ||
offer_bid.save() |