forked from cloudflare-api/python-cloudflare-v4
-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
""" dump api tests """ | ||
|
||
import os | ||
import sys | ||
|
||
sys.path.insert(0, os.path.abspath('.')) | ||
sys.path.insert(0, os.path.abspath('..')) | ||
import CloudFlare | ||
|
||
# test API list fetches from Cloudflare website | ||
|
||
cf = None | ||
|
||
def test_cloudflare(): | ||
global cf | ||
cf = CloudFlare.CloudFlare() | ||
assert isinstance(cf, CloudFlare.CloudFlare) | ||
|
||
def test_app_invalid(): | ||
"""add API commands""" | ||
cf.add('OPEN', 'invalid') | ||
try: | ||
results = cf.invalid() | ||
print('error - should not reach here') | ||
assert False | ||
except CloudFlare.exceptions.CloudFlareAPIError as e: | ||
# error 7000 No route for that URI | ||
assert int(e) == 7000 | ||
assert str(e) == 'No route for that URI' | ||
print(int(e), str(e)) | ||
|
||
def test_app_invalid_with_underscore(): | ||
"""add API commands""" | ||
cf.add('OPEN', 'in_valid') | ||
try: | ||
results = cf.in_valid() | ||
print('error - should not reach here') | ||
assert False | ||
except CloudFlare.exceptions.CloudFlareAPIError as e: | ||
# error 7000 No route for that URI | ||
assert int(e) == 7000 | ||
assert str(e) == 'No route for that URI' | ||
print(int(e), str(e)) | ||
|
||
def test_app_invalid_with_dash(): | ||
"""add API commands""" | ||
cf.add('OPEN', 'in-val-id') | ||
try: | ||
results = cf.in_val_id() | ||
print('error - should not reach here') | ||
assert False | ||
except CloudFlare.exceptions.CloudFlareAPIError as e: | ||
# error 7000 No route for that URI | ||
assert int(e) == 7000 | ||
assert str(e) == 'No route for that URI' | ||
print(int(e), str(e)) | ||
|
||
if __name__ == '__main__': | ||
test_cloudflare() | ||
test_app_invalid() | ||
test_app_invalid_with_underscore() | ||
test_app_invalid_with_dash() | ||
|