On 07/15/2013 05:59 PM, Joe Hakim Rahme wrote:
Hello,

I am trying to write a test in Tempest that would cover the behavior of
the Swift Account Quotas middleware. The use case I'm trying to cover
is that the test would create an account, put a quota on it, and try to
upload a file larger and a file smaller than the quota.

Here's what I have in my class:

class AccountQuotaTest(base.BaseObjectTest):
    @classmethod
    def setUpClass(cls):
        super(AccountQuotaTest, cls).setUpClass()
        cls.container_name = rand_name(name="TestContainer")
        cls.container_client.create_container(cls.container_name)

        # Add the account quota metadata
        size = "10"
        metadata = {"Quota-Bytes": size}
        cls.account_client.create_account_metadata(metadata=metadata)

However when I execute the tests, I get a Unauthorized exception. I
guess it makes sense, since only the admin (or any account with
ResellerAdmin role) can set this metadata.

In the base class you'll see the container_client , account_client and other clients are defined out of cls.os

https://github.com/openstack/tempest/blob/master/tempest/api/object_storage/base.py#L28

redefine those in your test class from cls.os_admin so they will "run" using the admin credentials

Ideally you could also provide some BaseAdminObjectTest class in base.py to use, as it happens for the volume tests:

https://github.com/openstack/tempest/blob/master/tempest/api/volume/base.py#L192
--
Giulio Fidente
GPG KEY: 08D733BA | IRC: giulivo

_______________________________________________
OpenStack-dev mailing list
[email protected]
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

Reply via email to