Skip to content

Commit

Permalink
fixup!: delete unneeded tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rebecca Graber authored and Rebecca Graber committed Nov 2, 2023
1 parent 5d84a4d commit a513fb5
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 177 deletions.
67 changes: 0 additions & 67 deletions common/djangoapps/student/tests/test_handlers.py

This file was deleted.

110 changes: 0 additions & 110 deletions lms/djangoapps/certificates/tests/test_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
CertificateGenerationConfiguration,
GeneratedCertificate
)
from lms.djangoapps.certificates.signals import (
listen_for_certificate_created_event,
listen_for_certificate_revoked_event
)
from lms.djangoapps.certificates.tests.factories import CertificateAllowlistFactory, GeneratedCertificateFactory
from lms.djangoapps.grades.course_grade_factory import CourseGradeFactory
from lms.djangoapps.grades.tests.utils import mock_passing_grade
Expand Down Expand Up @@ -443,109 +439,3 @@ def test_verified_to_audit(self):
) as mock_allowlist_task:
self.verified_enrollment.change_mode('audit')
mock_allowlist_task.assert_not_called()


class CertificateEventBusTests(ModuleStoreTestCase):
"""
Tests for Certificate events that interact with the event bus.
"""
def setUp(self):
super().setUp()
self.user = UserFactory.create()
self.name = f'{self.user.first_name} {self.user.last_name}'
self.course = CourseFactory.create(self_paced=True)
self.enrollment = CourseEnrollmentFactory(
user=self.user,
course_id=self.course.id,
is_active=True,
mode='verified',
)

def _create_event_data(self, event_type, certificate_status):
"""
Utility function to create test data for unit tests.
"""
expected_course_data = CourseData(course_key=self.course.id)
expected_user_data = UserData(
pii=UserPersonalData(
username=self.user.username,
email=self.user.email,
name=self.name,
),
id=self.user.id,
is_active=self.user.is_active
)
expected_certificate_data = CertificateData(
user=expected_user_data,
course=expected_course_data,
mode='verified',
grade='',
current_status=certificate_status,
download_url='',
name='',
)
expected_event_metadata = EventsMetadata(
event_type=event_type.event_type,
id=uuid4(),
minorversion=0,
source='openedx/lms/web',
sourcehost='lms.test',
time=datetime.now(timezone.utc)
)

return {
'certificate': expected_certificate_data,
'metadata': expected_event_metadata,
}

@override_settings(SEND_CERTIFICATE_CREATED_SIGNAL=False)
@mock.patch('lms.djangoapps.certificates.signals.get_producer', autospec=True)
def test_certificate_created_event_disabled(self, mock_producer):
"""
Test to verify that we do not publish `CERTIFICATE_CREATED` events to the event bus if the
`SEND_CERTIFICATE_CREATED_SIGNAL` setting is disabled.
"""
listen_for_certificate_created_event(None, CERTIFICATE_CREATED)
mock_producer.assert_not_called()

@override_settings(SEND_CERTIFICATE_REVOKED_SIGNAL=False)
@mock.patch('lms.djangoapps.certificates.signals.get_producer', autospec=True)
def test_certificate_revoked_event_disabled(self, mock_producer):
"""
Test to verify that we do not publish `CERTIFICATE_REVOKED` events to the event bus if the
`SEND_CERTIFICATE_REVOKED_SIGNAL` setting is disabled.
"""
listen_for_certificate_created_event(None, CERTIFICATE_REVOKED)
mock_producer.assert_not_called()

@override_settings(SEND_CERTIFICATE_CREATED_SIGNAL=True)
@mock.patch('lms.djangoapps.certificates.signals.get_producer', autospec=True)
def test_certificate_created_event_enabled(self, mock_producer):
"""
Test to verify that we push `CERTIFICATE_CREATED` events to the event bus if the
`SEND_CERTIFICATE_CREATED_SIGNAL` setting is enabled.
"""
event_data = self._create_event_data(CERTIFICATE_CREATED, CertificateStatuses.downloadable)
listen_for_certificate_created_event(None, CERTIFICATE_CREATED, **event_data)
# verify that the data sent to the event bus matches what we expect
data = mock_producer.return_value.send.call_args.kwargs
assert data['signal'].event_type == CERTIFICATE_CREATED.event_type
assert data['event_data']['certificate'] == event_data['certificate']
assert data['topic'] == 'learning-certificate-lifecycle'
assert data['event_key_field'] == 'certificate.course.course_key'

@override_settings(SEND_CERTIFICATE_REVOKED_SIGNAL=True)
@mock.patch('lms.djangoapps.certificates.signals.get_producer', autospec=True)
def test_certificate_revoked_event_enabled(self, mock_producer):
"""
Test to verify that we push `CERTIFICATE_REVOKED` events to the event bus if the
`SEND_CERTIFICATE_REVOKED_SIGNAL` setting is enabled.
"""
event_data = self._create_event_data(CERTIFICATE_REVOKED, CertificateStatuses.notpassing)
listen_for_certificate_revoked_event(None, CERTIFICATE_REVOKED, **event_data)
# verify that the data sent to the event bus matches what we expect
data = mock_producer.return_value.send.call_args.kwargs
assert data['signal'].event_type == CERTIFICATE_REVOKED.event_type
assert data['event_data']['certificate'] == event_data['certificate']
assert data['topic'] == 'learning-certificate-lifecycle'
assert data['event_key_field'] == 'certificate.course.course_key'

0 comments on commit a513fb5

Please sign in to comment.