Created
September 25, 2011 21:07
-
-
Save ChristinaMeno/1241153 to your computer and use it in GitHub Desktop.
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
diff --git a/medley/medley_ads/tests/test_bulkadload.py b/medley/medley_ads/tests/test_bulkadload.py | |
index dc2ccb5..5272ea6 100644 | |
--- a/medley/medley_ads/tests/test_bulkadload.py | |
+++ b/medley/medley_ads/tests/test_bulkadload.py | |
@@ -2,6 +2,7 @@ | |
Tests for the bulk_ad_load view and new adt_tag | |
""" | |
import httplib2 | |
+from datetime import datetime, timedelta | |
from django.core.urlresolvers import reverse | |
from django.test import TestCase | |
@@ -9,6 +10,7 @@ from django.test.client import Client | |
from django.utils import simplejson as json | |
from medley.sitesettings.models import Setting | |
from django.contrib.sites.models import Site | |
+from medley.medley_ads.models import AdAssignment, AdCall, AdPosition, AdType, CurrentAssignment | |
import mock | |
@@ -74,9 +76,54 @@ class BulkAdLoadTest(TestCase): | |
self.mock_httplib_response(test) | |
-if __name__=='__main__': | |
- BulkAdLoadTest.runTest=lambda self: 'faked' | |
- testcase=BulkAdLoadTest() | |
- testcase.setUp() | |
- testcase.test_bulk_ad_load_success() | |
- testcase.test_bulk_ad_load_empty() | |
+ def test_PB01_overrides_HP01(self): | |
+ site = Site.objects.get(pk=1) | |
+ run_of_site = AdAssignment.objects.create(originating_site=site) | |
+ run_of_site.sites.add(site) | |
+ | |
+ then = datetime.now() - timedelta(seconds=10) | |
+ | |
+ hp01 = AdPosition.objects.create(name='HP01') | |
+ pb01 = AdPosition.objects.create(name='PB01') | |
+ | |
+ call1 = AdCall.objects.create(originating_site=site, | |
+ ad_type=AdType.objects.create(name='one'), | |
+ ad_call_syntax='<p>so long</p>') | |
+ | |
+ call2 = AdCall.objects.create(originating_site=site, | |
+ ad_type=AdType.objects.create(name='two'), | |
+ ad_call_syntax='<p>and thanks for all the fish</p>') | |
+ | |
+ kwargs = dict(ad_assignment=run_of_site, | |
+ start_date=then, | |
+ ) | |
+ first = dict(kwargs, | |
+ ad_type=call1.ad_type, | |
+ ad_position=hp01) | |
+ second = dict(kwargs, | |
+ ad_type=call2.ad_type, | |
+ ad_position=pb01) | |
+ | |
+ CurrentAssignment.objects.create(**first) | |
+ CurrentAssignment.objects.create(**second) | |
+ | |
+ params = dict(site='1', # wsbradio | |
+ category='622', # home | |
+ content_type=None, | |
+ obj='') | |
+ self.data = [ | |
+ dict(params, position="HP01"), | |
+ dict(params, position="RP06"), | |
+ dict(params, position="PB01"), | |
+ ] | |
+ | |
+ postdata = {} | |
+ postdata['bulk_ad_params'] = json.dumps(self.data) | |
+ | |
+ response = self.client.post(self.bulk_url, postdata) | |
+ return_data = json.loads(response.content) | |
+ for chunk in return_data: | |
+ if chunk.get('position') == 'HP01': | |
+ self.assertEqual(chunk.get('html'), '') | |
+ if chunk.get('position') == 'HP01': | |
+ self.assertTrue(call2.ad_call_syntax in chunk.get('html')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment