-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_howisresolved.py
51 lines (36 loc) · 1.41 KB
/
test_howisresolved.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python
import os
#from unittest.mock import patch
import pytest
import howisresolved
def test_setup_logging():
""" test logging.json configuration """
assert howisresolved.setup_logging() is True
def test_setup_logging_missing():
""" test missing logging.json configuration """
with pytest.raises(SystemExit) as err:
howisresolved.setup_logging(filepath="logging.test")
assert 'Create logging.json config file and restart.' in str(err.value)
def test_download_publicdns():
""" test download publicdns list """
dnsfile = './dnslist.test'
assert howisresolved.download_publicdns(dnsfile) is None
os.remove(dnsfile)
# def test_download_publicdns_mocked():
# """ test download publicdns list """
# dnsfile = './dnslist.test'
# with patch('requests.get') as mocked_get:
# print(mocked_get)
# mocked_get.return_value.ok = True
# mocked_get.return_value.text = 'Success'
# data = 'https://public-dns.info/nameservers.txt'
# mocked_get.assert_called_with(data)
# assert (data == 'https://public-dns.info/nameservers.txt') is True
# mocked_get.return_value.ok = False
# data = dnsfile
# mocked_get.assert_called_with(
# 'https://public-dns.info/nameservers.txt')
# assert (data) == 'Connnection Error'
# #os.remove(dnsfile)
if __name__ == '__main__':
pytest.main()