From 08989071e8c47bb75f3a5f171d821b805380baef Mon Sep 17 00:00:00 2001 From: Athos Ribeiro Date: Fri, 23 Oct 2020 12:00:17 +0200 Subject: Fix default actor name handling In c96476b, the new default_name nested function does not contain a retun statement. This leads to an issue when the environment variables are not present, where the actor name would not be set. Signed-off-by: Athos Ribeiro --- test/test_util.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'test/test_util.py') diff --git a/test/test_util.py b/test/test_util.py index 2f946891..5eba6c50 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -226,15 +226,25 @@ class TestUtils(TestBase): } os.environ.update(env) for cr in (None, self.rorepo.config_reader()): - Actor.committer(cr) - Actor.author(cr) + committer = Actor.committer(cr) + author = Actor.author(cr) + self.assertEqual(committer.name, 'Jane Doe') + self.assertEqual(committer.email, 'jane@example.com') + self.assertEqual(author.name, 'John Doe') + self.assertEqual(author.email, 'jdoe@example.com') self.assertFalse(mock_get_uid.called) @mock.patch("getpass.getuser") def test_actor_get_uid_laziness_called(self, mock_get_uid): + mock_get_uid.return_value = "user" for cr in (None, self.rorepo.config_reader()): - Actor.committer(cr) - Actor.author(cr) + committer = Actor.committer(cr) + author = Actor.author(cr) + if cr is None: # otherwise, use value from config_reader + self.assertEqual(committer.name, 'user') + self.assertTrue(committer.email.startswith('user@')) + self.assertEqual(author.name, 'user') + self.assertTrue(committer.email.startswith('user@')) self.assertTrue(mock_get_uid.called) self.assertEqual(mock_get_uid.call_count, 4) -- cgit v1.2.1