Show More
@@ -1,50 +1,65 b'' | |||||
1 | """ |
|
1 | """ | |
2 | Unit tests for vcs_ library. |
|
2 | Unit tests for vcs_ library. | |
3 |
|
3 | |||
4 | In order to run tests we need to prepare our environment first. Tests would be |
|
4 | In order to run tests we need to prepare our environment first. Tests would be | |
5 | run for each engine listed at ``conf.SCM_TESTS`` - keys are aliases from |
|
5 | run for each engine listed at ``conf.SCM_TESTS`` - keys are aliases from | |
6 | ``vcs.backends.BACKENDS``. |
|
6 | ``vcs.backends.BACKENDS``. | |
7 |
|
7 | |||
8 | For each SCM we run tests for, we need some repository. We would use |
|
8 | For each SCM we run tests for, we need some repository. We would use | |
9 | repositories location from system environment variables or test suite defaults |
|
9 | repositories location from system environment variables or test suite defaults | |
10 | - see ``conf`` module for more detail. We simply try to check if repository at |
|
10 | - see ``conf`` module for more detail. We simply try to check if repository at | |
11 | certain location exists, if not we would try to fetch them. At ``test_vcs`` or |
|
11 | certain location exists, if not we would try to fetch them. At ``test_vcs`` or | |
12 | ``test_common`` we run unit tests common for each repository type and for |
|
12 | ``test_common`` we run unit tests common for each repository type and for | |
13 | example specific mercurial tests are located at ``test_hg`` module. |
|
13 | example specific mercurial tests are located at ``test_hg`` module. | |
14 |
|
14 | |||
15 | Oh, and tests are run with ``unittest.collector`` wrapped by ``collector`` |
|
15 | Oh, and tests are run with ``unittest.collector`` wrapped by ``collector`` | |
16 | function at ``tests/__init__.py``. |
|
16 | function at ``tests/__init__.py``. | |
17 |
|
17 | |||
18 | .. _vcs: http://bitbucket.org/marcinkuzminski/vcs |
|
18 | .. _vcs: http://bitbucket.org/marcinkuzminski/vcs | |
19 | .. _unittest: http://pypi.python.org/pypi/unittest |
|
19 | .. _unittest: http://pypi.python.org/pypi/unittest | |
20 |
|
20 | |||
21 | """ |
|
21 | """ | |
|
22 | ||||
|
23 | import os | |||
|
24 | import shutil | |||
|
25 | ||||
22 | from kallithea.tests.base import TEST_HG_REPO, HG_REMOTE_REPO, TEST_GIT_REPO, GIT_REMOTE_REPO |
|
26 | from kallithea.tests.base import TEST_HG_REPO, HG_REMOTE_REPO, TEST_GIT_REPO, GIT_REMOTE_REPO | |
23 | from kallithea.tests.vcs.utils import SCMFetcher |
|
27 | from kallithea.tests.vcs.utils import SCMFetcher | |
24 |
|
28 | |||
25 | from kallithea.tests.base import * |
|
29 | from kallithea.tests.base import * | |
26 |
|
30 | |||
27 |
|
31 | |||
|
32 | # Base directory for the VCS tests. | |||
|
33 | VCS_TEST_MODULE_BASE_DIR = os.path.abspath(os.path.dirname(__file__)) | |||
|
34 | ||||
|
35 | # Path to user configuration file used during tests. | |||
|
36 | TEST_USER_CONFIG_FILE = os.path.join(TESTS_TMP_PATH, 'aconfig') | |||
|
37 | ||||
|
38 | ||||
28 | def setup_package(): |
|
39 | def setup_package(): | |
29 | """ |
|
40 | """ | |
30 | Prepares whole package for tests which mainly means it would try to fetch |
|
41 | Prepares whole package for tests which mainly means it would try to fetch | |
31 | test repositories or use already existing ones. |
|
42 | test repositories or use already existing ones. | |
32 | """ |
|
43 | """ | |
33 | fetchers = { |
|
44 | fetchers = { | |
34 | 'hg': { |
|
45 | 'hg': { | |
35 | 'alias': 'hg', |
|
46 | 'alias': 'hg', | |
36 | 'test_repo_path': TEST_HG_REPO, |
|
47 | 'test_repo_path': TEST_HG_REPO, | |
37 | 'remote_repo': HG_REMOTE_REPO, |
|
48 | 'remote_repo': HG_REMOTE_REPO, | |
38 | 'clone_cmd': 'hg clone --insecure', |
|
49 | 'clone_cmd': 'hg clone --insecure', | |
39 | }, |
|
50 | }, | |
40 | 'git': { |
|
51 | 'git': { | |
41 | 'alias': 'git', |
|
52 | 'alias': 'git', | |
42 | 'test_repo_path': TEST_GIT_REPO, |
|
53 | 'test_repo_path': TEST_GIT_REPO, | |
43 | 'remote_repo': GIT_REMOTE_REPO, |
|
54 | 'remote_repo': GIT_REMOTE_REPO, | |
44 | 'clone_cmd': 'git clone --bare', |
|
55 | 'clone_cmd': 'git clone --bare', | |
45 | }, |
|
56 | }, | |
46 | } |
|
57 | } | |
47 |
|
58 | |||
48 | for scm, fetcher_info in fetchers.items(): |
|
59 | for scm, fetcher_info in fetchers.items(): | |
49 | fetcher = SCMFetcher(**fetcher_info) |
|
60 | fetcher = SCMFetcher(**fetcher_info) | |
50 | fetcher.setup() |
|
61 | fetcher.setup() | |
|
62 | ||||
|
63 | # Copy the test user configuration file to location where | |||
|
64 | # temporary test data is stored at. | |||
|
65 | shutil.copy(os.path.join(VCS_TEST_MODULE_BASE_DIR, 'aconfig'), TEST_USER_CONFIG_FILE) |
@@ -1,66 +1,60 b'' | |||||
1 | """ |
|
1 | """ | |
2 | Unit tests configuration module for vcs. |
|
2 | Unit tests configuration module for vcs. | |
3 | """ |
|
3 | """ | |
4 | import os |
|
4 | import os | |
5 | import shutil |
|
|||
6 | import uuid |
|
5 | import uuid | |
7 |
|
6 | |||
8 | # Retrieve the necessary configuration options from the test base |
|
7 | # Retrieve the necessary configuration options from the test base | |
9 | # module. Some of these configuration options are subsequently |
|
8 | # module. Some of these configuration options are subsequently | |
10 | # consumed by the VCS test module. |
|
9 | # consumed by the VCS test module. | |
11 | from kallithea.tests.base import ( |
|
10 | from kallithea.tests.base import ( | |
12 | TESTS_TMP_PATH, SCM_TESTS, |
|
11 | TESTS_TMP_PATH, SCM_TESTS, | |
13 | TEST_HG_REPO, HG_REMOTE_REPO, |
|
12 | TEST_HG_REPO, HG_REMOTE_REPO, | |
14 | TEST_GIT_REPO, GIT_REMOTE_REPO, |
|
13 | TEST_GIT_REPO, GIT_REMOTE_REPO, | |
15 | ) |
|
14 | ) | |
16 |
|
15 | |||
17 | __all__ = ( |
|
16 | __all__ = ( | |
18 | 'TEST_HG_REPO', 'TEST_GIT_REPO', 'HG_REMOTE_REPO', 'GIT_REMOTE_REPO', |
|
17 | 'TEST_HG_REPO', 'TEST_GIT_REPO', 'HG_REMOTE_REPO', 'GIT_REMOTE_REPO', | |
19 | 'SCM_TESTS', |
|
18 | 'SCM_TESTS', | |
20 | ) |
|
19 | ) | |
21 |
|
20 | |||
22 | THIS = os.path.abspath(os.path.dirname(__file__)) |
|
|||
23 |
|
21 | |||
24 | def get_new_dir(title=None): |
|
22 | def get_new_dir(title=None): | |
25 | """ |
|
23 | """ | |
26 | Calculates a path for a new, non-existant, unique sub-directory in TESTS_TMP_PATH. |
|
24 | Calculates a path for a new, non-existant, unique sub-directory in TESTS_TMP_PATH. | |
27 |
|
25 | |||
28 | Resulting directory name will have format: |
|
26 | Resulting directory name will have format: | |
29 |
|
27 | |||
30 | vcs-test-[title-]hexuuid |
|
28 | vcs-test-[title-]hexuuid | |
31 |
|
29 | |||
32 | The "hexuuid" is a hexadecimal value of a randomly generated |
|
30 | The "hexuuid" is a hexadecimal value of a randomly generated | |
33 | UUID. Title will be added if specified. |
|
31 | UUID. Title will be added if specified. | |
34 |
|
32 | |||
35 | Args: |
|
33 | Args: | |
36 | title: Custom title to include as part of the resulting sub-directory |
|
34 | title: Custom title to include as part of the resulting sub-directory | |
37 | name. Can be useful for debugging to identify destination. Defaults |
|
35 | name. Can be useful for debugging to identify destination. Defaults | |
38 | to None. |
|
36 | to None. | |
39 |
|
37 | |||
40 | Returns: |
|
38 | Returns: | |
41 | Path to the new directory as a string. |
|
39 | Path to the new directory as a string. | |
42 | """ |
|
40 | """ | |
43 |
|
41 | |||
44 | test_repo_prefix = 'vcs-test' |
|
42 | test_repo_prefix = 'vcs-test' | |
45 |
|
43 | |||
46 | if title: |
|
44 | if title: | |
47 | name = "%s-%s" % (test_repo_prefix, title) |
|
45 | name = "%s-%s" % (test_repo_prefix, title) | |
48 | else: |
|
46 | else: | |
49 | name = test_repo_prefix |
|
47 | name = test_repo_prefix | |
50 |
|
48 | |||
51 | path = os.path.join(TESTS_TMP_PATH, name) |
|
49 | path = os.path.join(TESTS_TMP_PATH, name) | |
52 |
|
50 | |||
53 | # Generate new hexes until we get a unique name (just in case). |
|
51 | # Generate new hexes until we get a unique name (just in case). | |
54 | hex_uuid = uuid.uuid4().hex |
|
52 | hex_uuid = uuid.uuid4().hex | |
55 | while os.path.exists("%s-%s" % (path, hex_uuid)): |
|
53 | while os.path.exists("%s-%s" % (path, hex_uuid)): | |
56 | hex_uuid = uuid.uuid4().hex |
|
54 | hex_uuid = uuid.uuid4().hex | |
57 |
|
55 | |||
58 | return "%s-%s" % (path, hex_uuid) |
|
56 | return "%s-%s" % (path, hex_uuid) | |
59 |
|
57 | |||
60 |
|
58 | |||
61 | _dest = os.path.join(TESTS_TMP_PATH, 'aconfig') |
|
|||
62 | shutil.copy(os.path.join(THIS, 'aconfig'), _dest) |
|
|||
63 | TEST_USER_CONFIG_FILE = _dest |
|
|||
64 |
|
||||
65 | # overide default configurations with kallithea ones |
|
59 | # overide default configurations with kallithea ones | |
66 | from kallithea.tests.base import * |
|
60 | from kallithea.tests.base import * |
@@ -1,225 +1,225 b'' | |||||
1 | import datetime |
|
1 | import datetime | |
2 | from kallithea.tests.vcs.base import _BackendTestMixin |
|
2 | from kallithea.tests.vcs.base import _BackendTestMixin | |
3 | from kallithea.tests.vcs.conf import SCM_TESTS |
|
3 | from kallithea.tests.vcs.conf import SCM_TESTS | |
4 |
from kallithea.tests.vcs |
|
4 | from kallithea.tests.vcs import TEST_USER_CONFIG_FILE | |
5 | from kallithea.lib.vcs.nodes import FileNode |
|
5 | from kallithea.lib.vcs.nodes import FileNode | |
6 | from kallithea.lib.vcs.utils.compat import unittest |
|
6 | from kallithea.lib.vcs.utils.compat import unittest | |
7 | from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError |
|
7 | from kallithea.lib.vcs.exceptions import ChangesetDoesNotExistError | |
8 |
|
8 | |||
9 |
|
9 | |||
10 | class RepositoryBaseTest(_BackendTestMixin): |
|
10 | class RepositoryBaseTest(_BackendTestMixin): | |
11 | recreate_repo_per_test = False |
|
11 | recreate_repo_per_test = False | |
12 |
|
12 | |||
13 | @classmethod |
|
13 | @classmethod | |
14 | def _get_commits(cls): |
|
14 | def _get_commits(cls): | |
15 | return super(RepositoryBaseTest, cls)._get_commits()[:1] |
|
15 | return super(RepositoryBaseTest, cls)._get_commits()[:1] | |
16 |
|
16 | |||
17 | def test_get_config_value(self): |
|
17 | def test_get_config_value(self): | |
18 | self.assertEqual(self.repo.get_config_value('universal', 'foo', |
|
18 | self.assertEqual(self.repo.get_config_value('universal', 'foo', | |
19 | TEST_USER_CONFIG_FILE), 'bar') |
|
19 | TEST_USER_CONFIG_FILE), 'bar') | |
20 |
|
20 | |||
21 | def test_get_config_value_defaults_to_None(self): |
|
21 | def test_get_config_value_defaults_to_None(self): | |
22 | self.assertEqual(self.repo.get_config_value('universal', 'nonexist', |
|
22 | self.assertEqual(self.repo.get_config_value('universal', 'nonexist', | |
23 | TEST_USER_CONFIG_FILE), None) |
|
23 | TEST_USER_CONFIG_FILE), None) | |
24 |
|
24 | |||
25 | def test_get_user_name(self): |
|
25 | def test_get_user_name(self): | |
26 | self.assertEqual(self.repo.get_user_name(TEST_USER_CONFIG_FILE), |
|
26 | self.assertEqual(self.repo.get_user_name(TEST_USER_CONFIG_FILE), | |
27 | 'Foo Bar') |
|
27 | 'Foo Bar') | |
28 |
|
28 | |||
29 | def test_get_user_email(self): |
|
29 | def test_get_user_email(self): | |
30 | self.assertEqual(self.repo.get_user_email(TEST_USER_CONFIG_FILE), |
|
30 | self.assertEqual(self.repo.get_user_email(TEST_USER_CONFIG_FILE), | |
31 | 'foo.bar@example.com') |
|
31 | 'foo.bar@example.com') | |
32 |
|
32 | |||
33 | def test_repo_equality(self): |
|
33 | def test_repo_equality(self): | |
34 | self.assertTrue(self.repo == self.repo) |
|
34 | self.assertTrue(self.repo == self.repo) | |
35 |
|
35 | |||
36 | def test_repo_equality_broken_object(self): |
|
36 | def test_repo_equality_broken_object(self): | |
37 | import copy |
|
37 | import copy | |
38 | _repo = copy.copy(self.repo) |
|
38 | _repo = copy.copy(self.repo) | |
39 | delattr(_repo, 'path') |
|
39 | delattr(_repo, 'path') | |
40 | self.assertTrue(self.repo != _repo) |
|
40 | self.assertTrue(self.repo != _repo) | |
41 |
|
41 | |||
42 | def test_repo_equality_other_object(self): |
|
42 | def test_repo_equality_other_object(self): | |
43 | class dummy(object): |
|
43 | class dummy(object): | |
44 | path = self.repo.path |
|
44 | path = self.repo.path | |
45 | self.assertTrue(self.repo != dummy()) |
|
45 | self.assertTrue(self.repo != dummy()) | |
46 |
|
46 | |||
47 |
|
47 | |||
48 | class RepositoryGetDiffTest(_BackendTestMixin): |
|
48 | class RepositoryGetDiffTest(_BackendTestMixin): | |
49 |
|
49 | |||
50 | @classmethod |
|
50 | @classmethod | |
51 | def _get_commits(cls): |
|
51 | def _get_commits(cls): | |
52 | commits = [ |
|
52 | commits = [ | |
53 | { |
|
53 | { | |
54 | 'message': 'Initial commit', |
|
54 | 'message': 'Initial commit', | |
55 | 'author': 'Joe Doe <joe.doe@example.com>', |
|
55 | 'author': 'Joe Doe <joe.doe@example.com>', | |
56 | 'date': datetime.datetime(2010, 1, 1, 20), |
|
56 | 'date': datetime.datetime(2010, 1, 1, 20), | |
57 | 'added': [ |
|
57 | 'added': [ | |
58 | FileNode('foobar', content='foobar'), |
|
58 | FileNode('foobar', content='foobar'), | |
59 | FileNode('foobar2', content='foobar2'), |
|
59 | FileNode('foobar2', content='foobar2'), | |
60 | ], |
|
60 | ], | |
61 | }, |
|
61 | }, | |
62 | { |
|
62 | { | |
63 | 'message': 'Changed foobar, added foobar3', |
|
63 | 'message': 'Changed foobar, added foobar3', | |
64 | 'author': 'Jane Doe <jane.doe@example.com>', |
|
64 | 'author': 'Jane Doe <jane.doe@example.com>', | |
65 | 'date': datetime.datetime(2010, 1, 1, 21), |
|
65 | 'date': datetime.datetime(2010, 1, 1, 21), | |
66 | 'added': [ |
|
66 | 'added': [ | |
67 | FileNode('foobar3', content='foobar3'), |
|
67 | FileNode('foobar3', content='foobar3'), | |
68 | ], |
|
68 | ], | |
69 | 'changed': [ |
|
69 | 'changed': [ | |
70 | FileNode('foobar', 'FOOBAR'), |
|
70 | FileNode('foobar', 'FOOBAR'), | |
71 | ], |
|
71 | ], | |
72 | }, |
|
72 | }, | |
73 | { |
|
73 | { | |
74 | 'message': 'Removed foobar, changed foobar3', |
|
74 | 'message': 'Removed foobar, changed foobar3', | |
75 | 'author': 'Jane Doe <jane.doe@example.com>', |
|
75 | 'author': 'Jane Doe <jane.doe@example.com>', | |
76 | 'date': datetime.datetime(2010, 1, 1, 22), |
|
76 | 'date': datetime.datetime(2010, 1, 1, 22), | |
77 | 'changed': [ |
|
77 | 'changed': [ | |
78 | FileNode('foobar3', content='FOOBAR\nFOOBAR\nFOOBAR\n'), |
|
78 | FileNode('foobar3', content='FOOBAR\nFOOBAR\nFOOBAR\n'), | |
79 | ], |
|
79 | ], | |
80 | 'removed': [FileNode('foobar')], |
|
80 | 'removed': [FileNode('foobar')], | |
81 | }, |
|
81 | }, | |
82 | ] |
|
82 | ] | |
83 | return commits |
|
83 | return commits | |
84 |
|
84 | |||
85 | def test_raise_for_wrong(self): |
|
85 | def test_raise_for_wrong(self): | |
86 | with self.assertRaises(ChangesetDoesNotExistError): |
|
86 | with self.assertRaises(ChangesetDoesNotExistError): | |
87 | self.repo.get_diff('a' * 40, 'b' * 40) |
|
87 | self.repo.get_diff('a' * 40, 'b' * 40) | |
88 |
|
88 | |||
89 |
|
89 | |||
90 | class GitRepositoryGetDiffTest(RepositoryGetDiffTest, unittest.TestCase): |
|
90 | class GitRepositoryGetDiffTest(RepositoryGetDiffTest, unittest.TestCase): | |
91 | backend_alias = 'git' |
|
91 | backend_alias = 'git' | |
92 |
|
92 | |||
93 | def test_initial_commit_diff(self): |
|
93 | def test_initial_commit_diff(self): | |
94 | initial_rev = self.repo.revisions[0] |
|
94 | initial_rev = self.repo.revisions[0] | |
95 | self.assertEqual(self.repo.get_diff(self.repo.EMPTY_CHANGESET, initial_rev), '''diff --git a/foobar b/foobar |
|
95 | self.assertEqual(self.repo.get_diff(self.repo.EMPTY_CHANGESET, initial_rev), '''diff --git a/foobar b/foobar | |
96 | new file mode 100644 |
|
96 | new file mode 100644 | |
97 | index 0000000000000000000000000000000000000000..f6ea0495187600e7b2288c8ac19c5886383a4632 |
|
97 | index 0000000000000000000000000000000000000000..f6ea0495187600e7b2288c8ac19c5886383a4632 | |
98 | --- /dev/null |
|
98 | --- /dev/null | |
99 | +++ b/foobar |
|
99 | +++ b/foobar | |
100 | @@ -0,0 +1 @@ |
|
100 | @@ -0,0 +1 @@ | |
101 | +foobar |
|
101 | +foobar | |
102 | \ No newline at end of file |
|
102 | \ No newline at end of file | |
103 | diff --git a/foobar2 b/foobar2 |
|
103 | diff --git a/foobar2 b/foobar2 | |
104 | new file mode 100644 |
|
104 | new file mode 100644 | |
105 | index 0000000000000000000000000000000000000000..e8c9d6b98e3dce993a464935e1a53f50b56a3783 |
|
105 | index 0000000000000000000000000000000000000000..e8c9d6b98e3dce993a464935e1a53f50b56a3783 | |
106 | --- /dev/null |
|
106 | --- /dev/null | |
107 | +++ b/foobar2 |
|
107 | +++ b/foobar2 | |
108 | @@ -0,0 +1 @@ |
|
108 | @@ -0,0 +1 @@ | |
109 | +foobar2 |
|
109 | +foobar2 | |
110 | \ No newline at end of file |
|
110 | \ No newline at end of file | |
111 | ''') |
|
111 | ''') | |
112 |
|
112 | |||
113 | def test_second_changeset_diff(self): |
|
113 | def test_second_changeset_diff(self): | |
114 | revs = self.repo.revisions |
|
114 | revs = self.repo.revisions | |
115 | self.assertEqual(self.repo.get_diff(revs[0], revs[1]), '''diff --git a/foobar b/foobar |
|
115 | self.assertEqual(self.repo.get_diff(revs[0], revs[1]), '''diff --git a/foobar b/foobar | |
116 | index f6ea0495187600e7b2288c8ac19c5886383a4632..389865bb681b358c9b102d79abd8d5f941e96551 100644 |
|
116 | index f6ea0495187600e7b2288c8ac19c5886383a4632..389865bb681b358c9b102d79abd8d5f941e96551 100644 | |
117 | --- a/foobar |
|
117 | --- a/foobar | |
118 | +++ b/foobar |
|
118 | +++ b/foobar | |
119 | @@ -1 +1 @@ |
|
119 | @@ -1 +1 @@ | |
120 | -foobar |
|
120 | -foobar | |
121 | \ No newline at end of file |
|
121 | \ No newline at end of file | |
122 | +FOOBAR |
|
122 | +FOOBAR | |
123 | \ No newline at end of file |
|
123 | \ No newline at end of file | |
124 | diff --git a/foobar3 b/foobar3 |
|
124 | diff --git a/foobar3 b/foobar3 | |
125 | new file mode 100644 |
|
125 | new file mode 100644 | |
126 | index 0000000000000000000000000000000000000000..c11c37d41d33fb47741cff93fa5f9d798c1535b0 |
|
126 | index 0000000000000000000000000000000000000000..c11c37d41d33fb47741cff93fa5f9d798c1535b0 | |
127 | --- /dev/null |
|
127 | --- /dev/null | |
128 | +++ b/foobar3 |
|
128 | +++ b/foobar3 | |
129 | @@ -0,0 +1 @@ |
|
129 | @@ -0,0 +1 @@ | |
130 | +foobar3 |
|
130 | +foobar3 | |
131 | \ No newline at end of file |
|
131 | \ No newline at end of file | |
132 | ''') |
|
132 | ''') | |
133 |
|
133 | |||
134 | def test_third_changeset_diff(self): |
|
134 | def test_third_changeset_diff(self): | |
135 | revs = self.repo.revisions |
|
135 | revs = self.repo.revisions | |
136 | self.assertEqual(self.repo.get_diff(revs[1], revs[2]), '''diff --git a/foobar b/foobar |
|
136 | self.assertEqual(self.repo.get_diff(revs[1], revs[2]), '''diff --git a/foobar b/foobar | |
137 | deleted file mode 100644 |
|
137 | deleted file mode 100644 | |
138 | index 389865bb681b358c9b102d79abd8d5f941e96551..0000000000000000000000000000000000000000 |
|
138 | index 389865bb681b358c9b102d79abd8d5f941e96551..0000000000000000000000000000000000000000 | |
139 | --- a/foobar |
|
139 | --- a/foobar | |
140 | +++ /dev/null |
|
140 | +++ /dev/null | |
141 | @@ -1 +0,0 @@ |
|
141 | @@ -1 +0,0 @@ | |
142 | -FOOBAR |
|
142 | -FOOBAR | |
143 | \ No newline at end of file |
|
143 | \ No newline at end of file | |
144 | diff --git a/foobar3 b/foobar3 |
|
144 | diff --git a/foobar3 b/foobar3 | |
145 | index c11c37d41d33fb47741cff93fa5f9d798c1535b0..f9324477362684ff692aaf5b9a81e01b9e9a671c 100644 |
|
145 | index c11c37d41d33fb47741cff93fa5f9d798c1535b0..f9324477362684ff692aaf5b9a81e01b9e9a671c 100644 | |
146 | --- a/foobar3 |
|
146 | --- a/foobar3 | |
147 | +++ b/foobar3 |
|
147 | +++ b/foobar3 | |
148 | @@ -1 +1,3 @@ |
|
148 | @@ -1 +1,3 @@ | |
149 | -foobar3 |
|
149 | -foobar3 | |
150 | \ No newline at end of file |
|
150 | \ No newline at end of file | |
151 | +FOOBAR |
|
151 | +FOOBAR | |
152 | +FOOBAR |
|
152 | +FOOBAR | |
153 | +FOOBAR |
|
153 | +FOOBAR | |
154 | ''') |
|
154 | ''') | |
155 |
|
155 | |||
156 |
|
156 | |||
157 | class HgRepositoryGetDiffTest(RepositoryGetDiffTest, unittest.TestCase): |
|
157 | class HgRepositoryGetDiffTest(RepositoryGetDiffTest, unittest.TestCase): | |
158 | backend_alias = 'hg' |
|
158 | backend_alias = 'hg' | |
159 |
|
159 | |||
160 | def test_initial_commit_diff(self): |
|
160 | def test_initial_commit_diff(self): | |
161 | initial_rev = self.repo.revisions[0] |
|
161 | initial_rev = self.repo.revisions[0] | |
162 | self.assertEqual(self.repo.get_diff(self.repo.EMPTY_CHANGESET, initial_rev), '''diff --git a/foobar b/foobar |
|
162 | self.assertEqual(self.repo.get_diff(self.repo.EMPTY_CHANGESET, initial_rev), '''diff --git a/foobar b/foobar | |
163 | new file mode 100644 |
|
163 | new file mode 100644 | |
164 | --- /dev/null |
|
164 | --- /dev/null | |
165 | +++ b/foobar |
|
165 | +++ b/foobar | |
166 | @@ -0,0 +1,1 @@ |
|
166 | @@ -0,0 +1,1 @@ | |
167 | +foobar |
|
167 | +foobar | |
168 | \ No newline at end of file |
|
168 | \ No newline at end of file | |
169 | diff --git a/foobar2 b/foobar2 |
|
169 | diff --git a/foobar2 b/foobar2 | |
170 | new file mode 100644 |
|
170 | new file mode 100644 | |
171 | --- /dev/null |
|
171 | --- /dev/null | |
172 | +++ b/foobar2 |
|
172 | +++ b/foobar2 | |
173 | @@ -0,0 +1,1 @@ |
|
173 | @@ -0,0 +1,1 @@ | |
174 | +foobar2 |
|
174 | +foobar2 | |
175 | \ No newline at end of file |
|
175 | \ No newline at end of file | |
176 | ''') |
|
176 | ''') | |
177 |
|
177 | |||
178 | def test_second_changeset_diff(self): |
|
178 | def test_second_changeset_diff(self): | |
179 | revs = self.repo.revisions |
|
179 | revs = self.repo.revisions | |
180 | self.assertEqual(self.repo.get_diff(revs[0], revs[1]), '''diff --git a/foobar b/foobar |
|
180 | self.assertEqual(self.repo.get_diff(revs[0], revs[1]), '''diff --git a/foobar b/foobar | |
181 | --- a/foobar |
|
181 | --- a/foobar | |
182 | +++ b/foobar |
|
182 | +++ b/foobar | |
183 | @@ -1,1 +1,1 @@ |
|
183 | @@ -1,1 +1,1 @@ | |
184 | -foobar |
|
184 | -foobar | |
185 | \ No newline at end of file |
|
185 | \ No newline at end of file | |
186 | +FOOBAR |
|
186 | +FOOBAR | |
187 | \ No newline at end of file |
|
187 | \ No newline at end of file | |
188 | diff --git a/foobar3 b/foobar3 |
|
188 | diff --git a/foobar3 b/foobar3 | |
189 | new file mode 100644 |
|
189 | new file mode 100644 | |
190 | --- /dev/null |
|
190 | --- /dev/null | |
191 | +++ b/foobar3 |
|
191 | +++ b/foobar3 | |
192 | @@ -0,0 +1,1 @@ |
|
192 | @@ -0,0 +1,1 @@ | |
193 | +foobar3 |
|
193 | +foobar3 | |
194 | \ No newline at end of file |
|
194 | \ No newline at end of file | |
195 | ''') |
|
195 | ''') | |
196 |
|
196 | |||
197 | def test_third_changeset_diff(self): |
|
197 | def test_third_changeset_diff(self): | |
198 | revs = self.repo.revisions |
|
198 | revs = self.repo.revisions | |
199 | self.assertEqual(self.repo.get_diff(revs[1], revs[2]), '''diff --git a/foobar b/foobar |
|
199 | self.assertEqual(self.repo.get_diff(revs[1], revs[2]), '''diff --git a/foobar b/foobar | |
200 | deleted file mode 100644 |
|
200 | deleted file mode 100644 | |
201 | --- a/foobar |
|
201 | --- a/foobar | |
202 | +++ /dev/null |
|
202 | +++ /dev/null | |
203 | @@ -1,1 +0,0 @@ |
|
203 | @@ -1,1 +0,0 @@ | |
204 | -FOOBAR |
|
204 | -FOOBAR | |
205 | \ No newline at end of file |
|
205 | \ No newline at end of file | |
206 | diff --git a/foobar3 b/foobar3 |
|
206 | diff --git a/foobar3 b/foobar3 | |
207 | --- a/foobar3 |
|
207 | --- a/foobar3 | |
208 | +++ b/foobar3 |
|
208 | +++ b/foobar3 | |
209 | @@ -1,1 +1,3 @@ |
|
209 | @@ -1,1 +1,3 @@ | |
210 | -foobar3 |
|
210 | -foobar3 | |
211 | \ No newline at end of file |
|
211 | \ No newline at end of file | |
212 | +FOOBAR |
|
212 | +FOOBAR | |
213 | +FOOBAR |
|
213 | +FOOBAR | |
214 | +FOOBAR |
|
214 | +FOOBAR | |
215 | ''') |
|
215 | ''') | |
216 |
|
216 | |||
217 |
|
217 | |||
218 | # For each backend create test case class |
|
218 | # For each backend create test case class | |
219 | for alias in SCM_TESTS: |
|
219 | for alias in SCM_TESTS: | |
220 | attrs = { |
|
220 | attrs = { | |
221 | 'backend_alias': alias, |
|
221 | 'backend_alias': alias, | |
222 | } |
|
222 | } | |
223 | cls_name = alias.capitalize() + RepositoryBaseTest.__name__ |
|
223 | cls_name = alias.capitalize() + RepositoryBaseTest.__name__ | |
224 | bases = (RepositoryBaseTest, unittest.TestCase) |
|
224 | bases = (RepositoryBaseTest, unittest.TestCase) | |
225 | globals()[cls_name] = type(cls_name, bases, attrs) |
|
225 | globals()[cls_name] = type(cls_name, bases, attrs) |
General Comments 0
You need to be logged in to leave comments.
Login now