Skip to content

Commit

Permalink
Add test case for authors mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
ustuehler committed Oct 27, 2015
1 parent 792e78f commit 066c248
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions tests/test_authors.py
@@ -0,0 +1,61 @@
from os.path import dirname, join
import subprocess
import unittest

from cvsgit.command.clone import Clone
from cvsgit.git import Git
from cvsgit.utils import Tempdir
from cvsgit.main import UnknownAuthorFullnames

class Test(unittest.TestCase):

def setUp(self):
self.tempdir = Tempdir(cwd=True)
self.tempdir.__enter__()
self.cvsdir = join(dirname(__file__), 'data', 'greek', 'tree')
self.gitdir = 'tree'

def tearDown(self):
self.tempdir.__exit__(None, None, None)

def cvs_clone(self, *args):
"""Clone CVS repo with default and additional arguments.
"""
args += (self.cvsdir, self.gitdir)
self.assertEquals(0, Clone().eval('--quiet', '--no-skip-latest', *args))

def git_authors(self):
"""Return author name and email addresses from git.
"""
return Git(self.gitdir).check_command('log', '--format=%an <%ae>',
stdout=subprocess.PIPE)

def test_clone_without_authors(self):
"""Clone without author mapping.
"""
self.cvs_clone()
self.assertEquals('uwe <uwe>', self.git_authors())

def test_clone_with_authors_name(self):
"""Clone with author fullname mapping.
"""
with open('authors', 'w') as authors:
authors.write('uwe Some Dude\n')
self.cvs_clone('--domain=example.com', '--authors=authors')
self.assertEquals('Some Dude <uwe@example.com>', self.git_authors())

def test_clone_with_authors_name_and_email(self):
"""Clone with author fullname and email mapping.
"""
with open('authors', 'w') as authors:
authors.write('uwe Some Dude <dude@example.com>\n')
self.cvs_clone('--authors=authors')
self.assertEquals('Some Dude <dude@example.com>', self.git_authors())

def test_clone_with_unknown_auhtor(self):
"""Clone with unknown author and --stop-on-unknown-author.
"""
with open('authors', 'w') as authors:
authors.write('nobody Non-existent User\n')
with self.assertRaises(UnknownAuthorFullnames):
self.cvs_clone('--authors=authors', '--stop-on-unknown-author')

0 comments on commit 066c248

Please sign in to comment.