~rlane/nova/ldapimprovements

« back to all changes in this revision

Viewing changes to nova/tests/misc_unittest.py

  • Committer: Ryan Lane
  • Date: 2010-11-24 15:46:32 UTC
  • mfrom: (382.48.1 trunk)
  • Revision ID: laner@controller-20101124154632-zh7kwjuyyd02a2lh
MergeĀ fromĀ trunk

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
import subprocess
 
19
 
 
20
from nova import test
 
21
from nova.utils import parse_mailmap, str_dict_replace
 
22
 
 
23
 
 
24
class ProjectTestCase(test.TrialTestCase):
 
25
    def test_authors_up_to_date(self):
 
26
        if os.path.exists('../.bzr'):
 
27
            log_cmd = subprocess.Popen(["bzr", "log", "-n0"],
 
28
                                       stdout=subprocess.PIPE)
 
29
            changelog = log_cmd.communicate()[0]
 
30
            mailmap = parse_mailmap('../.mailmap')
 
31
 
 
32
            contributors = set()
 
33
            for l in changelog.split('\n'):
 
34
                l = l.strip()
 
35
                if (l.startswith('author:') or l.startswith('committer:')
 
36
                         and not l == 'committer: Tarmac'):
 
37
                    email = l.split(' ')[-1]
 
38
                    contributors.add(str_dict_replace(email, mailmap))
 
39
 
 
40
            authors_file = open('../Authors', 'r').read()
 
41
 
 
42
            missing = set()
 
43
            for contributor in contributors:
 
44
                if not contributor in authors_file:
 
45
                    missing.add(contributor)
 
46
 
 
47
            self.assertTrue(len(missing) == 0,
 
48
                            '%r not listed in Authors' % missing)