Mercurial > kallithea
annotate rhodecode/tests/functional/test_forks.py @ 1749:8ecc6b8229a5 beta
commit less models
- models don't do any commits(with few exceptions)
- all db transactions should be handled by higher level modules like controllers, celery tasks
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 02 Dec 2011 22:31:13 +0200 |
parents | 8321b3d19b1f |
children | 162bf5c978f8 |
rev | line source |
---|---|
1375
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 from rhodecode.tests import * |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 from rhodecode.model.db import Repository |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 class TestForksController(TestController): |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 def test_index(self): |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 self.log_user() |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 repo_name = HG_REPO |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 response = self.app.get(url(controller='forks', action='forks', |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 repo_name=repo_name)) |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 self.assertTrue("""There are no forks yet""" in response.body) |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 def test_index_with_fork(self): |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 self.log_user() |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 # create a fork |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 fork_name = HG_FORK |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 description = 'fork of vcs test' |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 repo_name = HG_REPO |
1723
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
23 org_repo = Repository.get_by_repo_name(repo_name) |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
24 response = self.app.post(url(controller='forks', |
1375
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 action='fork_create', |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 repo_name=repo_name), |
1723
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
27 {'repo_name':fork_name, |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
28 'repo_group':'', |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
29 'fork_parent_id':org_repo.repo_id, |
1375
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 'repo_type':'hg', |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 'description':description, |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 'private':'False'}) |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 response = self.app.get(url(controller='forks', action='forks', |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 repo_name=repo_name)) |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 self.assertTrue("""<a href="/%s/summary">""" |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 """vcs_test_hg_fork</a>""" % fork_name |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 in response.body) |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 #remove this fork |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 response = self.app.delete(url('repo', repo_name=fork_name)) |
f9559677c953
added tests for forks and followers pages
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 |
1723
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
45 |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
46 |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
47 |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
48 def test_z_fork_create(self): |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
49 self.log_user() |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
50 fork_name = HG_FORK |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
51 description = 'fork of vcs test' |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
52 repo_name = HG_REPO |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
53 org_repo = Repository.get_by_repo_name(repo_name) |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
54 response = self.app.post(url(controller='forks', action='fork_create', |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
55 repo_name=repo_name), |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
56 {'repo_name':fork_name, |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
57 'repo_group':'', |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
58 'fork_parent_id':org_repo.repo_id, |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
59 'repo_type':'hg', |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
60 'description':description, |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
61 'private':'False'}) |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
62 |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
63 #test if we have a message that fork is ok |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
64 self.assertTrue('forked %s repository as %s' \ |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
65 % (repo_name, fork_name) in response.session['flash'][0]) |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
66 |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
67 #test if the fork was created in the database |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1732
diff
changeset
|
68 fork_repo = self.Session.query(Repository)\ |
1723
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
69 .filter(Repository.repo_name == fork_name).one() |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
70 |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
71 self.assertEqual(fork_repo.repo_name, fork_name) |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
72 self.assertEqual(fork_repo.fork.repo_name, repo_name) |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
73 |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
74 |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
75 #test if fork is visible in the list ? |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
76 response = response.follow() |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
77 |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
78 |
1732 | 79 # check if fork is marked as fork |
80 # wait for cache to expire | |
81 import time | |
82 time.sleep(10) | |
1723
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
83 response = self.app.get(url(controller='summary', action='index', |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
84 repo_name=fork_name)) |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
85 |
64e91067b996
- refactoring to overcome poor usage of global pylons config
Marcin Kuzminski <marcin@python-works.com>
parents:
1375
diff
changeset
|
86 self.assertTrue('Fork of %s' % repo_name in response.body) |