Repository: coderedcorp/wagtail-cache (language: python)

Issue:
unit tests are all broken
> (unrelated - unit tests are all broken in main branch due to some pip package change... need to hunt that down).

1. setting.py remove `wagtail.core.middleware.SiteMiddleware`
    > https://docs.wagtail.io/en/v2.8.1/getting_started/integrating_into_django.html
    > Wagtail is currently incompatible with projects using django.contrib.sites.middleware.CurrentSiteMiddleware, as both this and wagtail.core.middleware.SiteMiddleware set the attribute request.site.
2. tests.py(61) change to `cls.page_wagtailpage = WagtailPage.objects.get(slug="home").get_parent().specific`


Now I receive the following issue.

```
FAILED testproject/home/tests.py::WagtailCacheTest::test_page_hit - AssertionError: 'hit' != 'miss'
FAILED testproject/home/tests.py::WagtailCacheTest::test_page_hit_without_auth - AssertionError: 'hit' != 'miss'
FAILED testproject/home/tests.py::WagtailCacheTest::test_page_miss - AssertionError: 'hit' != 'miss'
FAILED testproject/home/tests.py::WagtailCacheTest::test_page_miss_without_auth - AssertionError: 'hit' != 'miss'
FAILED testproject/home/tests.py::WagtailCacheTest::test_page_restricted - TypeError: Cannot encode None for key 'return_url' as POST data. Did you mean to pass an empty string or omit the value?
FAILED testproject/home/tests.py::WagtailCacheTest::test_page_restricted_without_auth - TypeError: Cannot encode None for key 'return_url' as POST data. Did you mean to pass an empty string or omit the value?
FAILED testproject/home/tests.py::WagtailCacheTest::test_page_skip - AssertionError: 'miss' != 'skip'
FAILED testproject/home/tests.py::WagtailCacheTest::test_page_skip_without_auth - AssertionError: 'miss' != 'skip'
FAILED testproject/home/tests.py::WagtailCacheTest::test_request_hook_any - AssertionError: 'hit' != 'miss'
FAILED testproject/home/tests.py::WagtailCacheTest::test_response_hook_any - AssertionError: 'hit' != 'miss'
```

_Originally posted by @klausfuchs in https://github.com/coderedcorp/wagtail-cache/issues/22#issuecomment-741618359_


Discussion / hints:

Fix patch:
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index f3cabb4..1a03b41 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -29,14 +29,14 @@ stages:
       vmImage: 'ubuntu-latest'
     strategy:
       matrix:
-        py3.5:
-          PYTHON_VERSION: '3.5'
         py3.6:
           PYTHON_VERSION: '3.6'
         py3.7:
           PYTHON_VERSION: '3.7'
         py3.8:
           PYTHON_VERSION: '3.8'
+        py3.9:
+          PYTHON_VERSION: '3.9'
 
     steps:
     - task: UsePythonVersion@0
diff --git a/docs/conf.py b/docs/conf.py
index 574d9d7..4cc3e86 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -14,7 +14,6 @@
 # import sys
 # sys.path.insert(0, os.path.abspath('.'))
 
-import os
 import datetime
 from wagtailcache import __shortversion__
 
diff --git a/docs/releases/index.rst b/docs/releases/index.rst
index a4a6b4c..b8e56fa 100644
--- a/docs/releases/index.rst
+++ b/docs/releases/index.rst
@@ -4,6 +4,7 @@ Release Notes
 .. toctree::
     :maxdepth: 1
 
+    v1.0.2
     v1.0.1
     v1.0.0
     v0.5.2
@@ -13,4 +14,4 @@ Release Notes
     v0.3.0
     v0.2.1
     v0.2.0
-    v0.1.0
+    v0.1.0
\ No newline at end of file
diff --git a/docs/releases/v1.0.2.rst b/docs/releases/v1.0.2.rst
new file mode 100644
index 0000000..be8deaf
--- /dev/null
+++ b/docs/releases/v1.0.2.rst
@@ -0,0 +1,11 @@
+1.0.2 release notes
+===================
+
+* Updated ``testproject`` to work with Wagtail 2.10+
+* Removed deprecated ``wagtail.core.middleware.SiteMiddleware`` from the ``testproject``
+
+
+**Additional Notes**: ``SiteMiddleware`` was deprecated in Wagtail v.2.9 because it clashes with 
+Django's own site middleware. If this is left in your project when you upgrade
+your Wagtail versions, it will cause potential failures in this package and may 
+cause errors when running the server.
\ No newline at end of file


Test patch:
diff --git a/testproject/home/migrations/0002_create_homepage.py b/testproject/home/migrations/0002_create_homepage.py
index cbf9d0d..dcf2aad 100644
--- a/testproject/home/migrations/0002_create_homepage.py
+++ b/testproject/home/migrations/0002_create_homepage.py
@@ -15,7 +15,7 @@ def create_homepage(apps, schema_editor):
 
     # Create content type for homepage model
     homepage_content_type, __ = ContentType.objects.get_or_create(
-        model='homepage', app_label='home')
+        model='wagtailpage', app_label='home')
 
     # Create a new homepage
     homepage = WagtailPage.objects.create(
diff --git a/testproject/testproject/settings.py b/testproject/testproject/settings.py
index 5a00d2d..418a925 100644
--- a/testproject/testproject/settings.py
+++ b/testproject/testproject/settings.py
@@ -13,8 +13,7 @@
 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
 import os
 
-PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-BASE_DIR = os.path.dirname(PROJECT_DIR)
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 
 
 # Quick-start development settings - unsuitable for production
@@ -61,7 +60,6 @@
     'django.middleware.clickjacking.XFrameOptionsMiddleware',
     'django.middleware.security.SecurityMiddleware',
 
-    'wagtail.core.middleware.SiteMiddleware',
     'wagtail.contrib.redirects.middleware.RedirectMiddleware',
 
     'wagtailcache.cache.FetchFromCacheMiddleware',
@@ -73,7 +71,7 @@
     {
         'BACKEND': 'django.template.backends.django.DjangoTemplates',
         'DIRS': [
-            os.path.join(PROJECT_DIR, 'templates'),
+            os.path.join(BASE_DIR, 'templates'),
         ],
         'APP_DIRS': True,
         'OPTIONS': {
@@ -123,10 +121,6 @@
     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
 ]
 
-STATICFILES_DIRS = [
-    os.path.join(PROJECT_DIR, 'static'),
-]
-
 STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
 
 STATIC_ROOT = os.path.join(BASE_DIR, 'static')