File: TestGalaxyQuotas.py

package info (click to toggle)
python-bioblend 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,096 kB
  • sloc: python: 7,596; sh: 219; makefile: 158
file content (52 lines) | stat: -rw-r--r-- 2,104 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import uuid

from . import GalaxyTestBase


class TestGalaxyQuotas(GalaxyTestBase.GalaxyTestBase):
    def setUp(self):
        super().setUp()
        # Quota names must be unique, and they're impossible to delete
        # without accessing the database.
        self.quota_name = f"BioBlend-Test-Quota-{uuid.uuid4().hex}"
        self.quota = self.gi.quotas.create_quota(self.quota_name, "testing", "100 GB", "=", default="registered")

    def tearDown(self):
        self.gi.quotas.update_quota(self.quota["id"], default="registered")
        self.gi.quotas.update_quota(self.quota["id"], default="no")
        self.gi.quotas.delete_quota(self.quota["id"])

    def test_create_quota(self):
        quota = self.gi.quotas.show_quota(self.quota["id"])
        assert quota["name"] == self.quota_name
        assert quota["bytes"] == 107374182400
        assert quota["operation"] == "="
        assert quota["description"] == "testing"

    def test_get_quotas(self):
        quotas = self.gi.quotas.get_quotas()
        assert self.quota["id"] in [quota["id"] for quota in quotas]

    def test_update_quota(self):
        response = self.gi.quotas.update_quota(
            self.quota["id"],
            name=self.quota_name + "-new",
            description="asdf",
            default="registered",
            operation="-",
            amount=".01 TB",
        )
        assert f"""Quota '{self.quota_name}' has been renamed to '{self.quota_name}-new'""" in response

        quota = self.gi.quotas.show_quota(self.quota["id"])
        assert quota["name"] == self.quota_name + "-new"
        assert quota["bytes"] == 10995116277
        assert quota["operation"] == "-"
        assert quota["description"] == "asdf"

    def test_delete_undelete_quota(self):
        self.gi.quotas.update_quota(self.quota["id"], default="no")
        response = self.gi.quotas.delete_quota(self.quota["id"])
        assert response == "Deleted 1 quotas: " + self.quota_name
        response = self.gi.quotas.undelete_quota(self.quota["id"])
        assert response == "Undeleted 1 quotas: " + self.quota_name