-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #623 from edx/iahmad/ENT-2346-update-to-manage_lea…
…rners-admin-page-for-multiple-learner-enterprises ENT-2346 Overridden get in EnterpriseCustomerUser manager
- Loading branch information
Showing
4 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,6 +203,30 @@ class TestEnterpriseCustomerUserManager(unittest.TestCase): | |
Tests EnterpriseCustomerUserManager. | ||
""" | ||
|
||
def test_get_returns_only_one_when_multiple_objects_returned(self): | ||
""" | ||
Test that get on custom model manager returns only the active object when multiple objects found. | ||
""" | ||
enterprise_customer1 = factories.EnterpriseCustomerFactory() | ||
enterprise_customer2 = factories.EnterpriseCustomerFactory() | ||
user = factories.UserFactory(email='[email protected]') | ||
first_customer_user = factories.EnterpriseCustomerUserFactory( | ||
enterprise_customer=enterprise_customer1, | ||
user_id=user.id | ||
) | ||
second_customer_user = factories.EnterpriseCustomerUserFactory( | ||
enterprise_customer=enterprise_customer2, | ||
user_id=user.id, | ||
active=False | ||
) | ||
all_customer_users = [first_customer_user, second_customer_user] | ||
fetched_object = EnterpriseCustomerUser.objects.get(user_id=user.id) | ||
self.assertIn(fetched_object, all_customer_users) | ||
self.assertEqual(fetched_object.active, True) | ||
EnterpriseCustomerUser.objects.filter(user_id=user.id).delete() | ||
with raises(EnterpriseCustomerUser.DoesNotExist): | ||
EnterpriseCustomerUser.objects.get(user_id=user.id) | ||
|
||
@ddt.data("[email protected]", "[email protected]", "[email protected]") | ||
def test_link_user_existing_user(self, user_email): | ||
enterprise_customer = factories.EnterpriseCustomerFactory() | ||
|