From fca3623595516a4722f2d8e3933bf95966cd6066 Mon Sep 17 00:00:00 2001 From: lauxley Date: Wed, 2 Apr 2014 10:43:29 +0200 Subject: [PATCH] better FTPSSender test. --- carrier_pigeon/tests.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/carrier_pigeon/tests.py b/carrier_pigeon/tests.py index da54b78..bedc1e2 100644 --- a/carrier_pigeon/tests.py +++ b/carrier_pigeon/tests.py @@ -1,8 +1,9 @@ -from mock import MagicMock +from mock import patch from django.test import TestCase from django.contrib.auth.models import User +from senders import FTPSSender from configuration import DefaultConfiguration from models import ItemToPush @@ -18,12 +19,8 @@ def get_items_to_push(self): class FTPSTestCase(TestCase): def test_ftp_class(self): - def deliver(f, tu, r): - # mock the deliver method - return True - - config = TestConfiguration() - config.deliver = MagicMock() - for item in config.get_items_to_push(): - config.process_item(item.content_object, item) - config.deliver.assert_called_once() + with patch.object(FTPSSender, 'deliver', return_value=True) as mock_deliver: + config = TestConfiguration() + for item in config.get_items_to_push(): + config.process_item(item.content_object, item) + mock_deliver.assert_called_once()