1111 LearningPathProgressSerializer ,
1212)
1313from learning_paths .api .v1 .tests .factories import (
14- LearnerPathGradingCriteriaFactory ,
15- LearnerPathwayFactory ,
1614 LearningPathEnrollmentFactory ,
15+ LearningPathFactory ,
16+ LearningPathGradingCriteriaFactory ,
1717 UserFactory ,
1818)
1919from learning_paths .api .v1 .views import (
2626class LearningPathAsProgramTests (APITestCase ):
2727 def setUp (self ):
2828 super ().setUp ()
29- self .learning_paths = LearnerPathwayFactory .create_batch (5 )
29+ self .learning_paths = LearningPathFactory .create_batch (5 )
3030 self .user = UserFactory ()
3131 self .client .force_authenticate (user = self .user )
3232
@@ -51,8 +51,8 @@ def setUp(self):
5151 super ().setUp ()
5252 self .user = UserFactory ()
5353 self .client .force_authenticate (user = self .user )
54- self .learning_path = LearnerPathwayFactory .create ()
55- self .grading_criteria = LearnerPathGradingCriteriaFactory .create (
54+ self .learning_path = LearningPathFactory .create ()
55+ self .grading_criteria = LearningPathGradingCriteriaFactory .create (
5656 learning_path = self .learning_path ,
5757 required_completion = 0.80 ,
5858 required_grade = 0.75 ,
@@ -65,16 +65,16 @@ def test_learning_path_progress_success(
6565 """
6666 Test retrieving progress for a learning path.
6767 """
68- url = reverse ("learning-path-progress" , args = [self .learning_path .uuid ])
68+ url = reverse ("learning-path-progress" , args = [self .learning_path .key ])
6969 request = APIRequestFactory ().get (url , format = "json" )
7070 view = LearningPathUserProgressView .as_view ()
7171 force_authenticate (request , user = self .user )
72- response = view (request , learning_path_uuid = self .learning_path .uuid )
72+ response = view (request , learning_path_key_str = str ( self .learning_path .key ) )
7373
7474 self .assertEqual (response .status_code , status .HTTP_200_OK )
7575
7676 expected_data = {
77- "learning_path_id " : str (self .learning_path .uuid ),
77+ "learning_path_key " : str (self .learning_path .key ),
7878 "progress" : 0.75 ,
7979 "required_completion" : 0.80 ,
8080 }
@@ -88,8 +88,8 @@ def setUp(self) -> None:
8888 super ().setUp ()
8989 self .staff_user = UserFactory (is_staff = True )
9090 self .client .force_authenticate (user = self .staff_user )
91- self .learning_path = LearnerPathwayFactory .create ()
92- self .grading_criteria = LearnerPathGradingCriteriaFactory .create (
91+ self .learning_path = LearningPathFactory .create ()
92+ self .grading_criteria = LearningPathGradingCriteriaFactory .create (
9393 learning_path = self .learning_path ,
9494 required_completion = 0.80 ,
9595 required_grade = 0.75 ,
@@ -100,7 +100,7 @@ def test_learning_path_grade_grading_criteria_not_found(self):
100100 Test that the grade view returns 404 if grading criteria are not found.
101101 """
102102 self .grading_criteria .delete ()
103- url = reverse ("learning-path-grade" , args = [self .learning_path .uuid ])
103+ url = reverse ("learning-path-grade" , args = [self .learning_path .key ])
104104 response = self .client .get (url )
105105
106106 self .assertEqual (response .status_code , status .HTTP_404_NOT_FOUND )
@@ -120,7 +120,7 @@ def test_learning_path_grade_success(
120120 """
121121 Test retrieving grade for a learning path.
122122 """
123- url = reverse ("learning-path-grade" , args = [self .learning_path .uuid ])
123+ url = reverse ("learning-path-grade" , args = [self .learning_path .key ])
124124 response = self .client .get (url )
125125
126126 self .assertEqual (response .status_code , status .HTTP_200_OK )
@@ -134,8 +134,8 @@ def setUp(self) -> None:
134134 self .staff = UserFactory (is_staff = True )
135135 self .learner = UserFactory ()
136136 self .another_learner = UserFactory ()
137- self .learning_path = LearnerPathwayFactory .create ()
138- self .url = f"/api/learning_paths/v1/{ self .learning_path .uuid } /enrollments/"
137+ self .learning_path = LearningPathFactory .create ()
138+ self .url = f"/api/learning_paths/v1/{ self .learning_path .key } /enrollments/"
139139
140140 def test_get_with_username_for_staff (self ):
141141 """
@@ -289,9 +289,7 @@ def test_enrollment_returns_404_for_invalid_user_or_learning_path(self):
289289 self .assertEqual (response .status_code , status .HTTP_404_NOT_FOUND )
290290
291291 # Test invalid learning_path_id
292- url = reverse (
293- "learning-path-enrollments" , args = ["2ac8a3cc-e492-4ce9-88a3-cce4922ce9df" ]
294- )
292+ url = reverse ("learning-path-enrollments" , args = ["path-v1:this+does+not+exist" ])
295293 response = self .client .post (url )
296294 self .assertEqual (response .status_code , status .HTTP_404_NOT_FOUND )
297295
@@ -490,8 +488,8 @@ def setUp(self):
490488 self .admin_user = UserFactory (is_staff = True , is_superuser = True )
491489 self .client .force_authenticate (user = self .admin_user )
492490
493- self .learning_path1 = LearnerPathwayFactory ()
494- self .learning_path2 = LearnerPathwayFactory ()
491+ self .learning_path1 = LearningPathFactory ()
492+ self .learning_path2 = LearningPathFactory ()
495493
496494 self .user1 = UserFactory (email = "user1@example.com" )
497495 self .user2 = UserFactory (email = "user2@example.com" )
@@ -503,11 +501,11 @@ def _call_api(self, payload):
503501 def test_bulk_enrollment_success (self ):
504502 """
505503 GIVEN valid payload from staff user
506- WHEN then uuids and emails are valid
504+ WHEN then keys and emails are valid
507505 THEN create necessary enrollments and enrollment allowed objects.
508506 """
509507 payload = {
510- "learning_paths" : f"{ self .learning_path1 .uuid } ,{ self .learning_path2 .uuid } " ,
508+ "learning_paths" : f"{ self .learning_path1 .key } ,{ self .learning_path2 .key } " ,
511509 "emails" : "user1@example.com,user2@example.com,new_user@example.com" ,
512510 }
513511 response = self ._call_api (payload )
@@ -549,11 +547,11 @@ def test_bulk_enrollment_success(self):
549547 def test_bulk_enrollment_with_invalid_learning_path (self ):
550548 """
551549 GIVEN valid payload from staff user
552- WHEN the learning path uuid is invalid
550+ WHEN the learning path key is invalid
553551 THEN no enrollments are created.
554552 """
555553 payload = {
556- "learning_paths" : "invalid-path-uuid " ,
554+ "learning_paths" : "invalid-path-key " ,
557555 "emails" : "user1@example.com,user2@example.com" ,
558556 }
559557 response = self ._call_api (payload )
@@ -569,7 +567,7 @@ def test_bulk_enrollment_with_invalid_and_valid_emails(self):
569567 THEN no enrollments are created for the invalid email.
570568 """
571569 payload = {
572- "learning_paths" : f"{ self .learning_path1 .uuid } " ,
570+ "learning_paths" : f"{ self .learning_path1 .key } " ,
573571 "emails" : "user1@example.com,invalid_email" ,
574572 }
575573 response = self ._call_api (payload )
@@ -600,7 +598,7 @@ def test_bulk_enrollment_unauthenticated(self):
600598 """
601599 self .client .logout ()
602600 payload = {
603- "learning_paths" : f"{ self .learning_path1 .uuid } " ,
601+ "learning_paths" : f"{ self .learning_path1 .key } " ,
604602 "emails" : "user1@example.com" ,
605603 }
606604 # Un-authenticates
@@ -623,7 +621,7 @@ def test_bulk_enrollment_returned_counts_reflect_only_new_ones(self):
623621 )
624622
625623 payload = {
626- "learning_paths" : f"{ self .learning_path1 .uuid } " ,
624+ "learning_paths" : f"{ self .learning_path1 .key } " ,
627625 "emails" : self .user1 .email ,
628626 }
629627
@@ -644,7 +642,7 @@ def test_re_enrollment(self):
644642 )
645643
646644 payload = {
647- "learning_paths" : f"{ self .learning_path1 .uuid } " ,
645+ "learning_paths" : f"{ self .learning_path1 .key } " ,
648646 "emails" : self .user1 .email ,
649647 }
650648
0 commit comments