Skip to content

Commit

Permalink
start test_notify_matchers for codesy#37
Browse files Browse the repository at this point in the history
  • Loading branch information
groovecoder committed Nov 8, 2014
1 parent 5a57fb4 commit 339dbf6
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions auctions/tests/model_tests.py
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)]
))

0 comments on commit 339dbf6

Please sign in to comment.