annotate rhodecode/tests/models/test_repos.py @ 3893:7e9776f38c55 beta

fixed duplicated test in diff tests
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 22 May 2013 22:35:39 +0200
parents 5067d6e826a5
children 7e5f8c12a3fc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3642
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 from rhodecode.tests import *
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3 from rhodecode.model.meta import Session
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 from rhodecode.tests.fixture import Fixture
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5 from rhodecode.model.repo import RepoModel
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 from rhodecode.model.db import Repository
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 from rhodecode.lib.exceptions import AttachedForksError
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 fixture = Fixture()
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11
3829
5067d6e826a5 created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents: 3642
diff changeset
12 class TestRepos(BaseTestCase):
3642
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 def setUp(self):
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15 pass
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
17 def tearDown(self):
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
18 Session.remove()
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
19
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
20 def test_remove_repo(self):
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
21 repo = fixture.create_repo(name='test-repo-1')
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
22 Session().commit()
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
23
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
24 RepoModel().delete(repo=repo)
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
25 Session().commit()
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27 self.assertEqual(None, Repository.get_by_repo_name(repo_name='test-repo-1'))
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29 def test_remove_repo_repo_raises_exc_when_attached_forks(self):
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 repo = fixture.create_repo(name='test-repo-1')
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31 Session().commit()
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
33 fixture.create_fork(repo.repo_name, 'test-repo-fork-1')
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34 Session().commit()
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
35
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
36 self.assertRaises(AttachedForksError, lambda: RepoModel().delete(repo=repo))
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
37
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38 def test_remove_repo_delete_forks(self):
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39 repo = fixture.create_repo(name='test-repo-1')
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40 Session().commit()
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
41
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
42 fork = fixture.create_fork(repo.repo_name, 'test-repo-fork-1')
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43 Session().commit()
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45 #fork of fork
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46 fixture.create_fork(fork.repo_name, 'test-repo-fork-fork-1')
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47 Session().commit()
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 RepoModel().delete(repo=repo, forks='delete')
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 Session().commit()
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52 self.assertEqual(None, Repository.get_by_repo_name(repo_name='test-repo-1'))
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53 self.assertEqual(None, Repository.get_by_repo_name(repo_name='test-repo-fork-1'))
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54 self.assertEqual(None, Repository.get_by_repo_name(repo_name='test-repo-fork-fork-1'))
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
55
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56 def test_remove_repo_detach_forks(self):
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57 repo = fixture.create_repo(name='test-repo-1')
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58 Session().commit()
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
59
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
60 fork = fixture.create_fork(repo.repo_name, 'test-repo-fork-1')
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
61 Session().commit()
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
62
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
63 #fork of fork
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
64 fixture.create_fork(fork.repo_name, 'test-repo-fork-fork-1')
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
65 Session().commit()
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
66
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
67 RepoModel().delete(repo=repo, forks='detach')
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68 Session().commit()
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
69
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
70 try:
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
71 self.assertEqual(None, Repository.get_by_repo_name(repo_name='test-repo-1'))
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
72 self.assertNotEqual(None, Repository.get_by_repo_name(repo_name='test-repo-fork-1'))
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
73 self.assertNotEqual(None, Repository.get_by_repo_name(repo_name='test-repo-fork-fork-1'))
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
74 finally:
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
75 RepoModel().delete(repo='test-repo-fork-fork-1')
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
76 RepoModel().delete(repo='test-repo-fork-1')
749dfd6b6e95 added new fixture classes
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
77 Session().commit()