Repository: ucfopen/canvasapi (language: python)

Issue:
Delete Group Pages
**What resource needs additional coverage?**
Page

**What endpoints need to be covered?**
[Delete page](https://canvas.instructure.com/doc/api/pages.html#method.wiki_pages_api.destroy)

We already have [`Page.delete()`](https://github.com/ucfopen/canvasapi/blob/develop/canvasapi/page.py#L10), but it only works for course pages. Modify `Page.delete` to use the `parent_type` and `parent_id` attributes of the `Page` class to allow for both course and group pages to be deleted.



Discussion / hints:

Fix patch:
diff --git a/AUTHORS.md b/AUTHORS.md
index 3b38cd8d..d8387ff4 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -26,8 +26,9 @@ Patches and Suggestions
 - Bradford Lynch [@bradfordlynch](https://github.com/bradfordlynch)
 - Brian Bennett [@bennettscience](https://github.com/bennettscience)
 - Bruce Spang [@brucespang](https://github.com/brucespang)
-- Catherine Abbruzzese [@cat0698](https://github.com/cat0698))
+- Caitlin Fabian [@Caitlin-Fabian](https://github.com/Caitlin-Fabian)
 - Cameron Cuff [@ctcuff](https://github.com/ctcuff)
+- Catherine Abbruzzese [@cat0698](https://github.com/cat0698)
 - Craig Thompson [@craigdsthompson](https://github.com/craigdsthompson)
 - Dalton Durst [@UniversalSuperBox](https://github.com/UniversalSuperBox)
 - Damian Sweeney [@damianfs](https://github.com/damianfs)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1a1aad4b..d0dcc181 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,7 @@
 ### New Endpoint Coverage
 
 - New Quizzes
+- Delete Page in Groups (Thanks, [@Caitlin-Fabian](https://github.com/Caitlin-Fabian))
 
 ### General
 
diff --git a/canvasapi/page.py b/canvasapi/page.py
index e0840b88..207cc182 100644
--- a/canvasapi/page.py
+++ b/canvasapi/page.py
@@ -12,13 +12,17 @@ def delete(self, **kwargs):
         Delete this page.
 
         :calls: `DELETE /api/v1/courses/:course_id/pages/:url \
-        <https://canvas.instructure.com/doc/api/pages.html#method.wiki_pages_api.destroy>`_
+            <https://canvas.instructure.com/doc/api/pages.html#method.wiki_pages_api.destroy>`_
+            or
+            `DELETE /api/v1/groups/:group_id/pages/:url \
+            <https://canvas.instructure.com/doc/api/pages.html#method.wiki_pages_api.destroy>`_
 
         :rtype: :class:`canvasapi.page.Page`
         """
+
         response = self._requester.request(
             "DELETE",
-            "courses/{}/pages/{}".format(self.course_id, self.url),
+            "{}s/{}/pages/{}".format(self.parent_type, self.parent_id, self.url),
             _kwargs=combine_kwargs(**kwargs),
         )
         return Page(self._requester, response.json())
@@ -51,7 +55,8 @@ def get_parent(self, **kwargs):
 
         :calls: `GET /api/v1/groups/:group_id \
             <https://canvas.instructure.com/doc/api/groups.html#method.groups.show>`_
-            or :calls: `GET /api/v1/courses/:id \
+            or
+            `GET /api/v1/courses/:id \
             <https://canvas.instructure.com/doc/api/courses.html#method.courses.show>`_
 
         :rtype: :class:`canvasapi.group.Group` or :class:`canvasapi.course.Course`


Test patch:
diff --git a/tests/fixtures/page.json b/tests/fixtures/page.json
index dac500fb..d98e7120 100644
--- a/tests/fixtures/page.json
+++ b/tests/fixtures/page.json
@@ -1,116 +1,126 @@
 {
-	"get_page": {
-		"method": "GET",
-		"endpoint": "courses/1/pages/my-url",
-		"data": {
-			"id": 1,
-			"url": "my-url",
-			"title": "Awesome Page"
-		},
-		"status_code": 200
-	},
-	"edit": {
-		"method": "PUT",
-		"endpoint": "courses/1/pages/my-url",
-		"data": {
-			"id": 1,
-			"title": "New Page",
-			"url": "my-url"
-		},
-		"status_code": 200
-	},
-	"delete_page": {
-		"method": "DELETE",
-		"endpoint": "courses/1/pages/my-url",
-		"data": {
-			"id": 1,
-			"title": "Page To Be Deleted",
-			"url": "my-url"
-		},
-		"status_code": 200
-	},
-	"list_revisions": {
-		"method": "GET",
-		"endpoint": "courses/1/pages/my-url/revisions",
-		"data": [
-			{
-				"id": 1,
-				"title": "Revision 1"
-			},
-			{
-				"id": 2,
-				"title": "Revision 2"
-			}
-		],
-		"status_code": 200,
-		"headers": {
-			"Link": "<https://example.com/api/v1/courses/1/pages/my-url/revisions?page=2&per_page=2>; rel=\"next\""
-		}
-	},
-	"list_revisions2": {
-		"method": "GET",
-		"endpoint": "courses/1/pages/my-url/revisions?page=2&per_page=2",
-		"data": [
-			{
-				"id": 3,
-				"title": "Revision 3"
-			},
-			{
-				"id": 4,
-				"title": "Revision 4"
-			}
-		],
-		"status_code": 200
-	},
-	"latest_revision": {
-		"method": "GET",
-		"endpoint": "courses/1/pages/my-url/revisions/latest",
-		"data": {
-			"id": 1,
-			"title": "Latest Revision",
-			"url": "my-url"
-		},
-		"status_code": 200
-	},
-	"get_latest_rev_by_id": {
-		"method": "GET",
-		"endpoint": "courses/1/pages/my-url/revisions/2",
-		"data": {
-			"id": 2,
-			"updated_at": "2012-08-07T11:23:58-06:00",
-			"revision_id": 2,
-			"url": "my-url"
-		},
-		"status_code": 200
-	},
-	"get_latest_rev_by_id_group": {
-		"method": "GET",
-		"endpoint": "groups/1/pages/my-url/revisions/2",
-		"data": {
-			"id": 2,
-			"revision_id": 2,
-			"url": "my-url"
-		},
-		"status_code": 200
-	},
-	"revert_to_revision": {
-		"method": "POST",
-		"endpoint": "courses/1/pages/my-url/revisions/3",
-		"data": {
-			"id": 1,
-			"revision_id": 3,
-			"url": "my-url"
-		},
-		"status_code": 200
-	},
-	"revert_to_revision_group": {
-		"method": "POST",
-		"endpoint": "groups/1/pages/my-url/revisions/3",
-		"data": {
-			"id": 1,
-			"revision_id": 3,
-			"url": "my-url"
-		},
-		"status_code": 200
-	}
-}
\ No newline at end of file
+    "get_page": {
+        "method": "GET",
+        "endpoint": "courses/1/pages/my-url",
+        "data": {
+            "id": 1,
+            "url": "my-url",
+            "title": "Awesome Page"
+        },
+        "status_code": 200
+    },
+    "edit": {
+        "method": "PUT",
+        "endpoint": "courses/1/pages/my-url",
+        "data": {
+            "id": 1,
+            "title": "New Page",
+            "url": "my-url"
+        },
+        "status_code": 200
+    },
+    "delete_page_course": {
+        "method": "DELETE",
+        "endpoint": "courses/1/pages/my-url",
+        "data": {
+            "id": 1,
+            "title": "Page To Be Deleted",
+            "url": "my-url"
+        },
+        "status_code": 200
+    },
+    "delete_page_group": {
+        "method": "DELETE",
+        "endpoint": "groups/1/pages/my-url",
+        "data": {
+            "id": 1,
+            "title": "Page To Be Deleted",
+            "url": "my-url"
+        },
+        "status_code": 200
+    },
+    "list_revisions": {
+        "method": "GET",
+        "endpoint": "courses/1/pages/my-url/revisions",
+        "data": [
+            {
+                "id": 1,
+                "title": "Revision 1"
+            },
+            {
+                "id": 2,
+                "title": "Revision 2"
+            }
+        ],
+        "status_code": 200,
+        "headers": {
+            "Link": "<https://example.com/api/v1/courses/1/pages/my-url/revisions?page=2&per_page=2>; rel=\"next\""
+        }
+    },
+    "list_revisions2": {
+        "method": "GET",
+        "endpoint": "courses/1/pages/my-url/revisions?page=2&per_page=2",
+        "data": [
+            {
+                "id": 3,
+                "title": "Revision 3"
+            },
+            {
+                "id": 4,
+                "title": "Revision 4"
+            }
+        ],
+        "status_code": 200
+    },
+    "latest_revision": {
+        "method": "GET",
+        "endpoint": "courses/1/pages/my-url/revisions/latest",
+        "data": {
+            "id": 1,
+            "title": "Latest Revision",
+            "url": "my-url"
+        },
+        "status_code": 200
+    },
+    "get_latest_rev_by_id": {
+        "method": "GET",
+        "endpoint": "courses/1/pages/my-url/revisions/2",
+        "data": {
+            "id": 2,
+            "updated_at": "2012-08-07T11:23:58-06:00",
+            "revision_id": 2,
+            "url": "my-url"
+        },
+        "status_code": 200
+    },
+    "get_latest_rev_by_id_group": {
+        "method": "GET",
+        "endpoint": "groups/1/pages/my-url/revisions/2",
+        "data": {
+            "id": 2,
+            "revision_id": 2,
+            "url": "my-url"
+        },
+        "status_code": 200
+    },
+    "revert_to_revision": {
+        "method": "POST",
+        "endpoint": "courses/1/pages/my-url/revisions/3",
+        "data": {
+            "id": 1,
+            "revision_id": 3,
+            "url": "my-url"
+        },
+        "status_code": 200
+    },
+    "revert_to_revision_group": {
+        "method": "POST",
+        "endpoint": "groups/1/pages/my-url/revisions/3",
+        "data": {
+            "id": 1,
+            "revision_id": 3,
+            "url": "my-url"
+        },
+        "status_code": 200
+    }
+}
diff --git a/tests/test_page.py b/tests/test_page.py
index 01ac1661..e1735cc2 100644
--- a/tests/test_page.py
+++ b/tests/test_page.py
@@ -33,6 +33,7 @@ def test__str__(self, m):
         string = str(self.page_course)
         self.assertIsInstance(string, str)
 
+    # edit()
     def test_edit(self, m):
         register_uris({"page": ["edit"]}, m)
 
@@ -43,14 +44,23 @@ def test_edit(self, m):
         self.assertTrue(hasattr(self.page_course, "title"))
         self.assertEqual(self.page_course.title, new_title)
 
-    def test_delete(self, m):
-        register_uris({"page": ["delete_page"]}, m)
+    # delete()
+    def test_delete_course(self, m):
+        register_uris({"page": ["delete_page_course"]}, m)
 
         page = self.page_course
         deleted_page = page.delete()
 
         self.assertIsInstance(deleted_page, Page)
 
+    def test_delete_group(self, m):
+        register_uris({"page": ["delete_page_group"]}, m)
+
+        page = self.page_group
+        deleted_page = page.delete()
+
+        self.assertIsInstance(deleted_page, Page)
+
     # get_revisions()
     def test_get_revisions(self, m):
         register_uris({"page": ["list_revisions", "list_revisions2"]}, m)