Repository: dwavesystems/dwave-cloud-client

Issue:
User-Agent is missing dwave-cloud-client version
The bug was introduced in 331c37b67, and released in [0.7.5](https://github.com/dwavesystems/dwave-cloud-client/compare/0.7.4...0.7.5), so it affects 0.7.5 and 0.7.6.

Discussion:

Patch:
diff --git a/dwave/cloud/utils.py b/dwave/cloud/utils.py
index fbc82ad..41a026c 100644
--- a/dwave/cloud/utils.py
+++ b/dwave/cloud/utils.py
@@ -321,13 +321,13 @@ def user_agent(name=None, version=None):
     if name and version:
         tags.append((name, version))
 
-    tags = [
+    tags.extend([
         ("python", platform.python_version()),
         _interpreter(),
         ("machine", platform.machine() or 'unknown'),
         ("system", platform.system() or 'unknown'),
         ("platform", platform.platform() or 'unknown'),
-    ]
+    ])
 
     # add platform-specific tags
     tags.extend(get_platform_tags())


Test patch:
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 162456b..887f6e1 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -348,6 +348,19 @@ class TestCli(unittest.TestCase):
 
         self.assertEqual(result.exit_code, 0)
 
+    def test_platform(self):
+        runner = CliRunner()
+        result = runner.invoke(cli, ['--platform'])
+
+        # verify exit code and stdout printout
+        self.assertEqual(result.exit_code, 0)
+
+        from dwave.cloud.package_info import __packagename__, __version__
+        self.assertNotIn(__packagename__, result.output)
+        required = ['python', 'machine', 'system', 'platform']
+        for key in required:
+            self.assertIn(key, result.output)
+
 
 if __name__ == '__main__':
     unittest.main()
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 1ea5bda..2ec424f 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -22,7 +22,8 @@ from datetime import datetime
 from dwave.cloud.utils import (
     uniform_iterator, uniform_get, strip_head, strip_tail,
     active_qubits, generate_random_ising_problem,
-    default_text_input, utcnow, cached, retried, parse_loglevel)
+    default_text_input, utcnow, cached, retried, parse_loglevel,
+    user_agent)
 
 
 class TestSimpleUtils(unittest.TestCase):
@@ -138,6 +139,14 @@ class TestSimpleUtils(unittest.TestCase):
         self.assertEqual(parse_loglevel(str(logging.INFO)), logging.INFO)
         self.assertEqual(parse_loglevel('  %d  ' % logging.INFO), logging.INFO)
 
+    def test_user_agent(self):
+        from dwave.cloud.package_info import __packagename__, __version__
+        ua = user_agent(__packagename__, __version__)
+
+        required = [__packagename__, 'python', 'machine', 'system', 'platform']
+        for key in required:
+            self.assertIn(key, ua)
+
 
 class TestCachedDecorator(unittest.TestCase):