Merge pull request #11520 from edx/jsa/ecom-3638

Specify high priority queue for credentials generation task.
This commit is contained in:
Jim Abramson
2016-02-12 14:29:49 -05:00
10 changed files with 36 additions and 9 deletions

View File

@@ -1,9 +1,14 @@
"""Tests for models supporting Credentials-related functionality."""
import unittest
from django.conf import settings
from django.test import TestCase
from openedx.core.djangoapps.credentials.tests.mixins import CredentialsApiConfigMixin
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
class TestCredentialsApiConfig(CredentialsApiConfigMixin, TestCase):
"""Tests covering the CredentialsApiConfig model."""
def test_url_construction(self):

View File

@@ -1,4 +1,7 @@
"""Tests covering Credentials utilities."""
import unittest
from django.conf import settings
from django.core.cache import cache
from django.test import TestCase
import httpretty
@@ -15,6 +18,7 @@ from openedx.core.djangoapps.programs.models import ProgramsApiConfig
from student.tests.factories import UserFactory
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
class TestCredentialsRetrieval(ProgramsApiConfigMixin, CredentialsApiConfigMixin, CredentialsDataMixin,
ProgramsDataMixin, TestCase):
""" Tests covering the retrieval of user credentials from the Credentials

View File

@@ -17,6 +17,8 @@ from openedx.core.lib.token_utils import get_id_token
LOGGER = get_task_logger(__name__)
# Under cms the following setting is not defined, leading to errors during tests.
ROUTING_KEY = getattr(settings, 'CREDENTIALS_GENERATION_ROUTING_KEY', None)
def get_api_client(api_config, student):
@@ -115,7 +117,7 @@ def award_program_certificate(client, username, program_id):
})
@task(bind=True, ignore_result=True)
@task(bind=True, ignore_result=True, routing_key=ROUTING_KEY)
def award_program_certificates(self, username):
"""
This task is designed to be called whenever a student's completion status

View File

@@ -6,6 +6,7 @@ import ddt
import httpretty
import json
import mock
import unittest
from celery.exceptions import MaxRetriesExceededError
from django.conf import settings
@@ -22,6 +23,7 @@ from student.tests.factories import UserFactory
TASKS_MODULE = 'openedx.core.djangoapps.programs.tasks.v1.tasks'
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
class GetApiClientTestCase(TestCase, ProgramsApiConfigMixin):
"""
Test the get_api_client function
@@ -46,6 +48,7 @@ class GetApiClientTestCase(TestCase, ProgramsApiConfigMixin):
self.assertEqual(api_client._store['session'].auth.token, 'test-token') # pylint: disable=protected-access
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
class GetCompletedCoursesTestCase(TestCase):
"""
Test the get_completed_courses function
@@ -89,6 +92,7 @@ class GetCompletedCoursesTestCase(TestCase):
])
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
class GetCompletedProgramsTestCase(TestCase):
"""
Test the get_completed_programs function
@@ -115,6 +119,7 @@ class GetCompletedProgramsTestCase(TestCase):
self.assertEqual(result, [1, 2, 3])
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
class GetAwardedCertificateProgramsTestCase(TestCase):
"""
Test the get_awarded_certificate_programs function
@@ -155,6 +160,7 @@ class GetAwardedCertificateProgramsTestCase(TestCase):
self.assertEqual(result, [1])
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
class AwardProgramCertificateTestCase(TestCase):
"""
Test the award_program_certificate function
@@ -183,6 +189,7 @@ class AwardProgramCertificateTestCase(TestCase):
self.assertEqual(json.loads(httpretty.last_request().body), expected_body)
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
@ddt.ddt
@mock.patch(TASKS_MODULE + '.award_program_certificate')
@mock.patch(TASKS_MODULE + '.get_awarded_certificate_programs')

View File

@@ -1,4 +1,7 @@
"""Tests covering Programs utilities."""
import unittest
from django.conf import settings
from django.core.cache import cache
from django.test import TestCase
import httpretty
@@ -15,6 +18,7 @@ from openedx.core.djangoapps.programs.utils import (
from student.tests.factories import UserFactory
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
class TestProgramRetrieval(ProgramsApiConfigMixin, ProgramsDataMixin,
CredentialsApiConfigMixin, TestCase):
"""Tests covering the retrieval of programs from the Programs service."""