Commits

Olemis Lang committed af28c32

BH Multiproduct #387 : Support anonymous access in as_user context manager

Comments (0)

Files changed (1)

t387/t387_r1526822_functional_test.8.diff

 # HG changeset patch
-# Parent fc1aec50ea88423068999f6371a2ebc9d7c5393d
+# Parent 52a8c6115edd49a2370aeeaf877efd626424939f
 BH Multiproduct #387 : Extend functional testers API with 'as_user' context manager
 
-diff -r fc1aec50ea88 bloodhound_multiproduct/tests/functional/__init__.py
---- a/bloodhound_multiproduct/tests/functional/__init__.py	Tue Oct 01 19:07:17 2013 -0500
-+++ b/bloodhound_multiproduct/tests/functional/__init__.py	Tue Oct 01 19:29:45 2013 -0500
-@@ -717,6 +717,29 @@
+diff -r 52a8c6115edd bloodhound_multiproduct/tests/functional/__init__.py
+--- a/bloodhound_multiproduct/tests/functional/__init__.py	Tue Oct 01 21:24:09 2013 -0500
++++ b/bloodhound_multiproduct/tests/functional/__init__.py	Tue Oct 01 21:27:40 2013 -0500
+@@ -717,6 +717,30 @@
          tc.follow('Tickets')
          tc.url(self.url + '/dashboard')
  
 +        as user and restore login afterwards (by default to admin)
 +        """
 +        @contextlib.contextmanager
-+        def login_ctx():
++        def user_ctx():
 +            try:
 +                try:
 +                    self.logout()
 +                except:
 +                    pass
-+                self.login(user)
++                if user:
++                    self.login(user)
 +                yield self
 +            finally:
 +                try:
 +                if restore:
 +                    self.login(restore)
 +
-+        return login_ctx
++        return user_ctx()
 +
  
  class BloodhoundGlobalEnvFunctionalTester(BloodhoundFunctionalTester):