diff mbox

[01/25] tests: Remove 'find_in_context'

Message ID 1466718826-15770-2-git-send-email-stephen.finucane@intel.com
State Accepted
Headers show

Commit Message

Stephen Finucane June 23, 2016, 9:53 p.m. UTC
The aformentioned function handled both dicts and lists in a request's
context field. Seeing as only dicts are ever returned, this is not
necessary.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
---
 patchwork/tests/test_bundles.py |   21 +++++++++++----------
 patchwork/tests/utils.py        |   12 ------------
 2 files changed, 11 insertions(+), 22 deletions(-)

Comments

Andy Doan June 29, 2016, 5:08 p.m. UTC | #1
On 06/23/2016 04:53 PM, Stephen Finucane wrote:
> The aformentioned function handled both dicts and lists in a request's
> context field. Seeing as only dicts are ever returned, this is not
> necessary.
>
> Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>

Reviewed-by: Andy Doan <andy.doan@linaro.org>
diff mbox

Patch

diff --git a/patchwork/tests/test_bundles.py b/patchwork/tests/test_bundles.py
index cbed216..e822fbe 100644
--- a/patchwork/tests/test_bundles.py
+++ b/patchwork/tests/test_bundles.py
@@ -25,11 +25,14 @@  import unittest
 from django.conf import settings
 from django.test import TestCase
 from django.utils.http import urlencode
-from django.utils.six.moves import range, zip
+from django.utils.six.moves import range
+from django.utils.six.moves import zip
 
-from patchwork.models import Bundle, BundlePatch
-from patchwork.tests.utils import (defaults, create_user, find_in_context,
-                                   create_patches)
+from patchwork.models import Bundle
+from patchwork.models import BundlePatch
+from patchwork.tests.utils import create_patches
+from patchwork.tests.utils import create_user
+from patchwork.tests.utils import defaults
 
 
 def bundle_url(bundle):
@@ -46,8 +49,7 @@  class BundleListTest(TestCase):
     def testNoBundles(self):
         response = self.client.get('/user/bundles/')
         self.assertEqual(response.status_code, 200)
-        self.assertEqual(
-            len(find_in_context(response.context, 'bundles')), 0)
+        self.assertEqual(len(response.context['bundles']), 0)
 
     def testSingleBundle(self):
         defaults.project.save()
@@ -55,8 +57,7 @@  class BundleListTest(TestCase):
         bundle.save()
         response = self.client.get('/user/bundles/')
         self.assertEqual(response.status_code, 200)
-        self.assertEqual(
-            len(find_in_context(response.context, 'bundles')), 1)
+        self.assertEqual(len(response.context['bundles']), 1)
 
     def tearDown(self):
         self.user.delete()
@@ -87,7 +88,7 @@  class BundleViewTest(BundleTestBase):
     def testEmptyBundle(self):
         response = self.client.get(bundle_url(self.bundle))
         self.assertEqual(response.status_code, 200)
-        page = find_in_context(response.context, 'page')
+        page = response.context['page']
         self.assertEqual(len(page.object_list), 0)
 
     def testNonEmptyBundle(self):
@@ -95,7 +96,7 @@  class BundleViewTest(BundleTestBase):
 
         response = self.client.get(bundle_url(self.bundle))
         self.assertEqual(response.status_code, 200)
-        page = find_in_context(response.context, 'page')
+        page = response.context['page']
         self.assertEqual(len(page.object_list), 1)
 
     def testBundleOrder(self):
diff --git a/patchwork/tests/utils.py b/patchwork/tests/utils.py
index 2608782..37478b6 100644
--- a/patchwork/tests/utils.py
+++ b/patchwork/tests/utils.py
@@ -126,18 +126,6 @@  def create_covers(count=1):
     return covers
 
 
-def find_in_context(context, key):
-    if isinstance(context, list):
-        for c in context:
-            v = find_in_context(c, key)
-            if v is not None:
-                return v
-    else:
-        if key in context:
-            return context[key]
-    return None
-
-
 def read_patch(filename, encoding=None):
     file_path = os.path.join(_test_patch_dir, filename)
     if encoding is not None: