~ubuntu-branches/debian/squeeze/bzr-builddeb/squeeze

« back to all changes in this revision

Viewing changes to tests/blackbox/test_mark_uploaded.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2010-01-18 19:15:26 UTC
  • mfrom: (5.1.5 karmic)
  • Revision ID: james.westby@ubuntu.com-20100118191526-fzyw0n60z6vrhhhn
Tags: 2.2
* Upload to unstable.
* Bump standards version to 3.8.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#    test_mark_uploaded.py -- Blackbox tests for mark-uploaded.
 
2
#    Copyright (C) 2007 James Westby <jw+debian@jameswestby.net>
 
3
#    
 
4
#    This file is part of bzr-builddeb.
 
5
#
 
6
#    bzr-builddeb 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
#    bzr-builddeb 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 bzr-builddeb; if not, write to the Free Software
 
18
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
#
 
20
 
 
21
from debian_bundle.changelog import Changelog, Version
 
22
 
 
23
from bzrlib.plugins.builddeb.tests import BuilddebTestCase
 
24
 
 
25
 
 
26
class TestMarkUploaded(BuilddebTestCase):
 
27
 
 
28
    def make_unuploaded(self):
 
29
        self.wt = self.make_branch_and_tree('.')
 
30
        self.build_tree(['debian/'])
 
31
        cl = Changelog()
 
32
        v = Version("0.1-1")
 
33
        cl.new_block(package='package',
 
34
                     version=Version('0.1-1'),
 
35
                     distributions='unstable',
 
36
                     urgency='low',
 
37
                     author='James Westby <jw+debian@jameswestby.net>',
 
38
                     date='Thu,  3 Aug 2006 19:16:22 +0100',
 
39
                     )
 
40
        cl.add_change('');
 
41
        cl.add_change('  * Initial packaging.');
 
42
        cl.add_change('');
 
43
        f = open('debian/changelog', 'wb')
 
44
        try:
 
45
            cl.write_to_open_file(f)
 
46
        finally:
 
47
            f.close()
 
48
        self.wt.add(["debian/", "debian/changelog"])
 
49
        self.wt.commit("one")
 
50
 
 
51
    def test_mark_uploaded_available(self):
 
52
        self.run_bzr('mark-uploaded --help')
 
53
 
 
54
    def test_mark_uploaded_changes(self):
 
55
        self.make_unuploaded()
 
56
        self.build_tree(['foo'])
 
57
        self.wt.add(['foo'])
 
58
        self.run_bzr_error(["There are uncommitted changes"],
 
59
                "mark-uploaded")
 
60
 
 
61
    def test_mark_uploaded_unkown_dist(self):
 
62
        self.make_unuploaded()
 
63
        cl = Changelog()
 
64
        v = Version("0.1-1")
 
65
        cl.new_block(package='package',
 
66
                     version=Version('0.1-1'),
 
67
                     distributions='UNRELEASED',
 
68
                     urgency='low',
 
69
                     author='James Westby <jw+debian@jameswestby.net>',
 
70
                     date='Thu,  3 Aug 2006 19:16:22 +0100',
 
71
                     )
 
72
        cl.add_change('');
 
73
        cl.add_change('  * Initial packaging.');
 
74
        cl.add_change('');
 
75
        f = open('debian/changelog', 'wb')
 
76
        try:
 
77
            cl.write_to_open_file(f)
 
78
        finally:
 
79
            f.close()
 
80
        self.wt.commit("two")
 
81
        self.run_bzr_error(["The changelog still targets 'UNRELEASED', so "
 
82
                "apparently hasn't been uploaded."], "mark-uploaded")
 
83
 
 
84
    def test_mark_uploaded_already(self):
 
85
        self.make_unuploaded()
 
86
        self.run_bzr("mark-uploaded")
 
87
        self.build_tree(["foo"])
 
88
        self.wt.add(["foo"])
 
89
        self.wt.commit("two")
 
90
        self.run_bzr_error(["This version has already been marked uploaded"],
 
91
                "mark-uploaded")
 
92
 
 
93
    def test_mark_uploaded(self):
 
94
        self.make_unuploaded()
 
95
        self.run_bzr("mark-uploaded")
 
96
        tagged_revision = self.wt.branch.tags.lookup_tag('0.1-1')
 
97
        self.assertEqual(tagged_revision, self.wt.branch.last_revision())
 
98
 
 
99
    def test_mark_uploaded_force(self):
 
100
        self.make_unuploaded()
 
101
        self.run_bzr("mark-uploaded")
 
102
        self.build_tree(["foo"])
 
103
        self.wt.add(["foo"])
 
104
        self.wt.commit("two")
 
105
        self.run_bzr("mark-uploaded --force")
 
106
        tagged_revision = self.wt.branch.tags.lookup_tag('0.1-1')
 
107
        self.assertEqual(tagged_revision, self.wt.branch.last_revision())