e5b9078f4c
Fixing files 93/93 files fixed Change-Id: Ia30f2e2253806fa5f447d44208d13d2c0beba9cd
58 lines
2.1 KiB
Python
58 lines
2.1 KiB
Python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
|
|
# Copyright 2011 OpenStack LLC.
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import os
|
|
from tempfile import mkstemp
|
|
import unittest
|
|
|
|
from quantum.openstack.common.setup import canonicalize_emails
|
|
from quantum.openstack.common.setup import parse_mailmap
|
|
|
|
|
|
class SetupTest(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
(fd, self.mailmap) = mkstemp(prefix='openstack', suffix='.mailmap')
|
|
|
|
def test_str_dict_replace(self):
|
|
string = 'Johnnie T. Hozer'
|
|
mapping = {'T.': 'The'}
|
|
self.assertEqual('Johnnie The Hozer',
|
|
canonicalize_emails(string, mapping))
|
|
|
|
def test_mailmap_with_fullname(self):
|
|
with open(self.mailmap, 'w') as mm_fh:
|
|
mm_fh.write("Foo Bar <email@foo.com> Foo Bar <email@bar.com>\n")
|
|
self.assertEqual({'<email@bar.com>': '<email@foo.com>'},
|
|
parse_mailmap(self.mailmap))
|
|
|
|
def test_mailmap_with_firstname(self):
|
|
with open(self.mailmap, 'w') as mm_fh:
|
|
mm_fh.write("Foo <email@foo.com> Foo <email@bar.com>\n")
|
|
self.assertEqual({'<email@bar.com>': '<email@foo.com>'},
|
|
parse_mailmap(self.mailmap))
|
|
|
|
def test_mailmap_with_noname(self):
|
|
with open(self.mailmap, 'w') as mm_fh:
|
|
mm_fh.write("<email@foo.com> <email@bar.com>\n")
|
|
self.assertEqual({'<email@bar.com>': '<email@foo.com>'},
|
|
parse_mailmap(self.mailmap))
|
|
|
|
def tearDown(self):
|
|
if os.path.exists(self.mailmap):
|
|
os.remove(self.mailmap)
|