From 49b11cb6978f8a2e2835ee6a72adb02c14fd3092 Mon Sep 17 00:00:00 2001 From: Renzo Lucioni Date: Fri, 12 May 2017 11:20:50 -0400 Subject: [PATCH] Exclude UTM parameters from marketing URLs when caching programs LEARNER-382 --- .../catalog/management/commands/cache_programs.py | 2 +- .../management/commands/tests/test_cache_programs.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/openedx/core/djangoapps/catalog/management/commands/cache_programs.py b/openedx/core/djangoapps/catalog/management/commands/cache_programs.py index b2e05b2951..74e457d816 100644 --- a/openedx/core/djangoapps/catalog/management/commands/cache_programs.py +++ b/openedx/core/djangoapps/catalog/management/commands/cache_programs.py @@ -58,7 +58,7 @@ class Command(BaseCommand): for uuid in uuids: try: logger.info('Requesting details for program {uuid}.'.format(uuid=uuid)) - program = client.programs(uuid).get() + program = client.programs(uuid).get(exclude_utm=1) cache_key = PROGRAM_CACHE_KEY_TPL.format(uuid=uuid) programs[cache_key] = program diff --git a/openedx/core/djangoapps/catalog/management/commands/tests/test_cache_programs.py b/openedx/core/djangoapps/catalog/management/commands/tests/test_cache_programs.py index 64a115ed35..de8c15149d 100644 --- a/openedx/core/djangoapps/catalog/management/commands/tests/test_cache_programs.py +++ b/openedx/core/djangoapps/catalog/management/commands/tests/test_cache_programs.py @@ -46,10 +46,18 @@ class TestCachePrograms(CatalogIntegrationMixin, CacheIsolationTestCase): ) def mock_detail(self, uuid, program): + def detail_callback(request, uri, headers): + expected = { + 'exclude_utm': ['1'], + } + self.assertEqual(request.querystring, expected) + + return (200, headers, json.dumps(program)) + httpretty.register_uri( httpretty.GET, self.detail_tpl.format(uuid=uuid), - body=json.dumps(program), + body=detail_callback, content_type='application/json' )