'Verify that signal is sent, received, and fires task
based on \'SELF_PACED_ONLY\' flag'

def test_cert_generation_on_whitelist_append_self_paced(self):

    with mock.patch('lms.djangoapps.certificates.signals.generate_certificate.apply_async', return_value=None) as mock_generate_certificate_apply_async:
        with waffle.waffle().override(waffle.SELF_PACED_ONLY, active=False):
            CertificateWhitelist.objects.create(user=self.user, course_id=self.course.id)
            mock_generate_certificate_apply_async.assert_not_called()
        with waffle.waffle().override(waffle.SELF_PACED_ONLY, active=True):
            CertificateWhitelist.objects.create(user=self.user, course_id=self.course.id)
            mock_generate_certificate_apply_async.assert_called_with(kwargs={'student': unicode(self.user.id), 'course_key': unicode(self.course.id)})
