Build API: Add version fetching endpoint.

BUG=chromium:979814
TEST=ran endpoint manually

Change-Id: Ifd400e6d7f92286f8313927fa5200e011a1fa395
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1682829
Commit-Queue: Alex Klein <saklein@chromium.org>
Tested-by: Alex Klein <saklein@chromium.org>
Reviewed-by: Evan Hernandez <evanhernandez@chromium.org>
Auto-Submit: Alex Klein <saklein@chromium.org>
diff --git a/api/controller/api_unittest.py b/api/controller/api_unittest.py
new file mode 100644
index 0000000..63d136c
--- /dev/null
+++ b/api/controller/api_unittest.py
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+# Copyright 2019 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""API controller tests."""
+
+from __future__ import print_function
+
+from chromite.api import router
+from chromite.api.controller import api as api_controller
+from chromite.api.gen.chromite.api import api_pb2
+from chromite.lib import cros_test_lib
+
+
+class GetMethodsTest(cros_test_lib.MockTestCase):
+  """GetMethods tests."""
+
+  def testGetMethods(self):
+    """Simple GetMethods sanity check."""
+    methods = ['foo', 'bar']
+    self.PatchObject(router.Router, 'ListMethods', return_value=methods)
+
+    request = api_pb2.MethodGetRequest()
+    response = api_pb2.MethodGetResponse()
+
+    api_controller.GetMethods(request, response)
+
+    self.assertItemsEqual(methods, [m.method for m in response.methods])
+
+
+class GetVersionTest(cros_test_lib.MockTestCase):
+  """GetVersion tests."""
+
+  def testGetVersion(self):
+    """Simple GetVersion sanity check."""
+    self.PatchObject(api_controller, 'VERSION_MAJOR', new=1)
+    self.PatchObject(api_controller, 'VERSION_MINOR', new=2)
+    self.PatchObject(api_controller, 'VERSION_BUG', new=3)
+
+    request = api_pb2.VersionGetRequest()
+    response = api_pb2.VersionGetResponse()
+
+    api_controller.GetVersion(request, response)
+
+    self.assertEqual(response.version.major, 1)
+    self.assertEqual(response.version.minor, 2)
+    self.assertEqual(response.version.bug, 3)