/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6637.1.2 by Jelmer Vernooij
Add tests.
1
# Copyright (C) 2006-2012 Aaron Bentley
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
#
17
18
"""Tests of the 'brz import' command."""
19
20
import os
21
22
from ... import (
23
    osutils,
24
    tests,
25
    urlutils,
26
    )
27
from .. import (
28
    features,
29
    script,
30
    )
31
32
33
LzmaFeature = features.ModuleAvailableFeature("lzma")
34
35
36
class TestImport(tests.TestCaseWithTransport):
37
38
    def test_import_upstream(self):
39
        self.run_bzr('init source')
40
        os.mkdir('source/src')
6973.7.5 by Jelmer Vernooij
s/file/open.
41
        with open('source/src/myfile', 'wb') as f:
42
            f.write(b'hello?')
6637.1.2 by Jelmer Vernooij
Add tests.
43
        os.chdir('source')
44
        self.run_bzr('add')
45
        self.run_bzr('commit -m hello')
46
        self.run_bzr('export ../source-0.1.tar.gz')
47
        self.run_bzr('export ../source-0.1.tar.bz2')
48
        self.run_bzr('export ../source-0.1')
49
        self.run_bzr('init ../import')
50
        os.chdir('../import')
51
        self.run_bzr('import ../source-0.1.tar.gz')
52
        self.assertPathExists('src/myfile')
53
        result = self.run_bzr('import ../source-0.1.tar.gz', retcode=3)[1]
54
        self.assertContainsRe(result, 'Working tree has uncommitted changes')
55
        self.run_bzr('commit -m commit')
56
        self.run_bzr('import ../source-0.1.tar.gz')
57
        os.chdir('..')
58
        self.run_bzr('init import2')
59
        self.run_bzr('import source-0.1.tar.gz import2')
60
        self.assertPathExists('import2/src/myfile')
61
        self.run_bzr('import source-0.1.tar.gz import3')
62
        self.assertPathExists('import3/src/myfile')
63
        self.run_bzr('import source-0.1.tar.bz2 import4')
64
        self.assertPathExists('import4/src/myfile')
65
        self.run_bzr('import source-0.1 import5')
66
        self.assertPathExists('import5/src/myfile')
67
68
    def test_import_upstream_lzma(self):
69
        self.requireFeature(LzmaFeature)
70
        self.run_bzr('init source')
71
        os.mkdir('source/src')
6973.7.5 by Jelmer Vernooij
s/file/open.
72
        with open('source/src/myfile', 'wb') as f:
73
            f.write(b'hello?')
6637.1.2 by Jelmer Vernooij
Add tests.
74
        os.chdir('source')
75
        self.run_bzr('add')
76
        self.run_bzr('commit -m hello')
77
        self.run_bzr('export ../source-0.1.tar.lzma')
78
        self.run_bzr('export ../source-0.1.tar.xz')
79
        os.chdir('..')
80
        self.run_bzr('import source-0.1.tar.lzma import1')
81
        self.assertPathExists('import1/src/myfile')
82
        self.run_bzr('import source-0.1.tar.xz import2')
83
        self.assertPathExists('import2/src/myfile')