blob: 2b5be07dbdebd1f4b2bfa108e2e036f6b730a0f1 [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
15import os
16import unittest
17
18from xosutil import autodiscover_version
19
20test_path = os.path.abspath(os.path.dirname(os.path.realpath(__file__)))
21
Zack Williams045b63d2019-01-22 16:30:57 -070022
Scott Bakerbcbd4cc2018-03-07 13:50:21 -080023class XOSUtilTest(unittest.TestCase):
24 """
25 Testing the XOS Util Module
26 """
27
28 def setUp(self):
29 pass
30
31 def tearDown(self):
32 pass
33
34 def test_autodiscover_version_of_caller(self):
35 version = open(os.path.join(test_path, "../../../VERSION")).readline().strip()
36 self.assertEqual(version, autodiscover_version.autodiscover_version_of_caller())
37
38 def test_autodiscover_version_of_caller_save_to(self):
39 version = open(os.path.join(test_path, "../../../VERSION")).readline().strip()
40 test_save_fn = os.path.join(test_path, "test_version.py")
41 if os.path.exists(test_save_fn):
42 os.remove(test_save_fn)
Zack Williams045b63d2019-01-22 16:30:57 -070043 self.assertEqual(
44 version,
45 autodiscover_version.autodiscover_version_of_caller(
46 save_to="test_version.py"
47 ),
48 )
Scott Bakerbcbd4cc2018-03-07 13:50:21 -080049 self.assertTrue(os.path.exists(test_save_fn))
50 self.assertTrue(version in open(test_save_fn).read())
51
Zack Williams045b63d2019-01-22 16:30:57 -070052
Scott Bakerbcbd4cc2018-03-07 13:50:21 -080053if __name__ == "__main__":
54 unittest.main()