From 71b0f312b15b597ab54d4d3bd6629efdcf188884 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 30 Sep 2019 22:39:49 -0400 Subject: git_command: refactor User-Agent settings Convert the RepoUserAgent function into a UserAgent class. This makes it cleaner to hold internal state, and will make it easier to add a separate git User-Agent, although we don't do it here. We make the RepoSourceVersion independent of GitCommand so that it can be called by the class (later). Bug: https://crbug.com/gerrit/11144 Change-Id: Iab4e1f974b8733a36b243b2d03f5085a96effa19 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/239232 Reviewed-by: David Pursehouse Tested-by: Mike Frysinger --- tests/test_git_command.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'tests/test_git_command.py') diff --git a/tests/test_git_command.py b/tests/test_git_command.py index 4d65d3ce..5ceb0b33 100644 --- a/tests/test_git_command.py +++ b/tests/test_git_command.py @@ -50,12 +50,20 @@ class GitCallUnitTest(unittest.TestCase): self.assertNotEqual('', ver.full) -class RepoUserAgentUnitTest(unittest.TestCase): - """Tests the RepoUserAgent function.""" +class UserAgentUnitTest(unittest.TestCase): + """Tests the UserAgent function.""" - def test_smoke(self): - """Make sure it returns something useful.""" - ua = git_command.RepoUserAgent() + def test_smoke_os(self): + """Make sure UA OS setting returns something useful.""" + os_name = git_command.user_agent.os + # We can't dive too deep because of OS/tool differences, but we can check + # the general form. + m = re.match(r'^[^ ]+$', os_name) + self.assertIsNotNone(m) + + def test_smoke_repo(self): + """Make sure repo UA returns something useful.""" + ua = git_command.user_agent.repo # We can't dive too deep because of OS/tool differences, but we can check # the general form. m = re.match(r'^git-repo/[^ ]+ ([^ ]+) git/[^ ]+ Python/[0-9.]+', ua) -- cgit v1.2.3-54-g00ecf