Ladue, David (dl3158) | 9c9a86f | 2020-02-14 12:02:30 -0500 | [diff] [blame] | 1 | # ============LICENSE_START======================================================= |
| 2 | # Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved. |
| 3 | # ================================================================================ |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # ============LICENSE_END========================================================= |
| 16 | |
Vijay VK | 339ca1c | 2018-03-27 02:05:36 +0100 | [diff] [blame] | 17 | import pytest |
| 18 | import unittest |
| 19 | import trapd_exit |
| 20 | |
| 21 | pid_file="/tmp/test_pid_file" |
| 22 | pid_file_dne="/tmp/test_pid_file_NOT" |
| 23 | |
| 24 | import trapd_settings as tds |
Vijay VK | 339ca1c | 2018-03-27 02:05:36 +0100 | [diff] [blame] | 25 | |
| 26 | class test_cleanup_and_exit(unittest.TestCase): |
| 27 | """ |
| 28 | Test for presense of required vars |
| 29 | """ |
| 30 | |
| 31 | |
| 32 | def test_nonexistent_dict(self): |
| 33 | """ |
| 34 | Test nosuch var |
| 35 | """ |
| 36 | tds.init() |
| 37 | try: |
| 38 | tds.no_such_var |
| 39 | result = True |
| 40 | except: |
| 41 | result = False |
| 42 | |
| 43 | self.assertEqual(result, False) |
| 44 | |
| 45 | def test_config_dict(self): |
| 46 | """ |
| 47 | Test config dict |
| 48 | """ |
| 49 | tds.init() |
| 50 | try: |
| 51 | tds.c_config |
| 52 | result = True |
| 53 | except: |
| 54 | result = False |
| 55 | |
| 56 | self.assertEqual(result, True) |
| 57 | |
| 58 | def test_dns_cache_ip_to_name(self): |
| 59 | """ |
| 60 | Test dns cache name dict |
| 61 | """ |
| 62 | |
| 63 | tds.init() |
| 64 | try: |
| 65 | tds.dns_cache_ip_to_name |
| 66 | result = True |
| 67 | except: |
| 68 | result = False |
| 69 | |
| 70 | self.assertEqual(result, True) |
| 71 | |
| 72 | def test_dns_cache_ip_expires(self): |
| 73 | """ |
| 74 | Test dns cache ip expires dict |
| 75 | """ |
| 76 | |
| 77 | tds.init() |
| 78 | try: |
| 79 | tds.dns_cache_ip_expires |
| 80 | result = True |
| 81 | except: |
| 82 | result = False |
| 83 | |
| 84 | self.assertEqual(result, True) |
| 85 | |
| 86 | if __name__ == '__main__': |
| 87 | # tds.init() |
| 88 | unittest.main() |