##// END OF EJS Templates
added tests if push set cache invalidation state
marcink -
r3617:b5c3680e beta
parent child Browse files
Show More
@@ -38,7 +38,8 b' from tempfile import _RandomNameSequence'
38 from subprocess import Popen, PIPE
38 from subprocess import Popen, PIPE
39
39
40 from rhodecode.tests import *
40 from rhodecode.tests import *
41 from rhodecode.model.db import User, Repository, UserLog, UserIpMap
41 from rhodecode.model.db import User, Repository, UserLog, UserIpMap,\
42 CacheInvalidation
42 from rhodecode.model.meta import Session
43 from rhodecode.model.meta import Session
43 from rhodecode.model.repo import RepoModel
44 from rhodecode.model.repo import RepoModel
44 from rhodecode.model.user import UserModel
45 from rhodecode.model.user import UserModel
@@ -105,7 +106,7 b' def _add_files_and_push(vcs, DEST, **kwa'
105 Command(cwd).execute('touch %s' % added_file)
106 Command(cwd).execute('touch %s' % added_file)
106 Command(cwd).execute('%s add %s' % (vcs, added_file))
107 Command(cwd).execute('%s add %s' % (vcs, added_file))
107
108
108 for i in xrange(3):
109 for i in xrange(kwargs.get('files_no', 3)):
109 cmd = """echo 'added_line%s' >> %s""" % (i, added_file)
110 cmd = """echo 'added_line%s' >> %s""" % (i, added_file)
110 Command(cwd).execute(cmd)
111 Command(cwd).execute(cmd)
111 author_str = 'Marcin KuΕΊminski <me@email.com>'
112 author_str = 'Marcin KuΕΊminski <me@email.com>'
@@ -240,6 +241,40 b' class TestVCSOperations(unittest.TestCas'
240 #WTF git stderr ?!
241 #WTF git stderr ?!
241 assert 'master -> master' in stderr
242 assert 'master -> master' in stderr
242
243
244 def test_push_invalidates_cache_hg(self):
245 key = CacheInvalidation.query().filter(CacheInvalidation.cache_key
246 ==HG_REPO).one()
247 key.cache_active = True
248 Session().add(key)
249 Session().commit()
250
251 DEST = _get_tmp_dir()
252 clone_url = _construct_url(HG_REPO, dest=DEST)
253 stdout, stderr = Command('/tmp').execute('hg clone', clone_url)
254
255 stdout, stderr = _add_files_and_push('hg', DEST, files_no=1)
256 key = CacheInvalidation.query().filter(CacheInvalidation.cache_key
257 ==HG_REPO).one()
258 self.assertEqual(key.cache_active, False)
259
260 def test_push_invalidates_cache_git(self):
261 key = CacheInvalidation.query().filter(CacheInvalidation.cache_key
262 ==GIT_REPO).one()
263 key.cache_active = True
264 Session().add(key)
265 Session().commit()
266
267 DEST = _get_tmp_dir()
268 clone_url = _construct_url(GIT_REPO, dest=DEST)
269 stdout, stderr = Command('/tmp').execute('git clone', clone_url)
270
271 # commit some stuff into this repo
272 stdout, stderr = _add_files_and_push('git', DEST, files_no=1)
273
274 key = CacheInvalidation.query().filter(CacheInvalidation.cache_key
275 ==GIT_REPO).one()
276 self.assertEqual(key.cache_active, False)
277
243 def test_push_wrong_credentials_hg(self):
278 def test_push_wrong_credentials_hg(self):
244 DEST = _get_tmp_dir()
279 DEST = _get_tmp_dir()
245 clone_url = _construct_url(HG_REPO, dest=DEST)
280 clone_url = _construct_url(HG_REPO, dest=DEST)
General Comments 0
You need to be logged in to leave comments. Login now