Skip to content

Commit

Permalink
fix: lint and other quality issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tecoholic committed May 12, 2023
1 parent d8b24f4 commit 84dca10
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 10 deletions.
10 changes: 9 additions & 1 deletion enterprise/api_client/lms.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,15 @@ def has_course_mode(self, course_run_id, mode):
course_modes = self.get_course_modes(course_run_id)
return any(course_mode for course_mode in course_modes if course_mode['slug'] == mode)

def enroll_user_in_course(self, username, course_id, mode, cohort=None, enterprise_uuid=None, force_enrollment=False):
def enroll_user_in_course(
self,
username,
course_id,
mode,
cohort=None,
enterprise_uuid=None,
force_enrollment=False,
):
"""
Call the enrollment API to enroll the user in the course specified by course_id.
Expand Down
2 changes: 1 addition & 1 deletion enterprise/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1702,7 +1702,7 @@ def enroll_user(enterprise_customer, user, course_mode, *course_ids, **kwargs):
*course_ids: An iterable containing any number of course IDs to eventually enroll the user in.
kwargs: Contains optional params such as:
- enrollment_client, if it's already been instantiated and should be passed in
- force_enrollment, if the course is "Invite Only" and the "force_enrollment" is needed
- force_enrollment, if the course is "Invite Only" and the "force_enrollment" is needed
Returns:
Boolean: Whether or not enrollment succeeded for all courses specified
Expand Down
3 changes: 2 additions & 1 deletion test_utils/fake_enrollment_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ def get_course_details(course_id):
return None


def enroll_user_in_course(user, course_id, mode, cohort=None, enterprise_uuid=None, force_enrollment=False):
def enroll_user_in_course(user, course_id, mode, cohort=None, enterprise_uuid=None, force_enrollment=False): # pylint: disable=unused-argument

"""
Fake implementation.
"""
Expand Down
11 changes: 10 additions & 1 deletion tests/test_admin/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,16 @@ def test_post_existing_pending_record_with_another_enterprise_customer(self):
self._test_post_existing_record_response(response)
assert PendingEnterpriseCustomerUser.objects.filter(user_email=email).count() == 2

def _enroll_user_request(self, user, mode, course_id="", notify=True, reason="tests", discount=0.0, force_enrollment=False):
def _enroll_user_request(
self,
user,
mode,
course_id="",
notify=True,
reason="tests",
discount=0.0,
force_enrollment=False
):
"""
Perform post request to log in and submit the form to enroll a user.
"""
Expand Down
10 changes: 5 additions & 5 deletions tests/test_enterprise/api/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
update_program_with_enterprise_context,
)
from test_utils.factories import FAKER, EnterpriseCustomerUserFactory, PendingEnterpriseCustomerUserFactory, UserFactory
from test_utils.fake_enterprise_api import get_default_branding_object
from test_utils.fake_enrollment_api import get_course_details
from test_utils.fake_enterprise_api import get_default_branding_object

fake = Faker()

Expand Down Expand Up @@ -4098,10 +4098,10 @@ def test_bulk_enrollment_in_bulk_courses_pending_licenses(

self.assertEqual(len(PendingEnrollment.objects.all()), 0)

with mock.patch("enterprise.models.EnrollmentApiClient.get_course_details", wraps=get_course_details) as mock_client:
# mock_client = mock.Mock(
# get_course_details=get_course_details
# )
with mock.patch(
"enterprise.models.EnrollmentApiClient.get_course_details",
wraps=get_course_details
):
response = self.client.post(
settings.TEST_SERVER + ENTERPRISE_CUSTOMER_BULK_ENROLL_LEARNERS_IN_COURSES_ENDPOINT,
data=json.dumps(body),
Expand Down
3 changes: 2 additions & 1 deletion tests/test_enterprise/api_client/test_lms.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ def test_enroll_user_in_course():
'mode': mode,
'cohort': cohort,
'is_active': True,
'enterprise_uuid': 'None'
'enterprise_uuid': 'None',
'force_enrollment': False
}
responses.add(
responses.POST,
Expand Down

0 comments on commit 84dca10

Please sign in to comment.