~ubuntu-branches/ubuntu/quantal/nova/quantal-proposed

« back to all changes in this revision

Viewing changes to nova/tests/misc_unittest.py

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-01-21 11:48:06 UTC
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20110121114806-v8fvnnl6az4m4ohv
Tags: upstream-2011.1~bzr597
ImportĀ upstreamĀ versionĀ 2011.1~bzr597

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
 
 
3
 
#    Copyright 2010 OpenStack LLC
4
 
#
5
 
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
6
 
#    not use this file except in compliance with the License. You may obtain
7
 
#    a copy of the License at
8
 
#
9
 
#         http://www.apache.org/licenses/LICENSE-2.0
10
 
#
11
 
#    Unless required by applicable law or agreed to in writing, software
12
 
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
 
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
 
#    License for the specific language governing permissions and limitations
15
 
#    under the License.
16
 
 
17
 
import os
18
 
 
19
 
from nova import test
20
 
from nova.utils import parse_mailmap, str_dict_replace
21
 
 
22
 
 
23
 
class ProjectTestCase(test.TrialTestCase):
24
 
    def test_authors_up_to_date(self):
25
 
        if os.path.exists('../.bzr'):
26
 
            contributors = set()
27
 
 
28
 
            mailmap = parse_mailmap('../.mailmap')
29
 
 
30
 
            import bzrlib.workingtree
31
 
            tree = bzrlib.workingtree.WorkingTree.open('..')
32
 
            tree.lock_read()
33
 
            parents = tree.get_parent_ids()
34
 
            g = tree.branch.repository.get_graph()
35
 
            for p in parents[1:]:
36
 
                rev_ids = [r for r, _ in g.iter_ancestry(parents)
37
 
                           if r != "null:"]
38
 
                revs = tree.branch.repository.get_revisions(rev_ids)
39
 
                for r in revs:
40
 
                    for author in r.get_apparent_authors():
41
 
                        email = author.split(' ')[-1]
42
 
                        contributors.add(str_dict_replace(email, mailmap))
43
 
 
44
 
            authors_file = open('../Authors', 'r').read()
45
 
 
46
 
            missing = set()
47
 
            for contributor in contributors:
48
 
                if not contributor in authors_file:
49
 
                    missing.add(contributor)
50
 
 
51
 
            self.assertTrue(len(missing) == 0,
52
 
                            '%r not listed in Authors' % missing)