From 20babbc70730079a4dcf104994d6d67b12208f5a Mon Sep 17 00:00:00 2001 From: David Fischer Date: Thu, 29 Feb 2024 15:58:09 -0800 Subject: [PATCH] Wanted to add a test here --- adserver/tests/test_reports.py | 72 ++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/adserver/tests/test_reports.py b/adserver/tests/test_reports.py index fad93de4..0b1debb6 100644 --- a/adserver/tests/test_reports.py +++ b/adserver/tests/test_reports.py @@ -739,6 +739,78 @@ def test_publisher_uplift_report_contents(self): response, '3' ) + def test_staff_advertiser_report_contents(self): + url = reverse("staff_advertisers_report") + + # Create a house ad + ad2 = get( + Advertisement, + name="Test Ad 2", + slug="test-ad-2", + flight=self.flight3, + ad_type=self.ad_type1, + image=None, + ) + + # House ad traffic + get( + Offer, + advertisement=ad2, + publisher=self.publisher1, + viewed=True, + ) + get( + Offer, + advertisement=ad2, + publisher=self.publisher1, + viewed=True, + clicked=True, + ) + + # Paid traffic + get( + Offer, + advertisement=self.ad1, + publisher=self.publisher1, + viewed=True, + ) + get( + Offer, + advertisement=self.ad1, + publisher=self.publisher1, + viewed=True, + ) + get( + Offer, + advertisement=self.ad1, + publisher=self.publisher1, + viewed=True, + ) + get( + Offer, + advertisement=self.ad1, + publisher=self.publisher1, + viewed=True, + clicked=True, + ) + + daily_update_impressions() + daily_update_advertisers() + + # Staff only has has access + self.client.force_login(self.staff_user) + + response = self.client.get(url) + self.assertEqual(response.status_code, 200) + self.assertContains(response, '6') + + response = self.client.get(url + "?campaign_type=paid") + self.assertEqual(response.status_code, 200) + self.assertContains(response, '4') + self.assertNotContains( + response, '6' + ) + def test_global_keyword_report_contents(self): get( Offer,