def test_rename_user_and_merge(self): self.commits = [ MockCommit('Alice', '*****@*****.**'), MockCommit('Bad name', '*****@*****.**', '2018-01-01 00:00'), ] self.authors = { '*****@*****.**': MockUser('Alice', '*****@*****.**'), } num_commits, authors, num_authors, last_time = \ tasks.commits_author_stats(self.repopath) self.assertEqual(num_commits, 2) self.assertEqual(num_authors, 1) self.assertEqual(last_time, '2018-01-01 00:00') self.assertIn(authors, [ [(2, [('Alice', '*****@*****.**', 'https://seccdn.libravatar.org/avatar/' 'ff8d9819fc0e12bf0d24892e45987e249a28dce836a85cad60e28eaaa8c6d976' '?s=32&d=retro')])], [(2, [('Alice', '*****@*****.**', 'https://seccdn.libravatar.org/avatar/' 'ff8d9819fc0e12bf0d24892e45987e249a28dce836a85cad60e28eaaa8c6d976' '?d=retro&s=32')])] ])
def test_preserve_unknown_author(self): self.commits = [ MockCommit('Alice', '*****@*****.**', '2018-01-01 00:00'), ] self.authors = {} num_commits, authors, num_authors, last_time = \ tasks.commits_author_stats(self.repopath) self.assertEqual(num_commits, 1) self.assertEqual(num_authors, 1) self.assertEqual(last_time, '2018-01-01 00:00') self.assertEqual(authors, [(1, [('Alice', '*****@*****.**')])])
def test_rename_user_and_merge(self): self.commits = [ MockCommit("Alice", "*****@*****.**"), MockCommit("Bad name", "*****@*****.**", "2018-01-01 00:00"), ] self.authors = { "*****@*****.**": MockUser("Alice", "*****@*****.**") } num_commits, authors, num_authors, last_time = tasks.commits_author_stats( self.repopath ) self.assertEqual(num_commits, 2) self.assertEqual(num_authors, 1) self.assertEqual(last_time, "2018-01-01 00:00") self.assertIn( authors, [ [ ( 2, [ ( "Alice", "*****@*****.**", "https://seccdn.libravatar.org/avatar/" "ff8d9819fc0e12bf0d24892e45987e249a28dce836a85cad60e28eaaa8c6d976" "?s=32&d=retro", ) ], ) ], [ ( 2, [ ( "Alice", "*****@*****.**", "https://seccdn.libravatar.org/avatar/" "ff8d9819fc0e12bf0d24892e45987e249a28dce836a85cad60e28eaaa8c6d976" "?d=retro&s=32", ) ], ) ], ], )
def test_no_change(self): self.commits = [ MockCommit('Alice', '*****@*****.**', '2018-01-01 00:00'), ] self.authors = { '*****@*****.**': MockUser('Alice', '*****@*****.**'), } num_commits, authors, num_authors, last_time = \ tasks.commits_author_stats(self.repopath) self.assertEqual(num_commits, 1) self.assertEqual(num_authors, 1) self.assertEqual(last_time, '2018-01-01 00:00') self.assertEqual(authors, [(1, [('Alice', '*****@*****.**')])])
def test_handle_empty_email(self): self.commits = [ # Two commits for Alice to ensure order of the result. MockCommit('Alice', None), MockCommit('Alice', None), MockCommit('Bob', '', '2018-01-01 00:00'), ] self.authors = {} num_commits, authors, num_authors, last_time = \ tasks.commits_author_stats(self.repopath) self.assertEqual(num_commits, 3) self.assertEqual(num_authors, 2) self.assertEqual(last_time, '2018-01-01 00:00') self.assertEqual(authors, [(2, [('Alice', None)]), (1, [('Bob', '')])])
def test_rename_user_and_merge(self): self.commits = [ MockCommit('Alice', '*****@*****.**'), MockCommit('Bad name', '*****@*****.**', '2018-01-01 00:00'), ] self.authors = { '*****@*****.**': MockUser('Alice', '*****@*****.**'), } num_commits, authors, num_authors, last_time = \ tasks.commits_author_stats(self.repopath) self.assertEqual(num_commits, 2) self.assertEqual(num_authors, 1) self.assertEqual(last_time, '2018-01-01 00:00') self.assertEqual(authors, [(2, [('Alice', '*****@*****.**')])])
def test_preserve_unknown_author(self): self.commits = [ MockCommit("Alice", "*****@*****.**", "2018-01-01 00:00") ] self.authors = {} num_commits, authors, num_authors, last_time = tasks.commits_author_stats( self.repopath ) self.assertEqual(num_commits, 1) self.assertEqual(num_authors, 1) self.assertEqual(last_time, "2018-01-01 00:00") self.assertIn( authors, [ [ ( 1, [ ( "Alice", "*****@*****.**", "https://seccdn.libravatar.org/avatar/" "ff8d9819fc0e12bf0d24892e45987e249a28dce836a85cad60e28eaaa8c6d976" "?s=32&d=retro", ) ], ) ], [ ( 1, [ ( "Alice", "*****@*****.**", "https://seccdn.libravatar.org/avatar/" "ff8d9819fc0e12bf0d24892e45987e249a28dce836a85cad60e28eaaa8c6d976" "?d=retro&s=32", ) ], ) ], ], )
def test_rename_user_and_merge(self): self.commits = [ MockCommit("Alice", "*****@*****.**"), MockCommit("Bad name", "*****@*****.**", "2018-01-01 00:00"), ] self.authors = { "*****@*****.**": MockUser("Alice", "*****@*****.**") } ( num_commits, authors, num_authors, last_time, ) = tasks.commits_author_stats(self.repopath) self.assertEqual(num_commits, 2) self.assertEqual(num_authors, 1) self.assertEqual(last_time, "2018-01-01 00:00") self.assertIn( authors, [ [( 2, [( "Alice", "*****@*****.**", "https://seccdn.libravatar.org/avatar/" "ff8d9819fc0e12bf0d24892e45987e249a28dce836a85cad60e28eaaa8c6d976" "?s=32&d=retro", )], )], [( 2, [( "Alice", "*****@*****.**", "https://seccdn.libravatar.org/avatar/" "ff8d9819fc0e12bf0d24892e45987e249a28dce836a85cad60e28eaaa8c6d976" "?d=retro&s=32", )], )], ], )
def test_handle_empty_email(self): self.commits = [ # Two commits for Alice to ensure order of the result. MockCommit("Alice", None), MockCommit("Alice", None), MockCommit("Bob", "", "2018-01-01 00:00"), ] self.authors = {} num_commits, authors, num_authors, last_time = tasks.commits_author_stats( self.repopath ) self.assertEqual(num_commits, 3) self.assertEqual(num_authors, 2) self.assertEqual(last_time, "2018-01-01 00:00") self.assertEqual( authors, [(2, [("Alice", None, None)]), (1, [("Bob", "", None)])] )
def test_preserve_unknown_author(self): self.commits = [ MockCommit("Alice", "*****@*****.**", "2018-01-01 00:00") ] self.authors = {} ( num_commits, authors, num_authors, last_time, ) = tasks.commits_author_stats(self.repopath) self.assertEqual(num_commits, 1) self.assertEqual(num_authors, 1) self.assertEqual(last_time, "2018-01-01 00:00") self.assertIn( authors, [ [( 1, [( "Alice", "*****@*****.**", "https://seccdn.libravatar.org/avatar/" "ff8d9819fc0e12bf0d24892e45987e249a28dce836a85cad60e28eaaa8c6d976" "?s=32&d=retro", )], )], [( 1, [( "Alice", "*****@*****.**", "https://seccdn.libravatar.org/avatar/" "ff8d9819fc0e12bf0d24892e45987e249a28dce836a85cad60e28eaaa8c6d976" "?d=retro&s=32", )], )], ], )
def test_handle_empty_email(self): self.commits = [ # Two commits for Alice to ensure order of the result. MockCommit("Alice", None), MockCommit("Alice", None), MockCommit("Bob", "", "2018-01-01 00:00"), ] self.authors = {} ( num_commits, authors, num_authors, last_time, ) = tasks.commits_author_stats(self.repopath) self.assertEqual(num_commits, 3) self.assertEqual(num_authors, 2) self.assertEqual(last_time, "2018-01-01 00:00") self.assertEqual(authors, [(2, [("Alice", None, None)]), (1, [("Bob", "", None)])])