Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
b6993c39
Commit
b6993c39
authored
Apr 26, 2017
by
Ahsan Ulhaq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop program cert awarding if cert is not configured in credentials
ECOM-4478
parent
79a40eb3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
openedx/core/djangoapps/programs/tasks/v1/tasks.py
+6
-0
openedx/core/djangoapps/programs/tasks/v1/tests/test_tasks.py
+17
-0
No files found.
openedx/core/djangoapps/programs/tasks/v1/tasks.py
View file @
b6993c39
...
...
@@ -6,6 +6,7 @@ from celery.utils.log import get_task_logger # pylint: disable=no-name-in-modul
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.core.exceptions
import
ImproperlyConfigured
from
edx_rest_api_client
import
exceptions
from
edx_rest_api_client.client
import
EdxRestApiClient
from
provider.oauth2.models
import
Client
...
...
@@ -196,6 +197,11 @@ def award_program_certificates(self, username):
try
:
award_program_certificate
(
credentials_client
,
username
,
program_uuid
)
LOGGER
.
info
(
'Awarded certificate for program
%
s to user
%
s'
,
program_uuid
,
username
)
except
exceptions
.
HttpNotFoundError
:
LOGGER
.
exception
(
'Certificate for program
%
s not configured, unable to award certificate to
%
s'
,
program_uuid
,
username
)
except
Exception
:
# pylint: disable=broad-except
# keep trying to award other certs, but retry the whole task to fix any missing entries
LOGGER
.
exception
(
'Failed to award certificate for program
%
s to user
%
s'
,
program_uuid
,
username
)
...
...
openedx/core/djangoapps/programs/tasks/v1/tests/test_tasks.py
View file @
b6993c39
...
...
@@ -7,6 +7,7 @@ from celery.exceptions import MaxRetriesExceededError
import
ddt
from
django.conf
import
settings
from
django.test
import
override_settings
,
TestCase
from
edx_rest_api_client
import
exceptions
from
edx_rest_api_client.client
import
EdxRestApiClient
from
edx_oauth2_provider.tests.factories
import
ClientFactory
import
httpretty
...
...
@@ -299,3 +300,19 @@ class AwardProgramCertificatesTestCase(CatalogIntegrationMixin, CredentialsApiCo
tasks
.
award_program_certificates
.
delay
(
self
.
student
.
username
)
.
get
()
self
.
assertEqual
(
mock_get_certified_programs
.
call_count
,
2
)
self
.
assertEqual
(
mock_award_program_certificate
.
call_count
,
1
)
def
test_no_retry_on_credentials_api_not_found_errors
(
self
,
mock_get_completed_programs
,
mock_get_certified_programs
,
mock_award_program_certificate
,
):
mock_get_completed_programs
.
return_value
=
[
1
,
2
]
mock_get_certified_programs
.
side_effect
=
[[],
[
2
]]
mock_award_program_certificate
.
side_effect
=
self
.
_make_side_effect
(
[
exceptions
.
HttpNotFoundError
(),
None
]
)
tasks
.
award_program_certificates
.
delay
(
self
.
student
.
username
)
.
get
()
self
.
assertEqual
(
mock_award_program_certificate
.
call_count
,
2
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment