diff rhodecode/tests/test_hg_operations.py @ 1047:15b60f83420c beta

tests update
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 15 Feb 2011 01:36:50 +0100
parents a9421a8a874f
children 51076a2a2b64
line wrap: on
line diff
--- a/rhodecode/tests/test_hg_operations.py	Tue Feb 15 01:36:35 2011 +0100
+++ b/rhodecode/tests/test_hg_operations.py	Tue Feb 15 01:36:50 2011 +0100
@@ -77,6 +77,8 @@
 
     if force and user is not None:
         print 'removing current user'
+        for repo in sa.query(Repository).filter(Repository.user == user).all():
+            sa.delete(repo)
         sa.delete(user)
         sa.commit()
 
@@ -117,6 +119,19 @@
         rm.base_path = '/home/hg'
         rm.create(form_data, user)
 
+
+def set_anonymous_access(enable=True):
+    sa = get_session()
+    user = sa.query(User).filter(User.username == 'default').one()
+    user.active = enable
+    sa.add(user)
+    sa.commit()
+
+def get_anonymous_access():
+    sa = get_session()
+    return sa.query(User).filter(User.username == 'default').one().active
+
+
 #==============================================================================
 # TESTS
 #==============================================================================
@@ -157,6 +172,12 @@
         raise
 
 
+    print 'checking if anonymous access is enabled'
+    anonymous_access = get_anonymous_access()
+    if not anonymous_access:
+        print 'not enabled, enabling it '
+        set_anonymous_access(enable=True)
+
     clone_url = 'http://%(host)s/%(cloned_repo)s %(dest)s' % \
                   {'user':USER,
                    'pass':PASS,
@@ -166,9 +187,17 @@
 
     stdout, stderr = Command(cwd).execute('hg clone', clone_url)
     print stdout, stderr
+
+
     assert """adding file changes""" in stdout, 'no messages about cloning'
     assert """abort""" not in stderr , 'got error from clone'
 
+    #disable if it was enabled
+    if not anonymous_access:
+        print 'disabling anonymous access'
+        set_anonymous_access(enable=False)
+
+
 def test_clone_wrong_credentials():
     cwd = path = jn(TESTS_TMP_PATH, HG_REPO)
 
@@ -296,7 +325,7 @@
     #test_clone_wrong_credentials()
 
     #test_pull()
-    test_push_new_file(commits=3)
+    test_push_new_file(commits=2)
     #test_push_wrong_path()
     #test_push_wrong_credentials()