Warning

This document is for an old release of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.

Source code for galaxy_test.api.test_display_applications

import random
from typing import List

from ._framework import ApiTestCase


[docs]class DisplayApplicationsApiTestCase(ApiTestCase):
[docs] def test_index(self): response = self._get("display_applications") self._assert_status_code_is(response, 200) as_list = response.json() assert isinstance(as_list, list) assert len(as_list) > 0 for display_app in as_list: self._assert_has_keys(display_app, "id", "name", "version", "filename_", "links")
[docs] def test_reload_as_admin(self): response = self._post("display_applications/reload", admin=True) self._assert_status_code_is(response, 200)
[docs] def test_reload_with_some_ids(self): response = self._get("display_applications") self._assert_status_code_is(response, 200) display_apps = response.json() all_ids = [display_app["id"] for display_app in display_apps] input_ids = self._get_half_random_items(all_ids) payload = {"ids": input_ids} response = self._post("display_applications/reload", payload, admin=True) self._assert_status_code_is(response, 200) reloaded = response.json()["reloaded"] assert len(reloaded) == len(input_ids) assert all(elem in reloaded for elem in input_ids)
[docs] def test_reload_unknow_returns_as_failed(self): unknown_id = "unknown" payload = {"ids": [unknown_id]} response = self._post("display_applications/reload", payload, admin=True) self._assert_status_code_is(response, 200) reloaded = response.json()["reloaded"] failed = response.json()["failed"] assert len(reloaded) == 0 assert len(failed) == 1 assert unknown_id in failed
[docs] def test_reload_as_non_admin_returns_403(self): response = self._post("display_applications/reload") self._assert_status_code_is(response, 403)
def _get_half_random_items(self, collection: List[str]) -> List[str]: half_num_items = int(len(collection) / 2) rval = random.sample(collection, half_num_items) return rval