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

Commit dbec555

Browse files
committed
added lots of %s %r tests
1 parent e44bf75 commit dbec555

File tree

1 file changed

+62
-5
lines changed

1 file changed

+62
-5
lines changed

CloudFlare/tests/test_cloudflare_calls.py

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,82 +12,129 @@
1212
cf = None
1313

1414
def test_cloudflare():
15+
""" test_cloudflare """
1516
global cf
1617
cf = CloudFlare.CloudFlare()
1718
assert isinstance(cf, CloudFlare.CloudFlare)
1819

1920
def test_percent_s():
20-
21+
""" test_percent_s """
2122
s = '%s' % cf
2223
assert len(s) > 0 and isinstance(s, str)
24+
25+
def test_percent_r():
26+
""" test_percent_r """
2327
s = '%r' % cf
2428
assert len(s) > 0 and isinstance(s, str)
2529

30+
def test_percent_ips_s():
31+
""" test_percent_ips_s """
32+
s = '%s' % cf.ips
33+
assert len(s) > 0 and isinstance(s, str)
34+
35+
def test_percent_ips_r():
36+
""" test_percent_ips_r """
37+
s = '%r' % cf.ips
38+
assert len(s) > 0 and isinstance(s, str)
39+
40+
def test_percent_cf_accounts_billing_s():
41+
""" test_percent_cf_accounts_billing_s """
42+
s = '%s' % cf.accounts.billing
43+
assert len(s) > 0 and isinstance(s, str)
44+
45+
def test_percent_cf_accounts_billing_r():
46+
""" test_percent_cf_accounts_billing_r """
47+
s = '%r' % cf.accounts.billing
48+
assert len(s) > 0 and isinstance(s, str)
49+
50+
def test_percent_cf_zones_waiting_rooms_events_details_s():
51+
""" test_percent_cf_accounts_billing_s """
52+
s = '%s' % cf.zones.waiting_rooms.events.details
53+
assert len(s) > 0 and isinstance(s, str)
54+
55+
def test_percent_cf_zones_waiting_rooms_events_details_r():
56+
""" test_percent_cf_accounts_billing_r """
57+
s = '%r' % cf.zones.waiting_rooms.events.details
58+
assert len(s) > 0 and isinstance(s, str)
59+
2660
def test_ips1():
61+
""" test_ips1 """
2762
ips = cf.ips()
2863
assert isinstance(ips, dict)
2964
assert len(ips) > 0
3065

3166
def test_cloudflare_debug():
67+
""" test_cloudflare_debug """
3268
global cf
3369
cf = CloudFlare.CloudFlare(debug=True)
3470
assert isinstance(cf, CloudFlare.CloudFlare)
3571

3672
def test_ips2():
73+
""" test_ips2 """
3774
ips = cf.ips()
3875
assert isinstance(ips, dict)
3976
assert len(ips) > 0
4077

4178
def test_cloudflare_raw():
79+
""" test_cloudflare_raw """
4280
global cf
4381
cf = CloudFlare.CloudFlare(raw=False)
4482
assert isinstance(cf, CloudFlare.CloudFlare)
4583

4684
def test_ips3():
85+
""" test_ips3 """
4786
ips = cf.ips()
4887
assert isinstance(ips, dict)
4988
assert len(ips) > 0
5089

5190
def test_cloudflare_no_sessions():
91+
""" test_cloudflare_no_sessions """
5292
global cf
5393
cf = CloudFlare.CloudFlare(use_sessions=False)
5494
assert isinstance(cf, CloudFlare.CloudFlare)
5595

5696
def test_ips4():
97+
""" test_ips4 """
5798
ips = cf.ips()
5899
assert isinstance(ips, dict)
59100
assert len(ips) > 0
60101

61102
def test_ips5():
103+
""" test_ips5 """
62104
ips = cf.ips()
63105
assert isinstance(ips, dict)
64106
assert len(ips) > 0
65107

66108
def test_cloudflare_url_invalid():
109+
""" test_cloudflare_url_invalid """
67110
global cf
68111
cf = CloudFlare.CloudFlare(base_url='blah blah blah blah ...')
69112
# this does not fail yet - so we wait
70113

71114
def test_ips6_should_fail():
115+
""" test_ips6_should_fail """
72116
try:
73117
ips = cf.ips()
74118
except CloudFlare.exceptions.CloudFlareAPIError as e:
75-
print('Error expected: %d %s' % (e, e), file=sys.stderr)
119+
print('Error expected: %d %s' % (int(e), str(e)), file=sys.stderr)
76120
pass
77121

78122
def test_cloudflare_url_wrong():
123+
""" test_cloudflare_url_wrong """
79124
global cf
80125
cf = CloudFlare.CloudFlare(base_url='http://example.com/')
81126
# this does not fail yet - so we wait
82127

83128
def test_ips7_should_fail():
129+
""" test_ips7_should_fail """
84130
try:
85131
ips = cf.ips()
86132
except CloudFlare.exceptions.CloudFlareAPIError as e:
87-
print('Error expected: %d %s' % (e, e), file=sys.stderr)
133+
print('Error expected: %d %s' % (int(e), str(e)), file=sys.stderr)
88134
pass
89135

90136
def test_cloudflare_email_invalid():
137+
""" test_cloudflare_email_invalid """
91138
global cf
92139
try:
93140
cf = CloudFlare.CloudFlare(email=int(0))
@@ -96,6 +143,7 @@ def test_cloudflare_email_invalid():
96143
print('Error expected: %s' % (e), file=sys.stderr)
97144

98145
def test_cloudflare_key_invalid():
146+
""" test_cloudflare_key_invalid """
99147
global cf
100148
try:
101149
cf = CloudFlare.CloudFlare(key=int(0))
@@ -104,6 +152,7 @@ def test_cloudflare_key_invalid():
104152
print('Error expected: %s' % (e), file=sys.stderr)
105153

106154
def test_cloudflare_token_invalid():
155+
""" test_cloudflare_token_invalid """
107156
global cf
108157
try:
109158
cf = CloudFlare.CloudFlare(token=int(0))
@@ -112,6 +161,7 @@ def test_cloudflare_token_invalid():
112161
print('Error expected: %s' % (e), file=sys.stderr)
113162

114163
def test_cloudflare_certtoken_invalid():
164+
""" test_cloudflare_certtoken_invalid """
115165
global cf
116166
try:
117167
cf = CloudFlare.CloudFlare(certtoken=int(0))
@@ -120,8 +170,8 @@ def test_cloudflare_certtoken_invalid():
120170
print('Error expected: %s' % (e), file=sys.stderr)
121171

122172
def test_cloudflare_context():
173+
""" test_cloudflare_context """
123174
global cf
124-
125175
cf = None
126176
with CloudFlare.CloudFlare() as cf:
127177
assert isinstance(cf, CloudFlare.CloudFlare)
@@ -132,6 +182,13 @@ def test_cloudflare_context():
132182
if __name__ == '__main__':
133183
test_cloudflare()
134184
test_percent_s()
185+
test_percent_r()
186+
test_percent_ips_s()
187+
test_percent_ips_r()
188+
test_percent_cf_accounts_billing_s()
189+
test_percent_cf_accounts_billing_r()
190+
test_percent_cf_zones_waiting_rooms_events_details_s()
191+
test_percent_cf_zones_waiting_rooms_events_details_r()
135192
test_ips1()
136193
test_cloudflare_debug()
137194
test_ips2()
@@ -152,4 +209,4 @@ def test_cloudflare_context():
152209
test_cloudflare_token_invalid()
153210
test_cloudflare_certtoken_invalid()
154211

155-
test_cloudflare_contexe()
212+
test_cloudflare_context()

0 commit comments

Comments
 (0)