def test_django_push_quota(self): client = mock.MagicMock() quota_info = QuotaInformation( timestamp=None, used=1230, soft=456, hard=789, doubt=0, expired=(False, None), files_used=130, files_soft=380, files_hard=560, files_doubt=0, files_expired=(False, None), ) with DjangoPusher("my_storage", client, QUOTA_USER_KIND, False) as pusher: pusher.push_quota('vsc10001', 'vsc100', quota_info, shared=False) self.assertEqual(pusher.payload["my_storage"][0], { 'fileset': 'vsc100', 'used': 1230, 'soft': 456, 'hard': 789, 'doubt': 0, 'expired': False, 'remaining': 0, 'files_used': 130, 'files_soft': 380, 'files_hard': 560, 'files_doubt': 0, 'files_expired': False, 'files_remaining': 0, 'user': '******', }) self.assertEqual(pusher.payload["my_storage_SHARED"], []) pusher.push_quota('vsc10001', 'vsc100', quota_info, shared=True) self.assertEqual(pusher.payload["my_storage_SHARED"][0], { 'fileset': 'vsc100', 'used': 1230, 'soft': 456, 'hard': 789, 'doubt': 0, 'expired': False, 'remaining': 0, 'files_used': 130, 'files_soft': 380, 'files_hard': 560, 'files_doubt': 0, 'files_expired': False, 'files_remaining': 0, 'user': '******', })
def test_django_pusher(self): client = mock.MagicMock() with DjangoPusher("my_storage", client, QUOTA_USER_KIND, False) as pusher: for i in range(0, 101): pusher.push("my_storage", "pushing %d" % i) self.assertEqual(pusher.payload, {"my_storage": [], "my_storage_SHARED": []})