[PATCH 2/6] tests: make test suite pass with XML-RPC disabled
Daniel Axtens
dja at axtens.net
Wed Sep 18 16:17:27 AEST 2019
Handy for development purposes.
Signed-off-by: Daniel Axtens <dja at axtens.net>
---
patchwork/tests/test_about.py | 24 ++++++++++++++++++------
patchwork/tests/test_xmlrpc.py | 3 +++
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/patchwork/tests/test_about.py b/patchwork/tests/test_about.py
index 99892cb0539a..d8c35b9f3e5f 100644
--- a/patchwork/tests/test_about.py
+++ b/patchwork/tests/test_about.py
@@ -3,19 +3,31 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
+import unittest
+
+from django.conf import settings
from django.test import TestCase
from django.urls import reverse
class AboutViewTest(TestCase):
- def test_redirects(self):
- for view in ['help', 'help-about', 'help-pwclient']:
- requested_url = reverse(view)
- redirect_url = reverse('about')
+ def _test_redirect(self, view):
+ requested_url = reverse(view)
+ redirect_url = reverse('about')
- response = self.client.get(requested_url)
- self.assertRedirects(response, redirect_url, 301)
+ response = self.client.get(requested_url)
+ self.assertRedirects(response, redirect_url, 301)
+
+ def test_redirects(self):
+ for view in ['help', 'help-about']:
+ self._test_redirect(view)
+
+ @unittest.skipUnless(settings.ENABLE_XMLRPC,
+ 'requires xmlrpc interface (use the ENABLE_XMLRPC '
+ 'setting)')
+ def test_redirects_xmlrpc(self):
+ self._test_redirect('help-pwclient')
def test_xmlrpc(self):
with self.settings(ENABLE_XMLRPC=False):
diff --git a/patchwork/tests/test_xmlrpc.py b/patchwork/tests/test_xmlrpc.py
index 461dfe638fa1..79c6c848a0c2 100644
--- a/patchwork/tests/test_xmlrpc.py
+++ b/patchwork/tests/test_xmlrpc.py
@@ -42,6 +42,9 @@ class XMLRPCGenericTest(XMLRPCTest):
self.rpc.patch_set(0, {})
+ at unittest.skipUnless(settings.ENABLE_XMLRPC,
+ 'requires xmlrpc interface (use the ENABLE_XMLRPC '
+ 'setting)')
class XMLRPCAuthenticatedTest(LiveServerTestCase):
def setUp(self):
--
2.20.1
More information about the Patchwork
mailing list