Scott Baker | bcbd4cc | 2018-03-07 13:50:21 -0800 | [diff] [blame] | 1 | # 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 | |
| 15 | import os |
| 16 | import unittest |
| 17 | |
| 18 | from xosutil import autodiscover_version |
| 19 | |
| 20 | test_path = os.path.abspath(os.path.dirname(os.path.realpath(__file__))) |
| 21 | |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame^] | 22 | |
Scott Baker | bcbd4cc | 2018-03-07 13:50:21 -0800 | [diff] [blame] | 23 | class 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 Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame^] | 43 | self.assertEqual( |
| 44 | version, |
| 45 | autodiscover_version.autodiscover_version_of_caller( |
| 46 | save_to="test_version.py" |
| 47 | ), |
| 48 | ) |
Scott Baker | bcbd4cc | 2018-03-07 13:50:21 -0800 | [diff] [blame] | 49 | self.assertTrue(os.path.exists(test_save_fn)) |
| 50 | self.assertTrue(version in open(test_save_fn).read()) |
| 51 | |
Zack Williams | 045b63d | 2019-01-22 16:30:57 -0700 | [diff] [blame^] | 52 | |
Scott Baker | bcbd4cc | 2018-03-07 13:50:21 -0800 | [diff] [blame] | 53 | if __name__ == "__main__": |
| 54 | unittest.main() |