def testDeleteCollectionRemote(self): # drive RESTful API via wrapper tca = TreeCollectionsAPI(self.domains, get_from='api') # remove any prior clones of our tests collection? or let them pile up for now? cl = tca.collection_list cid = 'jimallman/doomed-collection' if cid not in cl: # add our dummy collection so just we can delete it cjson = get_empty_collection() commit_msg = 'Creating temporary collection via API wrapper' result = tca.post_collection(cjson, cid, commit_msg) cl = tca.collection_list self.assertEqual(result['error'], 0) self.assertEqual(result['merge_needed'], False) self.assertEqual(result['resource_id'], cid) self.assertTrue(cid in cl) # now try to clobber it try: c = tca.get_collection(cid) except HTTPError as err: raise_http_error_with_more_detail(err) except Exception as err: raise err else: tca.delete_collection(cid, c['sha']) # is it really gone? cl = tca.collection_list self.assertTrue(cid not in cl)
def testFetchCollectionRemote(self): # drive RESTful API via wrapper tca = TreeCollectionsAPI(self.domains, get_from='api') try: c = tca.get_collection('jimallman/my-test-collection') except HTTPError as err: raise_http_error_with_more_detail(err) except Exception as err: raise err else: # N.B. we get the JSON "wrapper" with history, etc. cn = c['data']['name'] self.assertTrue(cn == u'My test collection')