CORD-2741 implement VERSION file discovery for xos python libraries

Change-Id: Ife67b0066d5fd54958e1b1de3c5b3758ac9d3ca6
diff --git a/lib/xos-util/tests/test_util.py b/lib/xos-util/tests/test_util.py
new file mode 100644
index 0000000..ff1ce58
--- /dev/null
+++ b/lib/xos-util/tests/test_util.py
@@ -0,0 +1,48 @@
+
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os
+import unittest
+
+from xosutil import autodiscover_version
+
+test_path = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
+
+class XOSUtilTest(unittest.TestCase):
+    """
+    Testing the XOS Util Module
+    """
+
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        pass
+
+    def test_autodiscover_version_of_caller(self):
+        version = open(os.path.join(test_path, "../../../VERSION")).readline().strip()
+        self.assertEqual(version, autodiscover_version.autodiscover_version_of_caller())
+
+    def test_autodiscover_version_of_caller_save_to(self):
+        version = open(os.path.join(test_path, "../../../VERSION")).readline().strip()
+        test_save_fn = os.path.join(test_path, "test_version.py")
+        if os.path.exists(test_save_fn):
+            os.remove(test_save_fn)
+        self.assertEqual(version, autodiscover_version.autodiscover_version_of_caller(save_to="test_version.py"))
+        self.assertTrue(os.path.exists(test_save_fn))
+        self.assertTrue(version in open(test_save_fn).read())
+
+if __name__ == "__main__":
+    unittest.main()