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
5a57fb4
commit 339dbf6
Showing
1 changed file
with
42 additions
and
0 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
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 | ||
|
||
from ..models import Bid | ||
|
||
class BidSaveReceiverTest(TestCase): | ||
def setUp(self): | ||
self.user1 = mommy.make(settings.AUTH_USER_MODEL) | ||
self.user2 = mommy.make(settings.AUTH_USER_MODEL) | ||
self.user3 = mommy.make(settings.AUTH_USER_MODEL) | ||
self.url = 'http://github.com/codesy/codesy/issues/37' | ||
self.bid1 = mommy.make(Bid, | ||
url=self.url, | ||
user=self.user1, | ||
ask=50, | ||
offer=0) | ||
self.bid2 = mommy.make(Bid, | ||
url=self.url, | ||
user=self.user1, | ||
ask=500, | ||
offer=10) | ||
self.instance = mommy.make(Bid, | ||
url=self.url, | ||
user=self.user3, | ||
ask=0, | ||
offer=45) | ||
|
||
@fudge.patch('Bid.objects') | ||
@fudge.patch('send_mail') | ||
def test_notify_matchers_sends_mail(self, mock_objects, mock_send_mail): | ||
(mock_objects.provides('filter').expects_call().with_args(url=self.url) | ||
.returns( | ||
fudge.Fake('QuerySet').provides('aggregate').returns(100) | ||
) | ||
.next_call().with_args(url=self.url, ask__lt=100) | ||
.returns( | ||
[fudge.Fake('Bid').has_attr(ask=99, url=self.url, user=self.user1)] | ||
)) |