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

Commit 91bd97d

Browse files
committed
corrected missing tests; added debug test - useful for coverage
1 parent 25c981a commit 91bd97d

File tree

3 files changed

+38
-13
lines changed

3 files changed

+38
-13
lines changed

tests/test_cloudflare_calls.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,49 @@
2020

2121
def test_cloudflare():
2222
global cf
23+
cf = None
2324
cf = CloudFlare.CloudFlare()
2425
assert isinstance(cf, CloudFlare.CloudFlare)
2526

26-
def test_ips():
27+
def test_ips1():
2728
ips = cf.ips()
2829
assert isinstance(ips, dict)
2930
assert len(ips) > 0
3031

3132
def test_cloudflare_debug():
3233
global cf
34+
cf = None
3335
cf = CloudFlare.CloudFlare(debug=True)
3436
assert isinstance(cf, CloudFlare.CloudFlare)
3537

36-
def test_ips():
38+
def test_ips2():
3739
ips = cf.ips()
3840
assert isinstance(ips, dict)
3941
assert len(ips) > 0
4042

4143
def test_cloudflare_raw():
4244
global cf
45+
cf = None
4346
cf = CloudFlare.CloudFlare(raw=False)
4447
assert isinstance(cf, CloudFlare.CloudFlare)
4548

46-
def test_ips():
49+
def test_ips3():
4750
ips = cf.ips()
4851
assert isinstance(ips, dict)
4952
assert len(ips) > 0
5053

5154
def test_cloudflare_no_sessions():
5255
global cf
56+
cf = None
5357
cf = CloudFlare.CloudFlare(use_sessions=False)
5458
assert isinstance(cf, CloudFlare.CloudFlare)
5559

56-
def test_ips():
60+
def test_ips4():
5761
ips = cf.ips()
5862
assert isinstance(ips, dict)
5963
assert len(ips) > 0
6064

61-
def test_ips():
65+
def test_ips5():
6266
ips = cf.ips()
6367
assert isinstance(ips, dict)
6468
assert len(ips) > 0

tests/test_dns_import_export.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ def test_cloudflare():
1818
cf = CloudFlare.CloudFlare()
1919
assert isinstance(cf, CloudFlare.CloudFlare)
2020

21-
dns_name = None
22-
dns_id = None
23-
2421
def test_find_zone():
2522
global zone_name, zone_id
2623
# grab the first zone identifier
@@ -49,3 +46,27 @@ def test_dns_export():
4946
assert isinstance(dns_records, str)
5047
assert 'SOA' in dns_records
5148
assert 'NS' in dns_records
49+
50+
def test_cloudflare_with_debug():
51+
global cf
52+
cf = None
53+
cf = CloudFlare.CloudFlare(debug=True)
54+
assert isinstance(cf, CloudFlare.CloudFlare)
55+
56+
def test_dns_import_with_debug():
57+
# IMPORT
58+
fd = open('/dev/null', 'rb')
59+
results = cf.zones.dns_records.import_.post(zone_id, files={'file':fd})
60+
# {"recs_added": 0, "recs_added_by_type": {}, "total_records_parsed": 0}
61+
assert len(results) > 0
62+
assert results['recs_added'] == 0
63+
assert len(results['recs_added_by_type']) == 0
64+
assert results['total_records_parsed'] == 0
65+
66+
def test_dns_export_with_debug():
67+
# EXPORT
68+
dns_records = cf.zones.dns_records.export.get(zone_id)
69+
assert len(dns_records) > 0
70+
assert isinstance(dns_records, str)
71+
assert 'SOA' in dns_records
72+
assert 'NS' in dns_records

tests/test_dns_records.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_dns_records():
4444
dns_content3 = 'temp pytest element 3'
4545
print('dns_record: %s' % (dns_name))
4646

47-
def test_dns_records_get():
47+
def test_dns_records_get1():
4848
# GET
4949
params = {'name':dns_name + '.' + zone_name, 'match':'all', 'type':dns_type}
5050
dns_results = cf.zones.dns_records.get(zone_id, params=params)
@@ -65,7 +65,7 @@ def test_dns_records_post():
6565
assert len(dns_id) == 32
6666
print('dns_record: %s %s' % (dns_name, dns_id))
6767

68-
def test_dns_records_get():
68+
def test_dns_records_get2():
6969
# GET
7070
params = {'name':dns_name + '.' + zone_name, 'match':'all', 'type':dns_type}
7171
dns_results = cf.zones.dns_records.get(zone_id, params=params)
@@ -74,7 +74,7 @@ def test_dns_records_get():
7474
assert dns_results[0]['type'] == dns_type
7575
assert dns_results[0]['content'] == dns_content1
7676

77-
def test_dns_records_get():
77+
def test_dns_records_get3():
7878
# GET
7979
dns_result = cf.zones.dns_records.get(zone_id, dns_id)
8080
assert dns_result['name'] == dns_name + '.' + zone_name
@@ -97,7 +97,7 @@ def test_dns_records_put():
9797
assert dns_result['type'] == dns_type
9898
assert dns_result['content'] == dns_content3
9999

100-
def test_dns_records_get():
100+
def test_dns_records_get4():
101101
# GET
102102
dns_result = cf.zones.dns_records.get(zone_id, dns_id)
103103
assert dns_result['name'] == dns_name + '.' + zone_name
@@ -109,7 +109,7 @@ def test_dns_records_delete():
109109
dns_result = cf.zones.dns_records.delete(zone_id, dns_id)
110110
assert dns_result['id'] == dns_id
111111

112-
def test_dns_records_get():
112+
def test_dns_records_get5():
113113
# GET
114114
params = {'name':dns_name + '.' + zone_name, 'match':'all', 'type':dns_type}
115115
dns_results = cf.zones.dns_records.get(zone_id, params=params)

0 commit comments

Comments
 (0)