def _setPolicy(self, policy, model, resource, user, error=None,
                   results=None):
        """
        Set the quota or assetstore policy and check that it was set.

        :param policy: dictionary of values to set.
        :param model: either 'user' or 'collection'.
        :param resource: the document for the resource to test.
        :param user: user to use for authorization.
        :param error: if set, this is a substring expected in an error message.
        :param results: if not specified, we expect policy to match the set
                        results.  Otherwise, these are the expected results.
        """
        if isinstance(policy, dict):
            policyJSON = json.dumps(policy)
        else:
            policyJSON = policy
        path = '/%s/%s/quota' % (model, resource['_id'])
        resp = self.request(path=path, method='PUT', user=user,
                            params={'policy': policyJSON})
        if error:
            self.assertStatus(resp, 400)
            self.assertTrue(error in resp.json['message'])
            return
        self.assertStatusOk(resp)
        resp = self.request(path=path, method='GET', user=user)
        self.assertStatusOk(resp)
        currentPolicy = resp.json['quota']
        if not results:
            results = policy
        for key in results:
            if results[key] or results[key] is False:
                self.assertEqual(currentPolicy[key], results[key])
            else:
                self.assertEqual(currentPolicy[key], None)
dataset/ETHPy150Open girder/girder/plugins/user_quota/plugin_tests/user_quota_test.py/QuotaTestCase._setPolicy/original