Merge pull request #30494 from openedx/saleem-latif/ENT-5796-bug-fix

fix: Fixed a small error related to function return type.
This commit is contained in:
Saleem Latif
2022-05-26 19:52:43 +05:00
committed by GitHub
2 changed files with 30 additions and 3 deletions

View File

@@ -89,7 +89,7 @@ class Command(BaseCommand):
for course_run in not_started_course['course_runs']:
if self.valid_course_run(course_run) and course_run['key'] != completed_course_id:
return program, course_run, not_started_course
return None, None
return None, None, None
def sort_programs(self, programs):
"""

View File

@@ -54,6 +54,10 @@ class TestSendProgramCourseNudgeEmailCommand(TestCase):
courses=[self.enrolled_course, self.unenrolled_course_2],
type='MicroMasters'
)
self.enrolled_program_3 = ProgramFactory(
courses=[self.enrolled_course],
type='MicroMasters'
)
self.unenrolled_program = ProgramFactory()
self.create_grade(user_id=self.user_1.id, course_id=self.enrolled_course_run['key'])
self.create_grade(user_id=self.user_2.id, course_id=self.enrolled_course_run['key'])
@@ -88,10 +92,8 @@ class TestSendProgramCourseNudgeEmailCommand(TestCase):
with LogCapture() as logger:
if add_no_commit:
call_command(self.command, '--no-commit')
assert mock_track.call_count == 0
else:
call_command(self.command)
assert mock_track.call_count == 2
logger.check_present(
(
LOG_PATH,
@@ -107,3 +109,28 @@ class TestSendProgramCourseNudgeEmailCommand(TestCase):
assert mock_track.call_count == 0
else:
assert mock_track.call_count == 2
@ddt.data(
False, True
)
@patch('common.djangoapps.student.models.segment.track')
@patch('lms.djangoapps.program_enrollments.management.commands.send_program_course_nudge_email.get_programs')
@override_settings(FEATURES=dict(ENABLE_ENTERPRISE_INTEGRATION=True))
def test_email_no_course_recommendation(self, add_no_commit, get_programs_mock, mock_track):
"""
Test Segment fired as expected.
"""
get_programs_mock.return_value = [self.enrolled_program_3]
with LogCapture() as logger:
if add_no_commit:
call_command(self.command, '--no-commit')
else:
call_command(self.command)
logger.check_present(
(
LOG_PATH,
'INFO',
'[Program Course Nudge Email] 0 Emails sent. Records: []'
)
)
assert mock_track.call_count == 0