def _testQuota(self, model, resource, user):
        """
        Test quota policies for a specified resource.

        :param model: either 'user' or 'collection'.
        :param resource: the document for the resource to test.
        :param user: user to use for authorization.
        """
        self.model('setting').set(SettingKey.UPLOAD_MINIMUM_CHUNK_SIZE, 0)
        resp = self.request(path='/folder', method='GET', user=user,
                            params={'parentType': model,
                                    'parentId': resource['_id']})
        self.assertStatusOk(resp)
        self.assertGreaterEqual(len(resp.json), 1)
        folder = resp.json[0]
        # Start by uploading one file so that there is some use
        self._uploadFile('First upload', folder, size=1024)
        # Set a policy limiting things to 4 kb, then a 4 kb file should fail
        self._setPolicy({'fileSizeQuota': 4096, 'useQuotaDefault': False},
                        model, resource, user)
        self._uploadFile('File too large', folder, size=4096,
                         error='Upload would exceed file storage quota')
        # But a 2 kb file will succeed
        file = self._uploadFile('Second upload', folder, size=2048)
        # And a second 2 kb file will fail
        self._uploadFile('File too large', folder, size=2048,
                         error='Upload would exceed file storage quota')
        # If we start uploading two files, only one should complete
        file1kwargs = self._uploadFile('First partial', folder, size=768,
                                       partial=True)
        file2kwargs = self._uploadFile('Second partial', folder, size=768,
                                       partial=True)
        resp = self.multipartRequest(**file1kwargs)
        self.assertStatusOk(resp)
        try:
            resp = self.multipartRequest(**file2kwargs)
            self.assertStatus(resp, 500)
        except AssertionError as exc:
            self.assertTrue(exc.args[0] in 'Upload exceeded')
        # Shrink the quota to smaller than all of our files.  Replacing an
        # existing file should still work, though
        self._setPolicy({'fileSizeQuota': 2048}, model, resource, user)
        self._uploadFile('Second upload', file, 'file', size=1536)
        # Now test again using default quotas.  We have 1024+1536+768 = 3328
        # bytes currently uploaded
        self._setPolicy({'useQuotaDefault': True}, model, resource, user)
        # Upload should now be unlimited, so anything will work
        self._uploadFile('Fourth upload', folder, size=1792)
        # Set a policy limiting things to 8 kb, then an additional 4 kb file
        # should fail
        self._setQuotaDefault(model, 8192)
        self._uploadFile('File too large', folder, size=4096,
                         error='Upload would exceed file storage quota')
        # But a 2 kb file will succeed
        file = self._uploadFile('Fifth upload', folder, size=2048)
        # And a second 2 kb file will fail
        self._uploadFile('File too large', folder, size=2048,
                         error='Upload would exceed file storage quota')
        # Set a policy with a large quota to test using NumberLong in the
        # mongo settings.
        self._setQuotaDefault(model, 5*1024**3)
        # A small file should now upload
        file = self._uploadFile('Six upload', folder, size=2048)
        # But a huge one will fail
        self._uploadFile('File too large', folder, size=6*1024**3,
                         error='Upload would exceed file storage quota')
dataset/ETHPy150Open girder/girder/plugins/user_quota/plugin_tests/user_quota_test.py/QuotaTestCase._testQuota/swapped operands of `in`