Merge pull request #19835 from edx/revert-19677-emma-green/REVEM-176/cache-course_runs-to-programs

Revert "WIP:Cache course runs to programs"
This commit is contained in:
Calen Pennington
2019-02-20 13:37:57 -05:00
committed by GitHub
15 changed files with 48 additions and 347 deletions

View File

@@ -11,8 +11,7 @@ from openedx.core.djangoapps.catalog.tests.factories import (
CourseRunFactory,
PathwayFactory,
ProgramFactory,
ProgramTypeFactory,
ProgramDescriptionFactory,
ProgramTypeFactory
)
@@ -25,12 +24,6 @@ class ProgramPageBase(ProgramsConfigMixin, CatalogIntegrationMixin, UniqueCourse
self.programs = ProgramFactory.create_batch(3)
self.pathways = PathwayFactory.create_batch(3)
self.course_runs = [
CourseRunFactory.create(programs=[ProgramDescriptionFactory.from_program(program)], **course_run)
for program in self.programs
for course in program['courses']
for course_run in course['course_runs']
]
for pathway in self.pathways:
self.programs += pathway['programs']
@@ -58,28 +51,18 @@ class ProgramPageBase(ProgramsConfigMixin, CatalogIntegrationMixin, UniqueCourse
program_type = ProgramTypeFactory()
return ProgramFactory(courses=[course], type=program_type['name'])
def stub_catalog_api(self, programs=None, pathways=None, course_runs=None):
def stub_catalog_api(self, programs, pathways):
"""
Stub the discovery service's program list and detail API endpoints, as well as
the credit pathway list endpoint.
"""
self.set_catalog_integration(is_enabled=True, service_username=self.username)
if programs is None:
programs = self.programs
CatalogFixture.install_programs(programs)
CatalogFixture().install_programs(programs)
program_types = [program['type'] for program in programs]
CatalogFixture.install_program_types(program_types)
CatalogFixture().install_program_types(program_types)
if pathways is None:
pathways = self.pathways
CatalogFixture.install_pathways(pathways)
if course_runs is None:
course_runs = self.course_runs
CatalogFixture.install_course_runs(course_runs)
CatalogFixture().install_pathways(pathways)
def cache_programs(self):
"""
@@ -101,7 +84,7 @@ class ProgramListingPageTest(ProgramPageBase):
def test_no_enrollments(self):
"""Verify that no cards appear when the user has no enrollments."""
self.auth(enroll=False)
self.stub_catalog_api()
self.stub_catalog_api(self.programs, self.pathways)
self.cache_programs()
self.listing_page.visit()
@@ -115,7 +98,7 @@ class ProgramListingPageTest(ProgramPageBase):
but none are included in an active program.
"""
self.auth()
self.stub_catalog_api()
self.stub_catalog_api(self.programs, self.pathways)
self.cache_programs()
self.listing_page.visit()
@@ -143,15 +126,7 @@ class ProgramListingPageA11yTest(ProgramPageBase):
]
})
self.auth(enroll=False)
self.stub_catalog_api(
programs=[self.program],
pathways=[],
course_runs=[
CourseRunFactory.create(programs=[ProgramDescriptionFactory.from_program(self.program)], **course_run)
for course in self.program['courses']
for course_run in course['course_runs']
]
)
self.stub_catalog_api(programs=[self.program], pathways=[])
self.cache_programs()
self.listing_page.visit()
@@ -168,15 +143,7 @@ class ProgramListingPageA11yTest(ProgramPageBase):
]
})
self.auth()
self.stub_catalog_api(
programs=[self.program],
pathways=[],
course_runs=[
CourseRunFactory.create(programs=[ProgramDescriptionFactory.from_program(self.program)], **course_run)
for course in self.program['courses']
for course_run in course['course_runs']
]
)
self.stub_catalog_api(programs=[self.program], pathways=[])
self.cache_programs()
self.listing_page.visit()
@@ -206,15 +173,7 @@ class ProgramDetailsPageA11yTest(ProgramPageBase):
]
})
self.auth()
self.stub_catalog_api(
programs=[self.program],
pathways=[],
course_runs=[
CourseRunFactory.create(programs=[ProgramDescriptionFactory.from_program(self.program)], **course_run)
for course in self.program['courses']
for course_run in course['course_runs']
]
)
self.stub_catalog_api(programs=[self.program], pathways=[])
self.cache_programs()
self.details_page.visit()