@@ -52,8 +52,83 @@ def now_iso8601_time(h_delta):
5252 r = datetime .datetime .fromtimestamp (int (t ), tz = pytz .timezone ("UTC" )).strftime ('%Y-%m-%d' )
5353 return r
5454
55- def test_graphql ():
56- """ /graphql test """
55+ def test_graphql_get ():
56+ """ /graphql_get test """
57+ try :
58+ # graphql is alwatys a post - this should fail (but presently doesn't)
59+ r = cf .graphql .get ()
60+ if r is not None and 'data' in r and 'errors' in r :
61+ # still an invalid API!
62+ print ('Error in API (but proceeding) r=' , r , file = sys .stderr )
63+ assert True
64+ else :
65+ assert False
66+ except CloudFlare .exceptions .CloudFlareAPIError as e :
67+ print ('Error expected: %s' % (e ), file = sys .stderr )
68+ assert True
69+
70+ def test_graphql_patch ():
71+ """ /graphql_patch test """
72+ try :
73+ # graphql is alwatys a post - this should fail (but presently doesn't)
74+ r = cf .graphql .patch ()
75+ if r is not None and 'data' in r and 'errors' in r :
76+ # still an invalid API!
77+ print ('Error in API (but proceeding) r=' , r , file = sys .stderr )
78+ assert True
79+ else :
80+ assert False
81+ except CloudFlare .exceptions .CloudFlareAPIError as e :
82+ print ('Error expected: %s' % (e ), file = sys .stderr )
83+ assert True
84+
85+ def test_graphql_put ():
86+ """ /graphql_put test """
87+ try :
88+ # graphql is alwatys a post - this should fail (but presently doesn't)
89+ r = cf .graphql .put ()
90+ if r is not None and 'data' in r and 'errors' in r :
91+ # still an invalid API!
92+ print ('Error in API (but proceeding) r=' , r , file = sys .stderr )
93+ assert True
94+ else :
95+ assert False
96+ except CloudFlare .exceptions .CloudFlareAPIError as e :
97+ print ('Error expected: %s' % (e ), file = sys .stderr )
98+ assert True
99+
100+ def test_graphql_delete ():
101+ """ /graphql_delete test """
102+ try :
103+ # graphql is alwatys a post - this should fail (but presently doesn't)
104+ r = cf .graphql .delete ()
105+ if r is not None and 'data' in r and 'errors' in r :
106+ # still an invalid API!
107+ print ('Error in API (but proceeding) r=' , r , file = sys .stderr )
108+ assert True
109+ else :
110+ assert False
111+ except CloudFlare .exceptions .CloudFlareAPIError as e :
112+ print ('Error expected: %s' % (e ), file = sys .stderr )
113+ assert True
114+
115+ def test_graphql_post_empty ():
116+ """ /graphql_post_empty test """
117+ try :
118+ # graphql requires data - this should fail (but presently doesn't)
119+ r = cf .graphql .post (data = {})
120+ if r is not None and 'data' in r and 'errors' in r :
121+ # still an invalid API!
122+ print ('Error in API (but proceeding) r=' , r , file = sys .stderr )
123+ assert True
124+ else :
125+ assert False
126+ except CloudFlare .exceptions .CloudFlareAPIError as e :
127+ print ('Error expected: %s' % (e ), file = sys .stderr )
128+ assert True
129+
130+ def test_graphql_post ():
131+ """ /graphql_post test """
57132 date_before = now_iso8601_time (0 ) # now
58133 date_after = now_iso8601_time (3 * 24 ) # 3 days worth
59134
@@ -119,4 +194,9 @@ def test_graphql():
119194 test_find_zone (sys .argv [1 ])
120195 else :
121196 test_find_zone ()
122- test_graphql ()
197+ test_graphql_get ()
198+ test_graphql_put ()
199+ test_graphql_patch ()
200+ test_graphql_delete ()
201+ test_graphql_post_empty ()
202+ test_graphql_post ()
0 commit comments