def testChangesMissingEnd(self): httpretty.register_uri(httpretty.POST, common.get_metadata_url() + 'changes', body='{"checkpoint": "foo", "reset": true, "nodes": [], "statusCode": 200}\n') nodes, purged_nodes, checkpoint, reset = metadata.get_changes() self.assertEqual(len(nodes), 0) self.assertEqual(len(purged_nodes), 0) self.assertEqual(checkpoint, 'foo') self.assertTrue(reset)
def testChanges(self): httpretty.register_uri(httpretty.POST, common.get_metadata_url() + 'changes', body='{"checkpoint": "foo", "reset": true, ' '"nodes": [ {"kind": "FILE", "status": "TRASH"} ], "statusCode": 200}\n' '{"end": true}') nodes, purged_nodes, checkpoint, reset = metadata.get_changes() self.assertEqual(len(nodes), 1) self.assertEqual(len(purged_nodes), 0) self.assertEqual(checkpoint, 'foo') self.assertTrue(reset)
def testChanges(self): httpretty.register_uri( httpretty.POST, common.get_metadata_url() + 'changes', body='{"checkpoint": "foo", "reset": true, ' '"nodes": [ {"kind": "FILE", "status": "TRASH"} ], "statusCode": 200}\n' '{"end": true}') nodes, purged_nodes, checkpoint, reset = metadata.get_changes() self.assertEqual(len(nodes), 1) self.assertEqual(len(purged_nodes), 0) self.assertEqual(checkpoint, 'foo') self.assertTrue(reset)
def testChangesMissingEnd(self): httpretty.register_uri( httpretty.POST, common.get_metadata_url() + 'changes', body= '{"checkpoint": "foo", "reset": true, "nodes": [], "statusCode": 200}\n' ) nodes, purged_nodes, checkpoint, reset = metadata.get_changes() self.assertEqual(len(nodes), 0) self.assertEqual(len(purged_nodes), 0) self.assertEqual(checkpoint, 'foo') self.assertTrue(reset)
def testUsage(self): httpretty. \ register_uri(httpretty.GET, common.get_metadata_url() + 'account/usage', body=json.dumps({"lastCalculated": "2014-08-13T23:17:41.365Z", "video": {"billable": {"bytes": 23524252, "count": 22}, "total": {"bytes": 23524252, "count": 22}}, "other": {"billable": {"bytes": 29999771, "count": 871}, "total": {"bytes": 29999771, "count": 871}}, "doc": {"billable": {"bytes": 807170, "count": 10}, "total": {"bytes": 807170, "count": 10}}, "photo": {"billable": {"bytes": 9477988, "count": 25}, "total": {"bytes": 9477988, "count": 25}}}) ) self.assertIsInstance(account.get_account_usage(), account._Usage)
def testUsageEmpty(self): httpretty.register_uri(httpretty.GET, common.get_metadata_url() + 'account/usage', body='{}') self.assertEqual(str(account.get_account_usage()), '')
def testMetadataUrl(self): self.assertEqual(common.get_metadata_url(), 'https://cdws.us-east-1.amazonaws.com/drive/v1/')
def testChangesCorruptJSON(self): httpretty.register_uri(httpretty.POST, common.get_metadata_url() + 'changes', body='{"checkpoint": }') self.assertRaises(common.RequestError, metadata.get_changes)