scripts: add virtualenv_wrapper

BUG=chromium:645611
TEST=~/chromiumos/chromite/bin$ ./venv_check -> succeeds and prints the
correct import path. Also succeeds when run from other cwds.

Change-Id: I981ed7d25457381688915171c04a249457a219b5
Reviewed-on: https://chromium-review.googlesource.com/388773
Commit-Ready: Aviv Keshet <akeshet@chromium.org>
Tested-by: Aviv Keshet <akeshet@chromium.org>
Reviewed-by: Paul Hobbs <phobbs@google.com>
diff --git a/scripts/virtualenv_wrapper_unittest.py b/scripts/virtualenv_wrapper_unittest.py
new file mode 100644
index 0000000..9511ce4
--- /dev/null
+++ b/scripts/virtualenv_wrapper_unittest.py
@@ -0,0 +1,26 @@
+# Copyright 2016 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.
+
+"""Unittests for virtualenv_wrapper"""
+
+from __future__ import print_function
+
+import os
+import six
+import sys
+
+from chromite.lib import cros_test_lib
+
+class VirtualEnvTest(cros_test_lib.TestCase):
+  """Test that we are running in a virtualenv."""
+
+  def testModuleIsFromVenv(self):
+    """Test that the |six| module was provided by virtualenv."""
+    # Note: The |six| module is chosen somewhat arbitrarily, but it happens to
+    # be provided inside the chromite virtualenv.
+    req_path = os.path.dirname(os.path.realpath(six.__file__))
+    my_path = os.path.dirname(os.path.realpath(__file__))
+    expected_venv_path = os.path.realpath(
+        os.path.join(my_path, '..', 'venv', 'venv'))
+    self.assertIn(expected_venv_path, req_path)