Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
b6993c39
Commit
b6993c39
authored
7 years ago
by
Ahsan Ulhaq
Browse files
Options
Downloads
Patches
Plain Diff
Stop program cert awarding if cert is not configured in credentials
ECOM-4478
parent
79a40eb3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
openedx/core/djangoapps/programs/tasks/v1/tasks.py
+6
-0
6 additions, 0 deletions
openedx/core/djangoapps/programs/tasks/v1/tasks.py
openedx/core/djangoapps/programs/tasks/v1/tests/test_tasks.py
+17
-0
17 additions, 0 deletions
...edx/core/djangoapps/programs/tasks/v1/tests/test_tasks.py
with
23 additions
and
0 deletions
openedx/core/djangoapps/programs/tasks/v1/tasks.py
+
6
−
0
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
)
...
...
This diff is collapsed.
Click to expand it.
openedx/core/djangoapps/programs/tasks/v1/tests/test_tasks.py
+
17
−
0
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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment