blob: f4c0d3a1720b8712b3c2d7b58bf383d7c903a7cc [file] [log] [blame]
Scott Bakerbcbd4cc2018-03-07 13:50:21 -08001# Copyright 2017-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
Zack Williams9a42f872019-02-15 17:56:04 -070015from __future__ import absolute_import
16
Scott Bakerbcbd4cc2018-03-07 13:50:21 -080017import os
18import unittest
19
20from xosutil import autodiscover_version
21
22test_path = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
23
Zack Williams045b63d2019-01-22 16:30:57 -070024
Scott Bakerbcbd4cc2018-03-07 13:50:21 -080025class XOSUtilTest(unittest.TestCase):
26 """
27 Testing the XOS Util Module
28 """
29
30 def setUp(self):
31 pass
32
33 def tearDown(self):
34 pass
35
36 def test_autodiscover_version_of_caller(self):
37 version = open(os.path.join(test_path, "../../../VERSION")).readline().strip()
38 self.assertEqual(version, autodiscover_version.autodiscover_version_of_caller())
39
40 def test_autodiscover_version_of_caller_save_to(self):
41 version = open(os.path.join(test_path, "../../../VERSION")).readline().strip()
42 test_save_fn = os.path.join(test_path, "test_version.py")
43 if os.path.exists(test_save_fn):
44 os.remove(test_save_fn)
Zack Williams045b63d2019-01-22 16:30:57 -070045 self.assertEqual(
46 version,
47 autodiscover_version.autodiscover_version_of_caller(
48 save_to="test_version.py"
49 ),
50 )
Scott Bakerbcbd4cc2018-03-07 13:50:21 -080051 self.assertTrue(os.path.exists(test_save_fn))
52 self.assertTrue(version in open(test_save_fn).read())
53
Zack Williams045b63d2019-01-22 16:30:57 -070054
Scott Bakerbcbd4cc2018-03-07 13:50:21 -080055if __name__ == "__main__":
56 unittest.main()