Remove deprecated references to ProgramsApiConfig model
ECOM-7195 The (now deprecated) programs service had several fields to set up configuration of the API. We are removing the property/field references in codeas the first part of deprecating the model fields. Also being removed are the model properties.
This commit is contained in:
@@ -94,52 +94,3 @@ class ProgramsApiConfig(ConfigurationModel):
|
||||
verbose_name=_("Do we want to show program details pages"),
|
||||
default=False
|
||||
)
|
||||
|
||||
@property
|
||||
def internal_api_url(self):
|
||||
"""
|
||||
Generate a URL based on internal service URL and API version number.
|
||||
"""
|
||||
return urljoin(self.internal_service_url, '/api/v{}/'.format(self.api_version_number))
|
||||
|
||||
@property
|
||||
def public_api_url(self):
|
||||
"""
|
||||
Generate a URL based on public service URL and API version number.
|
||||
"""
|
||||
return urljoin(self.public_service_url, '/api/v{}/'.format(self.api_version_number))
|
||||
|
||||
@property
|
||||
def is_cache_enabled(self):
|
||||
"""Whether responses from the Programs API will be cached."""
|
||||
return self.cache_ttl > 0
|
||||
|
||||
@property
|
||||
def is_studio_tab_enabled(self):
|
||||
"""
|
||||
Indicates whether Studio functionality related to Programs should
|
||||
be enabled or not.
|
||||
"""
|
||||
return self.enabled and self.enable_studio_tab
|
||||
|
||||
@property
|
||||
def is_certification_enabled(self):
|
||||
"""
|
||||
Indicates whether background tasks should be initiated to grant
|
||||
certificates for Program completion.
|
||||
"""
|
||||
return self.enabled and self.enable_certification
|
||||
|
||||
@property
|
||||
def show_program_listing(self):
|
||||
"""
|
||||
Indicates whether we want to show program listing page
|
||||
"""
|
||||
return self.enabled and self.program_listing_enabled
|
||||
|
||||
@property
|
||||
def show_program_details(self):
|
||||
"""
|
||||
Indicates whether we want to show program details pages
|
||||
"""
|
||||
return self.enabled and self.program_details_enabled
|
||||
|
||||
@@ -5,6 +5,7 @@ from openedx.core.djangoapps.programs.models import ProgramsApiConfig
|
||||
class ProgramsApiConfigMixin(object):
|
||||
"""Utilities for working with Programs configuration during testing."""
|
||||
|
||||
# Update these paramters once fields are removed from model
|
||||
DEFAULTS = {
|
||||
'enabled': True,
|
||||
'api_version_number': 1,
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
"""Tests for models supporting Program-related functionality."""
|
||||
import ddt
|
||||
from django.test import TestCase
|
||||
import mock
|
||||
from nose.plugins.attrib import attr
|
||||
|
||||
from openedx.core.djangoapps.programs.tests.mixins import ProgramsApiConfigMixin
|
||||
from openedx.core.djangolib.testing.utils import skip_unless_lms
|
||||
|
||||
|
||||
@skip_unless_lms
|
||||
@attr(shard=2)
|
||||
@ddt.ddt
|
||||
# ConfigurationModels use the cache. Make every cache get a miss.
|
||||
@mock.patch('config_models.models.cache.get', return_value=None)
|
||||
class TestProgramsApiConfig(ProgramsApiConfigMixin, TestCase):
|
||||
"""Tests covering the ProgramsApiConfig model."""
|
||||
def test_url_construction(self, _mock_cache):
|
||||
"""Verify that URLs returned by the model are constructed correctly."""
|
||||
programs_config = self.create_programs_config()
|
||||
|
||||
self.assertEqual(
|
||||
programs_config.internal_api_url,
|
||||
programs_config.internal_service_url.strip('/') + '/api/v{}/'.format(programs_config.api_version_number)
|
||||
)
|
||||
self.assertEqual(
|
||||
programs_config.public_api_url,
|
||||
programs_config.public_service_url.strip('/') + '/api/v{}/'.format(programs_config.api_version_number)
|
||||
)
|
||||
|
||||
@ddt.data(
|
||||
(0, False),
|
||||
(1, True),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_cache_control(self, cache_ttl, is_cache_enabled, _mock_cache):
|
||||
"""Verify the behavior of the property controlling whether API responses are cached."""
|
||||
programs_config = self.create_programs_config(cache_ttl=cache_ttl)
|
||||
self.assertEqual(programs_config.is_cache_enabled, is_cache_enabled)
|
||||
|
||||
def test_is_studio_tab_enabled(self, _mock_cache):
|
||||
"""
|
||||
Verify that the property controlling display of the Studio tab is only True
|
||||
when configuration is enabled and all required configuration is provided.
|
||||
"""
|
||||
programs_config = self.create_programs_config(enabled=False)
|
||||
self.assertFalse(programs_config.is_studio_tab_enabled)
|
||||
|
||||
programs_config = self.create_programs_config(enable_studio_tab=False)
|
||||
self.assertFalse(programs_config.is_studio_tab_enabled)
|
||||
|
||||
programs_config = self.create_programs_config()
|
||||
self.assertTrue(programs_config.is_studio_tab_enabled)
|
||||
|
||||
def test_is_certification_enabled(self, _mock_cache):
|
||||
"""
|
||||
Verify that the property controlling certification-related functionality
|
||||
for Programs behaves as expected.
|
||||
"""
|
||||
programs_config = self.create_programs_config(enabled=False)
|
||||
self.assertFalse(programs_config.is_certification_enabled)
|
||||
|
||||
programs_config = self.create_programs_config(enable_certification=False)
|
||||
self.assertFalse(programs_config.is_certification_enabled)
|
||||
|
||||
programs_config = self.create_programs_config()
|
||||
self.assertTrue(programs_config.is_certification_enabled)
|
||||
Reference in New Issue
Block a user