Skip to content

Commit

Permalink
Adapt quotas tests to use JSON payload
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed Sep 8, 2021
1 parent a5cf27d commit 1bc8b38
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions test/integration/test_quota.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@

import json

from requests import delete

from galaxy_test.base.populators import (
DatasetPopulator,
)
Expand Down Expand Up @@ -66,10 +61,10 @@ def test_update(self):
quota_id = quota["id"]

new_quota_name = "updated-quota-name"
update_payload = json.dumps({
update_payload = {
'name': new_quota_name,
})
put_response = self._put(f"quotas/{quota_id}", data=update_payload)
}
put_response = self._put(f"quotas/{quota_id}", data=update_payload, json=True)
put_response.raise_for_status()
assert "has been renamed to" in put_response.text

Expand All @@ -90,7 +85,7 @@ def test_delete_and_purge(self):
quota_name = "test-delete-purge-quota"
quota = self._create_quota_with_name(quota_name)
quota_id = quota["id"]
delete_response = self._delete_and_purge(f"quotas/{quota_id}")
delete_response = self._delete_and_purge(quota_id)
delete_response.raise_for_status()
self._assert_quota_is_deleted(quota_id)

Expand All @@ -111,7 +106,7 @@ def test_delete_and_purge_with_user(self):
json_response = show_response.json()
assert user_email in str(json_response["users"])

delete_response = self._delete_and_purge(f"quotas/{quota_id}")
delete_response = self._delete_and_purge(quota_id)
delete_response.raise_for_status()
show_response = self._get(f"quotas/deleted/{quota_id}")
show_response.raise_for_status()
Expand Down Expand Up @@ -146,7 +141,7 @@ def test_400_when_quota_name_already_exists(self):
quota_name = "test-duplicated-quota"
self._create_quota_with_name(quota_name)
payload = self._build_quota_payload_with_name(quota_name)
create_response = self._post("quotas", data=payload)
create_response = self._post("quotas", data=payload, json=True)
self._assert_status_code_is(create_response, 400)

def test_400_when_show_unknown_quota(self):
Expand All @@ -172,18 +167,11 @@ def _build_quota_payload_with_name(self, quota_name: str, is_default: bool = Fal
'in_groups': []
}

def _delete_and_purge(self, url):
headers = self.galaxy_interactor.api_key_header(
key=self.galaxy_interactor.api_key,
admin=True,
anon=False,
headers=None,
)
json_data = json.dumps({
def _delete_and_purge(self, quota_id):
data = {
'purge': 'true'
})
api_url = self._api_url(url)
return delete(api_url, data=json_data, headers=headers)
}
return self._delete(f"quotas/{quota_id}", data=data, admin=True, json=True)

def _assert_quota_is_deleted(self, quota_id: str):
show_response = self._get(f"quotas/deleted/{quota_id}")
Expand Down

0 comments on commit 1bc8b38

Please sign in to comment.