Commits

Anonymous committed 800ce51

do not depend on repoze.who tests at all

Comments (0)

Files changed (2)

repoze/who/plugins/test_formcookie.py

 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 import random
+import unittest
 
 from webob import Request, Response
 from webtest import TestApp
-from repoze.who.tests import Base, DummyIdentifier
 
 
-def app(environ, start_response):
-    """MockApp for testing"""
-    req = Request(environ)
-    res = Response()
-    res.body = 'Just a holder'
-    res.content_type = 'text/plain'
-    req.environ['paste.testing_variables']['req'] = req
-    req.environ['paste.testing_variables']['response'] = res
-    return res(environ, start_response)
-
-class DummyLogger(object):
-
-    def __init__(self):
-        self.messages = []
-
-    def debug(self, msg):
-        self.messages.append(msg)
-
-class DummyCookieIdentifier(DummyIdentifier):
-
-    def remember(self, environ, identity):
-        return [('one','two'),('three','four')]
-
-class FixtureBase(Base):
+class FixtureBase(unittest.TestCase):
     def setUp(self):
         self.plugin = self._make_one()
         self.app = TestApp(app, extra_environ={
                 'password':'password'})},
         })
 
+    def _makeEnviron(self, kw=None):
+        environ = {}
+        environ['wsgi.version'] = (1,0)
+        if kw is not None:
+            environ.update(kw)
+        return environ
+
+
 class TestCookieRedirectingFormPlugin(FixtureBase):
     def _getTargetClass(self):
         from repoze.who.plugins.formcookie import CookieRedirectingFormPlugin
         self.failUnless('performing logout' in environ['repoze.who.logger'].messages)
         self.assertEqual(environ['repoze.who.application'].code, 401)
         self.assertEqual(environ['came_from'], '/out/')
+
+class DummyIdentifier:
+    forgotten = False
+    remembered = False
+
+    def __init__(self, credentials=None, remember_headers=None,
+                 forget_headers=None, replace_app=None):
+        self.credentials = credentials
+        self.remember_headers = remember_headers
+        self.forget_headers = forget_headers
+        self.replace_app = replace_app
+
+    def identify(self, environ):
+        if self.replace_app:
+            environ['repoze.who.application'] = self.replace_app
+        return self.credentials
+
+    def forget(self, environ, identity):
+        self.forgotten = identity
+        return self.forget_headers
+
+    def remember(self, environ, identity):
+        self.remembered = identity
+        return self.remember_headers
+
+
+def app(environ, start_response):
+    """MockApp for testing"""
+    req = Request(environ)
+    res = Response()
+    res.body = 'Just a holder'
+    res.content_type = 'text/plain'
+    req.environ['paste.testing_variables']['req'] = req
+    req.environ['paste.testing_variables']['response'] = res
+    return res(environ, start_response)
+
+class DummyLogger(object):
+
+    def __init__(self):
+        self.messages = []
+
+    def debug(self, msg):
+        self.messages.append(msg)
+
+class DummyCookieIdentifier(DummyIdentifier):
+
+    def remember(self, environ, identity):
+        return [('one','two'),('three','four')]
       zip_safe=False,
       install_requires=[
         'setuptools',
-        'repoze.who<2.0a1',
+        'repoze.who',
         'Paste',
       ],
       entry_points="""