Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 5a314b1

Browse files
committed
CloudFlare/tests/test_find.py
1 parent 4a8c255 commit 5a314b1

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

CloudFlare/tests/test_find.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
""" find api tests """
2+
3+
import os
4+
import sys
5+
6+
sys.path.insert(0, os.path.abspath('.'))
7+
sys.path.insert(0, os.path.abspath('..'))
8+
import CloudFlare
9+
10+
# test API list fetches from Cloudflare website
11+
12+
cf = None
13+
14+
def test_cloudflare(debug=False):
15+
""" test_cloudflare """
16+
global cf
17+
cf = CloudFlare.CloudFlare(debug=debug)
18+
assert isinstance(cf, CloudFlare.CloudFlare)
19+
20+
def test_find():
21+
""" test_find """
22+
ips_call = cf.find('/ips')
23+
assert True
24+
25+
def test_find_call():
26+
""" test_find """
27+
ips_call = cf.find('/ips')
28+
ips = ips_call()
29+
assert isinstance(ips, dict)
30+
assert isinstance(ips['ipv4_cidrs'], list)
31+
assert isinstance(ips['ipv6_cidrs'], list)
32+
assert len(ips['ipv4_cidrs']) > 0
33+
assert len(ips['ipv6_cidrs']) > 0
34+
35+
def test_find_invalid():
36+
""" test_find """
37+
try:
38+
invalid_endpoint_call = cf.find('/invalid-endpoint')
39+
print('error - should not reach here', file=sys.stderr)
40+
assert False
41+
except AttributeError as e:
42+
assert True
43+
44+
if __name__ == '__main__':
45+
test_cloudflare(debug=True)
46+
test_find()
47+
test_find_call()
48+
test_find_invalid()

0 commit comments

Comments
 (0)