Repository: ucfopen/canvasapi

Issue:
List Assignments (AssignmentGroup)
**What resource needs additional coverage?**
List Assignments (AssignmentGroup)

**What endpoints need to be covered?**
https://canvas.instructure.com/doc/api/assignments.html#method.assignments_api.index

- [ ] List assignments (the second one)

We covered getting all the assignments in a course already, but need to handle the case for AssignmentGroups

Discussion:
coveralls: 
[![Coverage Status](https://coveralls.io/builds/26860046/badge)](https://coveralls.io/builds/26860046)

Coverage remained the same at 100.0% when pulling **41c3d2a363854ce14997492e80b95193e0f89c3c on ctcuff:issue/332-list-assignments** into **e2a04a4731f69699762915cbc5563057849f7141 on ucfopen:develop**.


Patch:
diff --git a/canvasapi/assignment.py b/canvasapi/assignment.py
index 6fb5155..3637e8f 100644
--- a/canvasapi/assignment.py
+++ b/canvasapi/assignment.py
@@ -251,6 +251,26 @@ class Assignment(CanvasObject):
             for extension in extension_list
         ]
 
+    def submissions_bulk_update(self, **kwargs):
+        """
+        Update the grading and comments on multiple student's assignment
+        submissions in an asynchronous job.
+
+        :calls: `POST /api/v1/courses/:course_id/assignments/:assignment_id/ \
+            submissions/update_grades \
+        <https://canvas.instructure.com/doc/api/submissions.html#method.submissions_api.bulk_update>`_
+
+        :rtype: :class:`canvasapi.progress.Progress`
+        """
+        response = self._requester.request(
+            "POST",
+            "courses/{}/assignments/{}/submissions/update_grades".format(
+                self.course_id, self.id
+            ),
+            _kwargs=combine_kwargs(**kwargs),
+        )
+        return Progress(self._requester, response.json())
+
     def submit(self, submission, file=None, **kwargs):
         """
         Makes a submission for an assignment.
@@ -295,26 +315,6 @@ class Assignment(CanvasObject):
 
         return Submission(self._requester, response_json)
 
-    def submissions_bulk_update(self, **kwargs):
-        """
-        Update the grading and comments on multiple student's assignment
-        submissions in an asynchronous job.
-
-        :calls: `POST /api/v1/courses/:course_id/assignments/:assignment_id/ \
-            submissions/update_grades \
-        <https://canvas.instructure.com/doc/api/submissions.html#method.submissions_api.bulk_update>`_
-
-        :rtype: :class:`canvasapi.progress.Progress`
-        """
-        response = self._requester.request(
-            "POST",
-            "courses/{}/assignments/{}/submissions/update_grades".format(
-                self.course_id, self.id
-            ),
-            _kwargs=combine_kwargs(**kwargs),
-        )
-        return Progress(self._requester, response.json())
-
     def upload_to_submission(self, file, user="self", **kwargs):
         """
         Upload a file to a submission.
@@ -356,40 +356,40 @@ class AssignmentGroup(CanvasObject):
     def __str__(self):
         return "{} ({})".format(self.name, self.id)
 
-    def edit(self, **kwargs):
+    def delete(self, **kwargs):
         """
-        Modify this assignment group.
+        Delete this assignment.
 
-        :calls: `PUT /api/v1/courses/:course_id/assignment_groups/:assignment_group_id \
-        <https://canvas.instructure.com/doc/api/assignment_groups.html#method.assignment_groups_api.update>`_
+        :calls: `DELETE /api/v1/courses/:course_id/assignment_groups/:assignment_group_id \
+        <https://canvas.instructure.com/doc/api/assignment_groups.html#method.assignment_groups_api.destroy>`_
 
         :rtype: :class:`canvasapi.assignment.AssignmentGroup`
         """
         response = self._requester.request(
-            "PUT",
+            "DELETE",
             "courses/{}/assignment_groups/{}".format(self.course_id, self.id),
             _kwargs=combine_kwargs(**kwargs),
         )
-
-        if "name" in response.json():
-            super(AssignmentGroup, self).set_attributes(response.json())
-
         return AssignmentGroup(self._requester, response.json())
 
-    def delete(self, **kwargs):
+    def edit(self, **kwargs):
         """
-        Delete this assignment.
+        Modify this assignment group.
 
-        :calls: `DELETE /api/v1/courses/:course_id/assignment_groups/:assignment_group_id \
-        <https://canvas.instructure.com/doc/api/assignment_groups.html#method.assignment_groups_api.destroy>`_
+        :calls: `PUT /api/v1/courses/:course_id/assignment_groups/:assignment_group_id \
+        <https://canvas.instructure.com/doc/api/assignment_groups.html#method.assignment_groups_api.update>`_
 
         :rtype: :class:`canvasapi.assignment.AssignmentGroup`
         """
         response = self._requester.request(
-            "DELETE",
+            "PUT",
             "courses/{}/assignment_groups/{}".format(self.course_id, self.id),
             _kwargs=combine_kwargs(**kwargs),
         )
+
+        if "name" in response.json():
+            super(AssignmentGroup, self).set_attributes(response.json())
+
         return AssignmentGroup(self._requester, response.json())
 
 
diff --git a/canvasapi/course.py b/canvasapi/course.py
index 3ce4983..b782347 100644
--- a/canvasapi/course.py
+++ b/canvasapi/course.py
@@ -4,6 +4,7 @@ import warnings
 
 from six import python_2_unicode_compatible, text_type, string_types
 
+from canvasapi.assignment import Assignment, AssignmentGroup
 from canvasapi.blueprint import BlueprintSubscription
 from canvasapi.canvas_object import CanvasObject
 from canvasapi.collaboration import Collaboration
@@ -733,6 +734,34 @@ class Course(CanvasObject):
             _kwargs=combine_kwargs(**kwargs),
         )
 
+    def get_assignments_for_group(self, assignment_group, **kwargs):
+        """
+        Returns a paginated list of assignments for the given assignment group
+
+        :calls: `GET /api/v1/courses/:course_id/assignment_groups/:assignment_group_id/assignments\
+        <https://canvas.instructure.com/doc/api/assignments.html#method.assignments_api.index>`_
+
+        :param assignment_group: The object or id of the assignment group
+        :type assignment_group: :class: `canvasapi.assignment.AssignmentGroup` or int
+
+        :rtype: :class:`canvasapi.paginated_list.PaginatedList` of
+            :class:`canvasapi.assignment.Assignment`
+        """
+
+        assignment_group_id = obj_or_id(
+            assignment_group, "assignment_group", (AssignmentGroup,)
+        )
+
+        return PaginatedList(
+            Assignment,
+            self._requester,
+            "GET",
+            "courses/{}/assignment_groups/{}/assignments".format(
+                self.id, assignment_group_id
+            ),
+            _kwargs=combine_kwargs(**kwargs),
+        )
+
     def get_blueprint(self, template="default", **kwargs):
         """
         Return the blueprint of a given ID.


Test patch:
diff --git a/tests/fixtures/course.json b/tests/fixtures/course.json
index f00bb64..06bd347 100644
--- a/tests/fixtures/course.json
+++ b/tests/fixtures/course.json
@@ -146,6 +146,25 @@
 		},
 		"status_code": 200
 	},
+	"get_assignments_for_group": {
+		"method": "GET",
+		"endpoint": "courses/1/assignment_groups/5/assignments",
+		"data": [
+			{
+				"id": 3,
+				"course_id": 1,
+				"name": "Assignment 1",
+				"description": "Do this assignment"
+			},
+			{
+				"id": 4,
+				"course_id": 1,
+				"name": "Assignment 2",
+				"description": "Do this assignment too"
+			}
+		],
+		"status_code": 200
+	},
 	"get_blueprint": {
 		"method": "GET",
 		"endpoint": "courses/1/blueprint_templates/1",
diff --git a/tests/test_course.py b/tests/test_course.py
index 0d1a5ee..83773d8 100644
--- a/tests/test_course.py
+++ b/tests/test_course.py
@@ -723,6 +723,43 @@ class TestCourse(unittest.TestCase):
         self.assertTrue(hasattr(assignment_group_by_obj, "course_id"))
         self.assertEqual(assignment_group_by_obj.course_id, 1)
 
+    # get_assignments_for_group()
+    def test_get_assignments_for_group(self, m):
+        register_uris(
+            {
+                "course": ["get_assignments_for_group"],
+                "assignment": ["get_assignment_group"],
+            },
+            m,
+        )
+
+        assignment_group_obj = self.course.get_assignment_group(5)
+        response = self.course.get_assignments_for_group(5)
+        assignments = [assignment for assignment in response]
+
+        self.assertIsInstance(response, PaginatedList)
+
+        for assignment in assignments:
+            self.assertIsInstance(assignment, Assignment)
+            self.assertTrue(hasattr(assignment, "id"))
+            self.assertTrue(hasattr(assignment, "name"))
+            self.assertTrue(hasattr(assignment, "course_id"))
+            self.assertTrue(hasattr(assignment, "description"))
+            self.assertEqual(assignment.course_id, self.course.id)
+
+        response = self.course.get_assignments_for_group(assignment_group_obj)
+        assignments = [assignment for assignment in response]
+
+        self.assertIsInstance(response, PaginatedList)
+
+        for assignment in assignments:
+            self.assertIsInstance(assignment, Assignment)
+            self.assertTrue(hasattr(assignment, "id"))
+            self.assertTrue(hasattr(assignment, "name"))
+            self.assertTrue(hasattr(assignment, "course_id"))
+            self.assertTrue(hasattr(assignment, "description"))
+            self.assertEqual(assignment.course_id, self.course.id)
+
     # list_assignment_groups()
     def test_list_assignment_groups(self, m):
         register_uris(