Vijay VK | 339ca1c | 2018-03-27 02:05:36 +0100 | [diff] [blame] | 1 | import pytest |
| 2 | import unittest |
| 3 | import trapd_exit |
| 4 | |
| 5 | pid_file="/tmp/test_pid_file" |
| 6 | pid_file_dne="/tmp/test_pid_file_NOT" |
| 7 | |
| 8 | import trapd_settings as tds |
Vijay VK | 339ca1c | 2018-03-27 02:05:36 +0100 | [diff] [blame] | 9 | |
| 10 | class test_cleanup_and_exit(unittest.TestCase): |
| 11 | """ |
| 12 | Test for presense of required vars |
| 13 | """ |
| 14 | |
| 15 | |
| 16 | def test_nonexistent_dict(self): |
| 17 | """ |
| 18 | Test nosuch var |
| 19 | """ |
| 20 | tds.init() |
| 21 | try: |
| 22 | tds.no_such_var |
| 23 | result = True |
| 24 | except: |
| 25 | result = False |
| 26 | |
| 27 | self.assertEqual(result, False) |
| 28 | |
| 29 | def test_config_dict(self): |
| 30 | """ |
| 31 | Test config dict |
| 32 | """ |
| 33 | tds.init() |
| 34 | try: |
| 35 | tds.c_config |
| 36 | result = True |
| 37 | except: |
| 38 | result = False |
| 39 | |
| 40 | self.assertEqual(result, True) |
| 41 | |
| 42 | def test_dns_cache_ip_to_name(self): |
| 43 | """ |
| 44 | Test dns cache name dict |
| 45 | """ |
| 46 | |
| 47 | tds.init() |
| 48 | try: |
| 49 | tds.dns_cache_ip_to_name |
| 50 | result = True |
| 51 | except: |
| 52 | result = False |
| 53 | |
| 54 | self.assertEqual(result, True) |
| 55 | |
| 56 | def test_dns_cache_ip_expires(self): |
| 57 | """ |
| 58 | Test dns cache ip expires dict |
| 59 | """ |
| 60 | |
| 61 | tds.init() |
| 62 | try: |
| 63 | tds.dns_cache_ip_expires |
| 64 | result = True |
| 65 | except: |
| 66 | result = False |
| 67 | |
| 68 | self.assertEqual(result, True) |
| 69 | |
| 70 | if __name__ == '__main__': |
| 71 | # tds.init() |
| 72 | unittest.main() |