bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.200.1515
by Jelmer Vernooij
Add tests for git_remote_helper. |
1 |
#!/usr/bin/env python
|
2 |
# vim: expandtab
|
|
3 |
||
|
0.358.2
by Jelmer Vernooij
Refresh copyright headers, add my email. |
4 |
# Copyright (C) 2011-2018 Jelmer Vernooij <jelmer@jelmer.uk>
|
|
0.200.1515
by Jelmer Vernooij
Add tests for git_remote_helper. |
5 |
|
6 |
# This program is free software; you can redistribute it and/or modify
|
|
7 |
# it under the terms of the GNU General Public License as published by
|
|
8 |
# the Free Software Foundation; either version 2 of the License, or
|
|
9 |
# (at your option) any later version.
|
|
10 |
#
|
|
11 |
# This program is distributed in the hope that it will be useful,
|
|
12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
# GNU General Public License for more details.
|
|
15 |
#
|
|
16 |
# You should have received a copy of the GNU General Public License
|
|
17 |
# along with this program; if not, write to the Free Software
|
|
|
0.358.1
by Jelmer Vernooij
Fix FSF address. |
18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
0.200.1515
by Jelmer Vernooij
Add tests for git_remote_helper. |
19 |
|
|
0.358.3
by Jelmer Vernooij
Enable absolute import. |
20 |
"""Tests for the git remote helper."""
|
21 |
||
22 |
from __future__ import absolute_import |
|
23 |
||
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
24 |
from io import BytesIO |
|
0.200.1515
by Jelmer Vernooij
Add tests for git_remote_helper. |
25 |
import os |
26 |
||
|
0.200.1586
by Jelmer Vernooij
Fixes duplicate tag warnings in 'git-remote-bzr' helper. |
27 |
from dulwich.repo import Repo |
28 |
||
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
29 |
from ...tests import ( |
|
0.200.1582
by Jelmer Vernooij
Print error when bzr-fastimport is not installed. |
30 |
TestCaseWithTransport, |
31 |
TestSkipped, |
|
32 |
)
|
|
|
0.200.1515
by Jelmer Vernooij
Add tests for git_remote_helper. |
33 |
|
|
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
34 |
from ..object_store import get_object_store |
35 |
from ..git_remote_helper import ( |
|
|
0.200.1516
by Jelmer Vernooij
Add tests for capabilities command. |
36 |
RemoteHelper, |
37 |
open_local_dir, |
|
|
0.200.1582
by Jelmer Vernooij
Print error when bzr-fastimport is not installed. |
38 |
fastexporter, |
|
0.200.1585
by Jelmer Vernooij
Add really basic test for remote helper 'fetch' implementation. |
39 |
fetch, |
|
0.200.1516
by Jelmer Vernooij
Add tests for capabilities command. |
40 |
)
|
|
0.200.1515
by Jelmer Vernooij
Add tests for git_remote_helper. |
41 |
|
|
7045.4.17
by Jelmer Vernooij
Fix tests. |
42 |
from . import FastimportFeature |
43 |
||
|
0.200.1515
by Jelmer Vernooij
Add tests for git_remote_helper. |
44 |
|
|
0.200.1586
by Jelmer Vernooij
Fixes duplicate tag warnings in 'git-remote-bzr' helper. |
45 |
def map_to_git_sha1(dir, bzr_revid): |
46 |
object_store = get_object_store(dir.open_repository()) |
|
|
0.200.1788
by Jelmer Vernooij
Use context managers. |
47 |
with object_store.lock_read(): |
|
0.200.1586
by Jelmer Vernooij
Fixes duplicate tag warnings in 'git-remote-bzr' helper. |
48 |
return object_store._lookup_revision_sha1(bzr_revid) |
49 |
||
50 |
||
|
0.200.1515
by Jelmer Vernooij
Add tests for git_remote_helper. |
51 |
class OpenLocalDirTests(TestCaseWithTransport): |
52 |
||
53 |
def test_from_env_dir(self): |
|
54 |
self.make_branch_and_tree('bla', format='git') |
|
55 |
self.overrideEnv('GIT_DIR', os.path.join(self.test_dir, 'bla', '.git')) |
|
56 |
open_local_dir() |
|
57 |
||
58 |
def test_from_dir(self): |
|
59 |
self.make_branch_and_tree('.', format='git') |
|
60 |
open_local_dir() |
|
|
0.200.1516
by Jelmer Vernooij
Add tests for capabilities command. |
61 |
|
62 |
||
|
0.200.1585
by Jelmer Vernooij
Add really basic test for remote helper 'fetch' implementation. |
63 |
class FetchTests(TestCaseWithTransport): |
64 |
||
65 |
def setUp(self): |
|
66 |
super(FetchTests, self).setUp() |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
67 |
self.local_dir = self.make_branch_and_tree('local', format='git').controldir |
|
0.200.1585
by Jelmer Vernooij
Add really basic test for remote helper 'fetch' implementation. |
68 |
self.remote_tree = self.make_branch_and_tree('remote') |
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
69 |
self.remote_dir = self.remote_tree.controldir |
|
0.200.1585
by Jelmer Vernooij
Add really basic test for remote helper 'fetch' implementation. |
70 |
self.shortname = 'bzr' |
71 |
||
72 |
def fetch(self, wants): |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
73 |
outf = BytesIO() |
|
0.200.1585
by Jelmer Vernooij
Add really basic test for remote helper 'fetch' implementation. |
74 |
fetch(outf, wants, self.shortname, self.remote_dir, self.local_dir) |
75 |
return outf.getvalue() |
|
76 |
||
77 |
def test_no_wants(self): |
|
78 |
r = self.fetch([]) |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
79 |
self.assertEqual(b"\n", r) |
|
0.200.1585
by Jelmer Vernooij
Add really basic test for remote helper 'fetch' implementation. |
80 |
|
|
0.200.1586
by Jelmer Vernooij
Fixes duplicate tag warnings in 'git-remote-bzr' helper. |
81 |
def test_simple(self): |
82 |
self.build_tree(['remote/foo']) |
|
83 |
self.remote_tree.add("foo") |
|
84 |
revid = self.remote_tree.commit("msg") |
|
85 |
git_sha1 = map_to_git_sha1(self.remote_dir, revid) |
|
86 |
out = self.fetch([(git_sha1, 'HEAD')]) |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
87 |
self.assertEqual(out, b"\n") |
|
0.200.1586
by Jelmer Vernooij
Fixes duplicate tag warnings in 'git-remote-bzr' helper. |
88 |
r = Repo('local') |
89 |
self.assertTrue(git_sha1 in r.object_store) |
|
|
6964.2.3
by Jelmer Vernooij
Review comments. |
90 |
self.assertEqual({ |
|
0.310.9
by Jelmer Vernooij
Some controldir fixes. |
91 |
}, r.get_refs()) |
|
0.200.1586
by Jelmer Vernooij
Fixes duplicate tag warnings in 'git-remote-bzr' helper. |
92 |
|
|
0.200.1585
by Jelmer Vernooij
Add really basic test for remote helper 'fetch' implementation. |
93 |
|
|
0.200.1516
by Jelmer Vernooij
Add tests for capabilities command. |
94 |
class RemoteHelperTests(TestCaseWithTransport): |
95 |
||
96 |
def setUp(self): |
|
97 |
super(RemoteHelperTests, self).setUp() |
|
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
98 |
self.local_dir = self.make_branch_and_tree('local', format='git').controldir |
|
0.200.1581
by Jelmer Vernooij
Fix support for newer versions of bzr-fastimport, add more tests. |
99 |
self.remote_tree = self.make_branch_and_tree('remote') |
|
0.200.1648
by Jelmer Vernooij
Fix compatibility with newer versions of breezy. |
100 |
self.remote_dir = self.remote_tree.controldir |
|
0.200.1516
by Jelmer Vernooij
Add tests for capabilities command. |
101 |
self.shortname = 'bzr' |
102 |
self.helper = RemoteHelper(self.local_dir, self.shortname, self.remote_dir) |
|
103 |
||
104 |
def test_capabilities(self): |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
105 |
f = BytesIO() |
|
0.200.1516
by Jelmer Vernooij
Add tests for capabilities command. |
106 |
self.helper.cmd_capabilities(f, []) |
107 |
capabs = f.getvalue() |
|
|
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
108 |
base = b"fetch\noption\npush\n" |
109 |
self.assertTrue(capabs in (base+b"\n", base+b"import\n\n"), capabs) |
|
|
0.200.1517
by Jelmer Vernooij
Add test for option command in git-remote-helper. |
110 |
|
111 |
def test_option(self): |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
112 |
f = BytesIO() |
|
0.200.1517
by Jelmer Vernooij
Add test for option command in git-remote-helper. |
113 |
self.helper.cmd_option(f, []) |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
114 |
self.assertEqual(b"unsupported\n", f.getvalue()) |
|
0.200.1517
by Jelmer Vernooij
Add test for option command in git-remote-helper. |
115 |
|
|
0.200.1518
by Jelmer Vernooij
Add basic test for list command. |
116 |
def test_list_basic(self): |
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
117 |
f = BytesIO() |
|
0.200.1518
by Jelmer Vernooij
Add basic test for list command. |
118 |
self.helper.cmd_list(f, []) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
119 |
self.assertEqual( |
|
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
120 |
b'\n', |
|
0.200.1518
by Jelmer Vernooij
Add basic test for list command. |
121 |
f.getvalue()) |
|
0.200.1581
by Jelmer Vernooij
Fix support for newer versions of bzr-fastimport, add more tests. |
122 |
|
123 |
def test_import(self): |
|
|
7045.4.17
by Jelmer Vernooij
Fix tests. |
124 |
self.requireFeature(FastimportFeature) |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
125 |
self.build_tree_contents([("remote/afile", b"somecontent")]) |
|
0.200.1581
by Jelmer Vernooij
Fix support for newer versions of bzr-fastimport, add more tests. |
126 |
self.remote_tree.add(["afile"]) |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
127 |
self.remote_tree.commit(b"A commit message", timestamp=1330445983, |
128 |
timezone=0, committer=b'Somebody <jrandom@example.com>') |
|
|
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
129 |
f = BytesIO() |
|
7027.5.2
by Jelmer Vernooij
Fix some more git tests. |
130 |
self.helper.cmd_import(f, ["import", "refs/heads/master"]) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
131 |
self.assertEqual( |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
132 |
b'commit refs/heads/master\n' |
133 |
b'mark :1\n' |
|
134 |
b'committer Somebody <jrandom@example.com> 1330445983 +0000\n' |
|
135 |
b'data 16\n' |
|
136 |
b'A commit message\n' |
|
137 |
b'M 644 inline afile\n' |
|
138 |
b'data 11\n' |
|
139 |
b'somecontent\n', |
|
|
0.200.1581
by Jelmer Vernooij
Fix support for newer versions of bzr-fastimport, add more tests. |
140 |
f.getvalue()) |