summaryrefslogtreecommitdiffstats
path: root/tests/test_git_command.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2019-09-30 22:39:49 -0400
committerMike Frysinger <vapier@google.com>2019-10-01 05:40:28 +0000
commit71b0f312b15b597ab54d4d3bd6629efdcf188884 (patch)
treeb02a38b231c6e7e94776706d08670bc66db14ddf /tests/test_git_command.py
parent369814b4a77adcc78b2549ad728e0d69175f08e8 (diff)
downloadgit-repo-71b0f312b15b597ab54d4d3bd6629efdcf188884.tar.gz
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 <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'tests/test_git_command.py')
-rw-r--r--tests/test_git_command.py18
1 files changed, 13 insertions, 5 deletions
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):
50 self.assertNotEqual('', ver.full) 50 self.assertNotEqual('', ver.full)
51 51
52 52
53class RepoUserAgentUnitTest(unittest.TestCase): 53class UserAgentUnitTest(unittest.TestCase):
54 """Tests the RepoUserAgent function.""" 54 """Tests the UserAgent function."""
55 55
56 def test_smoke(self): 56 def test_smoke_os(self):
57 """Make sure it returns something useful.""" 57 """Make sure UA OS setting returns something useful."""
58 ua = git_command.RepoUserAgent() 58 os_name = git_command.user_agent.os
59 # We can't dive too deep because of OS/tool differences, but we can check
60 # the general form.
61 m = re.match(r'^[^ ]+$', os_name)
62 self.assertIsNotNone(m)
63
64 def test_smoke_repo(self):
65 """Make sure repo UA returns something useful."""
66 ua = git_command.user_agent.repo
59 # We can't dive too deep because of OS/tool differences, but we can check 67 # We can't dive too deep because of OS/tool differences, but we can check
60 # the general form. 68 # the general form.
61 m = re.match(r'^git-repo/[^ ]+ ([^ ]+) git/[^ ]+ Python/[0-9.]+', ua) 69 m = re.match(r'^git-repo/[^ ]+ ([^ ]+) git/[^ ]+ Python/[0-9.]+', ua)