~ps-jenkins/click/ubuntu-utopic-proposed

« back to all changes in this revision

Viewing changes to tests/integration/test_buildsource.py

  • Committer: CI bot
  • Author(s): Colin Watson
  • Date: 2014-07-04 15:09:52 UTC
  • mfrom: (425.1.61 devel)
  • Revision ID: ps-jenkins@lists.canonical.com-20140704150952-kzid0oyfhdksxz1h
Click 0.4.29: Integration test and coverage improvements; handle all -devN frameworks; add qmlscene to chroots. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2014 Canonical Ltd.
 
2
# Author: Michael Vogt <michael.vogt@ubuntu.com>
 
3
 
 
4
# This program is free software: you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; version 3 of the License.
 
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, see <http://www.gnu.org/licenses/>.
 
15
 
 
16
"""Integration tests for the click CLI buildsource command."""
 
17
 
 
18
import os
 
19
import shutil
 
20
import subprocess
 
21
import tarfile
 
22
import tempfile
 
23
 
 
24
from .helpers import (
 
25
    chdir,
 
26
    ClickTestCase,
 
27
)
 
28
 
 
29
 
 
30
class TestBuildSource(ClickTestCase):
 
31
 
 
32
    def test_buildsource(self):
 
33
        temp_dir = tempfile.mkdtemp()
 
34
        self.addCleanup(shutil.rmtree, temp_dir)
 
35
        with chdir(temp_dir):
 
36
            with open(os.path.join(temp_dir, "README"), "w") as f:
 
37
                f.write("I'm a source package")
 
38
            os.mkdir(os.path.join(temp_dir, ".git"))
 
39
            os.mkdir(os.path.join(temp_dir, ".bzr"))
 
40
            os.mkdir(os.path.join(temp_dir, ".normal"))
 
41
            self._create_manifest(os.path.join(temp_dir, "manifest.json"),
 
42
                                  "srcfoo", "1.2", "ubuntu-sdk-13.10")
 
43
            subprocess.check_call(
 
44
                [self.click_binary, "buildsource", temp_dir],
 
45
                universal_newlines=True)
 
46
            # ensure we have the content we expect
 
47
            source_file = "srcfoo_1.2.tar.gz"
 
48
            tar = tarfile.open(source_file)
 
49
            self.assertEqual(
 
50
                sorted(tar.getnames()),
 
51
                sorted([".", "./.normal", "./manifest.json", "./README"]))