Skip to content

fix: Fixing the issue of deactivating user while seat allocation#215

Merged
rgopalrao-sonata-png merged 1 commit into
mainfrom
rgopalrao/ENT-12003
Jun 25, 2026
Merged

fix: Fixing the issue of deactivating user while seat allocation#215
rgopalrao-sonata-png merged 1 commit into
mainfrom
rgopalrao/ENT-12003

Conversation

@rgopalrao-sonata-png

Copy link
Copy Markdown
Contributor

Summary:
Jira ticket: https://2u-internal.atlassian.net/browse/ENT-12003
Guard against inadvertent enterprise link deactivation on re-assignment

Before calling create_pending_enterprise_users, create_pending_enterprise_learner_for_assignment_task now checks whether the learner is already actively linked to the target enterprise. If so, it records a successful linked action and returns early — skipping the LMS call that would otherwise trigger PendingEnterpriseCustomerUserSerializer's "inactivate other customers" side-effect.

Changes:

lms_client.py: new get_enterprise_learner_by_email() helper — resolves an email to an LMS user ID, then fetches the enterprise-learner record
tasks.py: pre-flight active-link check with early return; moves get_normalized_metadata_for_assignment import to content_metadata_api where it belongs
test_tasks.py: covers the skip path (active link), the proceed path (inactive/missing active field), and patches the new check in setUp so existing tests are unaffected

Test results:
image

@rgopalrao-sonata-png rgopalrao-sonata-png requested review from a team as code owners June 25, 2026 07:03
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.23810% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.46%. Comparing base (22ade54) to head (6a6e5ad).

Files with missing lines Patch % Lines
enterprise_access/apps/api_client/lms_client.py 93.75% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #215      +/-   ##
==========================================
+ Coverage   86.44%   86.46%   +0.01%     
==========================================
  Files         154      154              
  Lines       12848    12869      +21     
  Branches     1227     1232       +5     
==========================================
+ Hits        11107    11127      +20     
  Misses       1426     1426              
- Partials      315      316       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pbitla-sonata pbitla-sonata self-requested a review June 25, 2026 07:16
@rgopalrao-sonata-png rgopalrao-sonata-png force-pushed the rgopalrao/ENT-12003 branch 2 times, most recently from bbea207 to 8dc5a86 Compare June 25, 2026 08:22
@rgopalrao-sonata-png rgopalrao-sonata-png merged commit c115c11 into main Jun 25, 2026
6 checks passed
@rgopalrao-sonata-png rgopalrao-sonata-png deleted the rgopalrao/ENT-12003 branch June 25, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants