Statistics
| Revision:

gvsig-scripting / org.gvsig.scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.app / org.gvsig.scripting.app.mainplugin / src / main / resources-plugin / scripting / lib / dulwich / tests / test_blackbox.py @ 959

History | View | Annotate | Download (2.58 KB)

1
# test_blackbox.py -- blackbox tests
2
# Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
3
#
4
# Dulwich is dual-licensed under the Apache License, Version 2.0 and the GNU
5
# General Public License as public by the Free Software Foundation; version 2.0
6
# or (at your option) any later version. You can redistribute it and/or
7
# modify it under the terms of either of these two licenses.
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14
#
15
# You should have received a copy of the licenses; if not, see
16
# <http://www.gnu.org/licenses/> for a copy of the GNU General Public License
17
# and <http://www.apache.org/licenses/LICENSE-2.0> for a copy of the Apache
18
# License, Version 2.0.
19
#
20

    
21
"""Blackbox tests for Dulwich commands."""
22

    
23
import tempfile
24
import shutil
25

    
26
from dulwich.repo import (
27
    Repo,
28
    )
29
from dulwich.tests import (
30
    BlackboxTestCase,
31
    )
32

    
33

    
34
class GitReceivePackTests(BlackboxTestCase):
35
    """Blackbox tests for dul-receive-pack."""
36

    
37
    def setUp(self):
38
        super(GitReceivePackTests, self).setUp()
39
        self.path = tempfile.mkdtemp()
40
        self.addCleanup(shutil.rmtree, self.path)
41
        self.repo = Repo.init(self.path)
42

    
43
    def test_basic(self):
44
        process = self.run_command("dul-receive-pack", [self.path])
45
        (stdout, stderr) = process.communicate(b"0000")
46
        self.assertEqual(b'0000', stdout[-4:])
47
        self.assertEqual(0, process.returncode)
48

    
49
    def test_missing_arg(self):
50
        process = self.run_command("dul-receive-pack", [])
51
        (stdout, stderr) = process.communicate()
52
        self.assertEqual(
53
            [b'usage: dul-receive-pack <git-dir>'],
54
            stderr.splitlines()[-1:])
55
        self.assertEqual(b'', stdout)
56
        self.assertEqual(1, process.returncode)
57

    
58

    
59
class GitUploadPackTests(BlackboxTestCase):
60
    """Blackbox tests for dul-upload-pack."""
61

    
62
    def setUp(self):
63
        super(GitUploadPackTests, self).setUp()
64
        self.path = tempfile.mkdtemp()
65
        self.addCleanup(shutil.rmtree, self.path)
66
        self.repo = Repo.init(self.path)
67

    
68
    def test_missing_arg(self):
69
        process = self.run_command("dul-upload-pack", [])
70
        (stdout, stderr) = process.communicate()
71
        self.assertEqual(
72
            [b'usage: dul-upload-pack <git-dir>'],
73
            stderr.splitlines()[-1:])
74
        self.assertEqual(b'', stdout)
75
        self.assertEqual(1, process.returncode)