This repository was archived by the owner on Nov 22, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments