From 12e030494c1fc658b36c23c55bd73be780079dba Mon Sep 17 00:00:00 2001 From: Matthew Richards Date: Wed, 30 Aug 2023 14:16:34 +0000 Subject: [PATCH] feat!: Remove code and references to ISIS specific table endpoints #432 --- README.md | 10 +- datagateway_api/src/api_start_utils.py | 59 +--- .../src/datagateway_api/backend.py | 62 ---- .../src/datagateway_api/database/backend.py | 36 --- .../src/datagateway_api/database/helpers.py | 150 +--------- .../src/datagateway_api/icat/backend.py | 40 --- .../src/datagateway_api/icat/helpers.py | 163 ---------- .../src/datagateway_api/icat/query.py | 4 - .../table_endpoints/table_endpoints.py | 281 ------------------ .../src/swagger/datagateway_api/openapi.yaml | 154 ---------- .../datagateway_api/db/conftest.py | 18 +- .../db/endpoints/test_get_with_filters.py | 2 +- .../db/endpoints/test_table_endpoints_db.py | 121 -------- .../datagateway_api/icat/conftest.py | 39 --- .../endpoints/test_table_endpoints_icat.py | 127 -------- .../datagateway_api/test_backends.py | 26 -- test/integration/test_endpoint_rules.py | 25 -- util/postman_collection_icat.json | 151 ---------- 18 files changed, 13 insertions(+), 1455 deletions(-) delete mode 100644 datagateway_api/src/resources/table_endpoints/table_endpoints.py delete mode 100644 test/integration/datagateway_api/db/endpoints/test_table_endpoints_db.py delete mode 100644 test/integration/datagateway_api/icat/endpoints/test_table_endpoints_icat.py diff --git a/README.md b/README.md index 51b1f713..84d32580 100644 --- a/README.md +++ b/README.md @@ -483,8 +483,8 @@ api.add_resource(get_endpoint_resource, f"/{entity_name.lower()}") ## Endpoints -The logic for each endpoint is within `/src/resources`. They are split into entities, -non_entities and table_endpoints. +The logic for each endpoint is within `/src/resources` - they're split into entities and +non_entities. The entities package contains `entity_map` which maps entity names to their field name used in backend-specific code. The Database @@ -492,10 +492,8 @@ Backend uses this for its mapped classes (explained below) and the Python ICAT B uses this for interacting with ICAT objects within Python ICAT. In most instances, the dictionary found in `entity_map.py` is simply mapping the plural entity name (used to build the entity endpoints) to the singular version. The `entity_endpoint` module -contains the function that is used to generate endpoints at start up. `table_endpoints` -contains the endpoint classes that are table specific (currently these are the ISIS -specific endpoints required for their use cases). Finally, `non_entities` contains the -session endpoint for session handling. +contains the function that is used to generate endpoints at start up. Finally, +`non_entities` contains the session endpoint for session handling. ## Logging diff --git a/datagateway_api/src/api_start_utils.py b/datagateway_api/src/api_start_utils.py index eb5d13b7..6859368f 100644 --- a/datagateway_api/src/api_start_utils.py +++ b/datagateway_api/src/api_start_utils.py @@ -28,6 +28,11 @@ from datagateway_api.src.resources.non_entities.sessions_endpoints import ( session_endpoints, ) +from datagateway_api.src.swagger.apispec_flask_restful import RestfulPlugin +from datagateway_api.src.swagger.initialise_spec import ( + initialise_datagateway_api_spec, + initialise_search_api_spec, +) if Config.config.search_api: from datagateway_api.src.resources.search_api_endpoints import ( @@ -37,17 +42,6 @@ get_search_endpoint, get_single_endpoint, ) -from datagateway_api.src.resources.table_endpoints.table_endpoints import ( # noqa: I202, B950 - count_instrument_facility_cycles_endpoint, - count_instrument_investigation_endpoint, - instrument_facility_cycles_endpoint, - instrument_investigation_endpoint, -) -from datagateway_api.src.swagger.apispec_flask_restful import RestfulPlugin -from datagateway_api.src.swagger.initialise_spec import ( - initialise_datagateway_api_spec, - initialise_search_api_spec, -) log = logging.getLogger() @@ -232,49 +226,6 @@ def create_api_endpoints(flask_app, api, specs): ) datagateway_api_spec.path(resource=session_endpoint_resource, api=api) - # Table specific endpoints - instrument_facility_cycle_resource = instrument_facility_cycles_endpoint( - backend, client_pool=icat_client_pool, - ) - api.add_resource( - instrument_facility_cycle_resource, - f"{datagateway_api_extension}/instruments//facilitycycles", - endpoint="datagateway_isis_instrument_facility_cycle", - ) - datagateway_api_spec.path(resource=instrument_facility_cycle_resource, api=api) - - count_instrument_facility_cycle_res = count_instrument_facility_cycles_endpoint( - backend, client_pool=icat_client_pool, - ) - api.add_resource( - count_instrument_facility_cycle_res, - f"{datagateway_api_extension}/instruments//facilitycycles/count", - endpoint="datagateway_isis_count_instrument_facility_cycle", - ) - datagateway_api_spec.path(resource=count_instrument_facility_cycle_res, api=api) - - instrument_investigation_resource = instrument_investigation_endpoint( - backend, client_pool=icat_client_pool, - ) - api.add_resource( - instrument_investigation_resource, - f"{datagateway_api_extension}/instruments/" - f"/facilitycycles//investigations", - endpoint="datagateway_isis_instrument_investigation", - ) - datagateway_api_spec.path(resource=instrument_investigation_resource, api=api) - - count_instrument_investigation_res = count_instrument_investigation_endpoint( - backend, client_pool=icat_client_pool, - ) - api.add_resource( - count_instrument_investigation_res, - f"{datagateway_api_extension}/instruments/" - f"/facilitycycles//investigations/count", - endpoint="datagateway_isis_count_instrument_investigation", - ) - datagateway_api_spec.path(resource=count_instrument_investigation_res, api=api) - # Ping endpoint ping_resource = ping_endpoint(backend, client_pool=icat_client_pool) api.add_resource(ping_resource, f"{datagateway_api_extension}/ping") diff --git a/datagateway_api/src/datagateway_api/backend.py b/datagateway_api/src/datagateway_api/backend.py index b5bb1948..ec9d8e74 100644 --- a/datagateway_api/src/datagateway_api/backend.py +++ b/datagateway_api/src/datagateway_api/backend.py @@ -151,65 +151,3 @@ def update_with_id(self, session_id, entity_type, id_, data): :return: The updated entity. """ pass - - @abstractmethod - def get_facility_cycles_for_instrument_with_filters( - self, session_id, instrument_id, filters, - ): - """ - Given an instrument_id get facility cycles where the instrument has - investigations that occur within that cycle - - :param session_id: The session id of the requesting user - :param filters: The filters to be applied to the query - :param instrument_id: The id of the instrument - :return: A list of facility cycle entities - """ - pass - - @abstractmethod - def get_facility_cycles_for_instrument_count_with_filters( - self, session_id, instrument_id, filters, - ): - """ - Given an instrument_id get the facility cycles count where the instrument has - investigations that occur within that cycle - - :param session_id: The session id of the requesting user - :param filters: The filters to be applied to the query - :param instrument_id: The id of the instrument - :return: The count of the facility cycles - """ - pass - - @abstractmethod - def get_investigations_for_instrument_facility_cycle_with_filters( - self, session_id, instrument_id, facilitycycle_id, filters, - ): - """ - Given an instrument id and facility cycle id, get investigations that use the - given instrument in the given cycle - - :param session_id: The session id of the requesting user - :param filters: The filters to be applied to the query - :param instrument_id: The id of the instrument - :param facility_cycle_id: the ID of the facility cycle - :return: The investigations - """ - pass - - @abstractmethod - def get_investigation_count_instrument_facility_cycle_with_filters( - self, session_id, instrument_id, facilitycycle_id, filters, - ): - """ - Given an instrument id and facility cycle id, get the count of the - investigations that use the given instrument in the given cycle - - :param session_id: The session id of the requesting user - :param filters: The filters to be applied to the query - :param instrument_id: The id of the instrument - :param facility_cycle_id: the ID of the facility cycle - :return: The investigations count - """ - pass diff --git a/datagateway_api/src/datagateway_api/database/backend.py b/datagateway_api/src/datagateway_api/database/backend.py index 299fc903..2e5e4ac8 100644 --- a/datagateway_api/src/datagateway_api/database/backend.py +++ b/datagateway_api/src/datagateway_api/database/backend.py @@ -16,12 +16,8 @@ create_rows_from_json, db, delete_row_by_id, - get_facility_cycles_for_instrument, - get_facility_cycles_for_instrument_count, get_filtered_row_count, get_first_filtered_row, - get_investigations_for_instrument_in_facility_cycle, - get_investigations_for_instrument_in_facility_cycle_count, get_row_by_id, get_rows_by_filter, insert_row_into_table, @@ -127,35 +123,3 @@ def delete_with_id(self, session_id, entity_type, id_, **kwargs): def update_with_id(self, session_id, entity_type, id_, data, **kwargs): table = get_entity_object_from_name(entity_type) return update_row_from_id(table, id_, data) - - @requires_session_id - @queries_records - def get_facility_cycles_for_instrument_with_filters( - self, session_id, instrument_id, filters, **kwargs, - ): - return get_facility_cycles_for_instrument(instrument_id, filters) - - @requires_session_id - @queries_records - def get_facility_cycles_for_instrument_count_with_filters( - self, session_id, instrument_id, filters, **kwargs, - ): - return get_facility_cycles_for_instrument_count(instrument_id, filters) - - @requires_session_id - @queries_records - def get_investigations_for_instrument_facility_cycle_with_filters( - self, session_id, instrument_id, facilitycycle_id, filters, **kwargs, - ): - return get_investigations_for_instrument_in_facility_cycle( - instrument_id, facilitycycle_id, filters, - ) - - @requires_session_id - @queries_records - def get_investigation_count_instrument_facility_cycle_with_filters( - self, session_id, instrument_id, facilitycycle_id, filters, **kwargs, - ): - return get_investigations_for_instrument_in_facility_cycle_count( - instrument_id, facilitycycle_id, filters, - ) diff --git a/datagateway_api/src/datagateway_api/database/helpers.py b/datagateway_api/src/datagateway_api/database/helpers.py index d20c8ed4..debe10fa 100644 --- a/datagateway_api/src/datagateway_api/database/helpers.py +++ b/datagateway_api/src/datagateway_api/database/helpers.py @@ -4,7 +4,6 @@ import logging from flask_sqlalchemy import SQLAlchemy -from sqlalchemy.orm import aliased from datagateway_api.src.common.exceptions import ( AuthenticationError, @@ -18,14 +17,7 @@ DatabaseIncludeFilter as IncludeFilter, DatabaseWhereFilter as WhereFilter, ) -from datagateway_api.src.datagateway_api.database.models import ( - FACILITY, - FACILITYCYCLE, - INSTRUMENT, - INVESTIGATION, - INVESTIGATIONINSTRUMENT, - SESSION, -) +from datagateway_api.src.datagateway_api.database.models import SESSION log = logging.getLogger() @@ -394,143 +386,3 @@ def patch_entities(table, json_list): raise BadRequestError(f" Bad request made, request: {json_list}") return results - - -class InstrumentFacilityCyclesQuery(ReadQuery): - def __init__(self, instrument_id): - super().__init__(FACILITYCYCLE) - investigation_instrument = aliased(INSTRUMENT) - self.base_query = ( - self.base_query.join(FACILITYCYCLE.FACILITY) - .join(FACILITY.instruments) - .join(FACILITY.investigations) - .join(INVESTIGATION.investigationInstruments) - .join(investigation_instrument, INVESTIGATIONINSTRUMENT.INSTRUMENT) - .filter(INSTRUMENT.id == instrument_id) - .filter(investigation_instrument.id == INSTRUMENT.id) - .filter(INVESTIGATION.startDate >= FACILITYCYCLE.startDate) - .filter(INVESTIGATION.startDate <= FACILITYCYCLE.endDate) - ) - - -def get_facility_cycles_for_instrument(instrument_id, filters): - """ - Given an instrument_id get facility cycles where the instrument has investigations - that occur within that cycle - - :param filters: The filters to be applied to the query - :param instrument_id: The id of the instrument - :return: A list of facility cycle entities - """ - with InstrumentFacilityCyclesQuery(instrument_id) as query: - filter_handler = FilterOrderHandler() - return get_filtered_read_query_results(filter_handler, filters, query) - - -class InstrumentFacilityCyclesCountQuery(CountQuery): - def __init__(self, instrument_id): - super().__init__(FACILITYCYCLE) - investigation_instrument = aliased(INSTRUMENT) - self.base_query = ( - self.base_query.join(FACILITYCYCLE.FACILITY) - .join(FACILITY.instruments) - .join(FACILITY.investigations) - .join(INVESTIGATION.investigationInstruments) - .join(investigation_instrument, INVESTIGATIONINSTRUMENT.INSTRUMENT) - .filter(INSTRUMENT.id == instrument_id) - .filter(investigation_instrument.id == INSTRUMENT.id) - .filter(INVESTIGATION.startDate >= FACILITYCYCLE.startDate) - .filter(INVESTIGATION.startDate <= FACILITYCYCLE.endDate) - ) - - -def get_facility_cycles_for_instrument_count(instrument_id, filters): - """ - Given an instrument_id get the facility cycles count where the instrument has - investigations that occur within that cycle - - :param filters: The filters to be applied to the query - :param instrument_id: The id of the instrument - :return: The count of the facility cycles - """ - with InstrumentFacilityCyclesCountQuery(instrument_id) as query: - filter_handler = FilterOrderHandler() - filter_handler.add_filters(filters) - filter_handler.apply_filters(query) - return query.get_count() - - -class InstrumentFacilityCycleInvestigationsQuery(ReadQuery): - def __init__(self, instrument_id, facility_cycle_id): - super().__init__(INVESTIGATION) - investigation_instrument = aliased(INSTRUMENT) - self.base_query = ( - self.base_query.join(INVESTIGATION.FACILITY) - .join(FACILITY.facilityCycles) - .join(FACILITY.instruments) - .join(INVESTIGATION.investigationInstruments) - .join(investigation_instrument, INVESTIGATIONINSTRUMENT.INSTRUMENT) - .filter(INSTRUMENT.id == instrument_id) - .filter(FACILITYCYCLE.id == facility_cycle_id) - .filter(investigation_instrument.id == INSTRUMENT.id) - .filter(INVESTIGATION.startDate >= FACILITYCYCLE.startDate) - .filter(INVESTIGATION.startDate <= FACILITYCYCLE.endDate) - ) - - -def get_investigations_for_instrument_in_facility_cycle( - instrument_id, facility_cycle_id, filters, -): - """ - Given an instrument id and facility cycle id, get investigations that use the given - instrument in the given cycle - - :param filters: The filters to be applied to the query - :param instrument_id: The id of the instrument - :param facility_cycle_id: the ID of the facility cycle - :return: The investigations - """ - filter_handler = FilterOrderHandler() - with InstrumentFacilityCycleInvestigationsQuery( - instrument_id, facility_cycle_id, - ) as query: - return get_filtered_read_query_results(filter_handler, filters, query) - - -class InstrumentFacilityCycleInvestigationsCountQuery(CountQuery): - def __init__(self, instrument_id, facility_cycle_id): - super().__init__(INVESTIGATION) - investigation_instrument = aliased(INSTRUMENT) - self.base_query = ( - self.base_query.join(INVESTIGATION.FACILITY) - .join(FACILITY.facilityCycles) - .join(FACILITY.instruments) - .join(INVESTIGATION.investigationInstruments) - .join(investigation_instrument, INVESTIGATIONINSTRUMENT.INSTRUMENT) - .filter(INSTRUMENT.id == instrument_id) - .filter(FACILITYCYCLE.id == facility_cycle_id) - .filter(investigation_instrument.id == INSTRUMENT.id) - .filter(INVESTIGATION.startDate >= FACILITYCYCLE.startDate) - .filter(INVESTIGATION.startDate <= FACILITYCYCLE.endDate) - ) - - -def get_investigations_for_instrument_in_facility_cycle_count( - instrument_id, facility_cycle_id, filters, -): - """ - Given an instrument id and facility cycle id, get the count of the investigations - that use the given instrument in the given cycle - - :param filters: The filters to be applied to the query - :param instrument_id: The id of the instrument - :param facility_cycle_id: the ID of the facility cycle - :return: The investigations count - """ - with InstrumentFacilityCycleInvestigationsCountQuery( - instrument_id, facility_cycle_id, - ) as query: - filter_handler = FilterOrderHandler() - filter_handler.add_filters(filters) - filter_handler.apply_filters(query) - return query.get_count() diff --git a/datagateway_api/src/datagateway_api/icat/backend.py b/datagateway_api/src/datagateway_api/icat/backend.py index 73b70c91..83990117 100644 --- a/datagateway_api/src/datagateway_api/icat/backend.py +++ b/datagateway_api/src/datagateway_api/icat/backend.py @@ -13,11 +13,7 @@ get_count_with_filters, get_entity_by_id, get_entity_with_filters, - get_facility_cycles_for_instrument, - get_facility_cycles_for_instrument_count, get_first_result_with_filters, - get_investigations_for_instrument_in_facility_cycle, - get_investigations_for_instrument_in_facility_cycle_count, get_session_details_helper, logout_icat_client, refresh_client_session, @@ -128,39 +124,3 @@ def delete_with_id(self, session_id, entity_type, id_, **kwargs): @queries_records def update_with_id(self, session_id, entity_type, id_, data, **kwargs): return update_entity_by_id(kwargs.get("client"), entity_type, id_, data) - - @requires_session_id - @queries_records - def get_facility_cycles_for_instrument_with_filters( - self, session_id, instrument_id, filters, **kwargs, - ): - return get_facility_cycles_for_instrument( - kwargs.get("client"), instrument_id, filters, - ) - - @requires_session_id - @queries_records - def get_facility_cycles_for_instrument_count_with_filters( - self, session_id, instrument_id, filters, **kwargs, - ): - return get_facility_cycles_for_instrument_count( - kwargs.get("client"), instrument_id, filters, - ) - - @requires_session_id - @queries_records - def get_investigations_for_instrument_facility_cycle_with_filters( - self, session_id, instrument_id, facilitycycle_id, filters, **kwargs, - ): - return get_investigations_for_instrument_in_facility_cycle( - kwargs.get("client"), instrument_id, facilitycycle_id, filters, - ) - - @requires_session_id - @queries_records - def get_investigation_count_instrument_facility_cycle_with_filters( - self, session_id, instrument_id, facilitycycle_id, filters, **kwargs, - ): - return get_investigations_for_instrument_in_facility_cycle_count( - kwargs.get("client"), instrument_id, facilitycycle_id, filters, - ) diff --git a/datagateway_api/src/datagateway_api/icat/helpers.py b/datagateway_api/src/datagateway_api/icat/helpers.py index 61f4980c..d3471e3e 100644 --- a/datagateway_api/src/datagateway_api/icat/helpers.py +++ b/datagateway_api/src/datagateway_api/icat/helpers.py @@ -518,166 +518,3 @@ def create_entities(client, entity_type, data): created_data.append(get_entity_by_id(client, entity_type, entity.id, True)) return created_data - - -def get_facility_cycles_for_instrument( - client, instrument_id, filters, count_query=False, -): - """ - Given an Instrument ID, get the Facility Cycles where there are Instruments that - have investigations occurring within that cycle - - :param client: ICAT client containing an authenticated user - :type client: :class:`icat.client.Client` - :param instrument_id: ID of the instrument from the request - :type instrument_id: :class:`int` - :param filters: The list of filters to be applied to the request - :type filters: List of specific implementations :class:`QueryFilter` - :param count_query: Flag to determine if the query in this function should be used - as a count query. Used for `get_facility_cycles_for_instrument_count()` - :type count_query: :class:`bool` - :return: A list of Facility Cycles that match the query - """ - log.info("Getting a list of facility cycles from the specified instrument for ISIS") - - query_aggregate = "COUNT:DISTINCT" if count_query else "DISTINCT" - query = ICATQuery(client, "FacilityCycle", aggregate=query_aggregate) - query.isis_endpoint = True - - instrument_id_check = PythonICATWhereFilter( - "facility.instruments.id", instrument_id, "eq", - ) - investigation_instrument_id_check = PythonICATWhereFilter( - "facility.investigations.investigationInstruments.instrument.id", - instrument_id, - "eq", - ) - investigation_start_date_check = PythonICATWhereFilter( - "facility.investigations.startDate", "o.startDate", "gte", - ) - investigation_end_date_check = PythonICATWhereFilter( - "facility.investigations.startDate", "o.endDate", "lte", - ) - - facility_cycle_filters = [ - instrument_id_check, - investigation_instrument_id_check, - investigation_start_date_check, - investigation_end_date_check, - ] - filters.extend(facility_cycle_filters) - filter_handler = FilterOrderHandler() - filter_handler.manage_icat_filters(filters, query.query) - - data = query.execute_query(client, True) - - return data - - -def get_facility_cycles_for_instrument_count(client, instrument_id, filters): - """ - Given an Instrument ID, get the number of Facility Cycles where there's Instruments - that have investigations occurring within that cycle - - :param client: ICAT client containing an authenticated user - :type client: :class:`icat.client.Client` - :param instrument_id: ID of the instrument from the request - :type instrument_id: :class:`int` - :param filters: The list of filters to be applied to the request - :type filters: List of specific implementations :class:`QueryFilter` - :return: The number of Facility Cycles that match the query - """ - log.info( - "Getting the number of facility cycles from the specified instrument for ISIS", - ) - return get_facility_cycles_for_instrument( - client, instrument_id, filters, count_query=True, - )[0] - - -def get_investigations_for_instrument_in_facility_cycle( - client, instrument_id, facilitycycle_id, filters, count_query=False, -): - """ - Given Instrument and Facility Cycle IDs, get investigations that use the given - instrument in the given cycle - - :param client: ICAT client containing an authenticated user - :type client: :class:`icat.client.Client` - :param instrument_id: ID of the instrument from the request - :type instrument_id: :class:`int` - :param facilitycycle_id: ID of the facilityCycle from the request - :type facilitycycle_id: :class:`int` - :param filters: The list of filters to be applied to the request - :type filters: List of specific implementations :class:`QueryFilter` - :param count_query: Flag to determine if the query in this function should be used - as a count query. Used for - `get_investigations_for_instrument_in_facility_cycle_count()` - :type count_query: :class:`bool` - :return: A list of Investigations that match the query - """ - log.info( - "Getting a list of investigations from the specified instrument and facility" - " cycle, for ISIS", - ) - - query_aggregate = "COUNT:DISTINCT" if count_query else "DISTINCT" - query = ICATQuery(client, "Investigation", aggregate=query_aggregate) - query.isis_endpoint = True - - instrument_id_check = PythonICATWhereFilter( - "facility.instruments.id", instrument_id, "eq", - ) - investigation_instrument_id_check = PythonICATWhereFilter( - "investigationInstruments.instrument.id", instrument_id, "eq", - ) - facility_cycle_id_check = PythonICATWhereFilter( - "facility.facilityCycles.id", facilitycycle_id, "eq", - ) - facility_cycle_start_date_check = PythonICATWhereFilter( - "facility.facilityCycles.startDate", "o.startDate", "lte", - ) - facility_cycle_end_date_check = PythonICATWhereFilter( - "facility.facilityCycles.endDate", "o.startDate", "gte", - ) - - required_filters = [ - instrument_id_check, - investigation_instrument_id_check, - facility_cycle_id_check, - facility_cycle_start_date_check, - facility_cycle_end_date_check, - ] - filters.extend(required_filters) - filter_handler = FilterOrderHandler() - filter_handler.manage_icat_filters(filters, query.query) - - data = query.execute_query(client, True) - - return data - - -def get_investigations_for_instrument_in_facility_cycle_count( - client, instrument_id, facilitycycle_id, filters, -): - """ - Given Instrument and Facility Cycle IDs, get the number of investigations that use - the given instrument in the given cycle - - :param client: ICAT client containing an authenticated user - :type client: :class:`icat.client.Client` - :param instrument_id: ID of the instrument from the request - :type instrument_id: :class:`int` - :param facilitycycle_id: ID of the facilityCycle from the request - :type facilitycycle_id: :class:`int` - :param filters: The list of filters to be applied to the request - :type filters: List of specific implementations :class:`QueryFilter` - :return: The number of Investigations that match the query - """ - log.info( - "Getting the number of investigations from the specified instrument and" - " facility cycle, for ISIS", - ) - return get_investigations_for_instrument_in_facility_cycle( - client, instrument_id, facilitycycle_id, filters, count_query=True, - )[0] diff --git a/datagateway_api/src/datagateway_api/icat/query.py b/datagateway_api/src/datagateway_api/icat/query.py index 2ac43590..424014e5 100644 --- a/datagateway_api/src/datagateway_api/icat/query.py +++ b/datagateway_api/src/datagateway_api/icat/query.py @@ -37,9 +37,6 @@ def __init__( :raises PythonICATError: If a ValueError is raised when creating a Query(), 500 will be returned as a response """ - # Needed for ISIS endpoints as they use DISTINCT keyword but don't select - # multiple attributes - self.isis_endpoint = False try: log.info("Creating ICATQuery for entity: %s", entity_name) @@ -96,7 +93,6 @@ def execute_query(self, client, return_json_formattable=False): self.query.aggregate == "DISTINCT" and not count_query and not self.query.manual_count - and not self.isis_endpoint ): distinct_query = True log.info("Extracting the distinct fields from query's conditions") diff --git a/datagateway_api/src/resources/table_endpoints/table_endpoints.py b/datagateway_api/src/resources/table_endpoints/table_endpoints.py deleted file mode 100644 index 0ad33d35..00000000 --- a/datagateway_api/src/resources/table_endpoints/table_endpoints.py +++ /dev/null @@ -1,281 +0,0 @@ -from flask_restful import Resource - -from datagateway_api.src.common.helpers import ( - get_filters_from_query_string, - get_session_id_from_auth_header, -) - - -def instrument_facility_cycles_endpoint(backend, **kwargs): - """ - Generate a flask_restful Resource class using the configured backend. In main.py - these generated classes are registered with the api e.g. - `api.add_resource(get_endpoint("Datafiles", DATAFILE), "/datafiles")` - - :param backend: The backend instance used for processing requests - :type backend: :class:`DatabaseBackend` or :class:`PythonICATBackend` - :return: The generated endpoint class - """ - pass - - class InstrumentsFacilityCycles(Resource): - def get(self, id_): - """ - --- - summary: Get an Instrument's FacilityCycles - description: Given an Instrument id get facility cycles where the instrument - has investigations that occur within that cycle, subject to the given - filters - tags: - - FacilityCycles - parameters: - - in: path - required: true - name: id_ - description: The id of the instrument to retrieve the facility cycles - of - schema: - type: integer - - WHERE_FILTER - - ORDER_FILTER - - LIMIT_FILTER - - SKIP_FILTER - - DISTINCT_FILTER - - INCLUDE_FILTER - responses: - 200: - description: Success - returns a list of the instrument's facility - cycles that satisfy the filters - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/FACILITYCYCLE' - 400: - description: Bad request - Something was wrong with the request - 401: - description: Unauthorized - No session ID found in HTTP Auth. header - 403: - description: Forbidden - The session ID provided is invalid - 404: - description: No such record - Unable to find a record in ICAT - """ - return ( - backend.get_facility_cycles_for_instrument_with_filters( - get_session_id_from_auth_header(), - id_, - get_filters_from_query_string("datagateway_api"), - **kwargs, - ), - 200, - ) - - return InstrumentsFacilityCycles - - -def count_instrument_facility_cycles_endpoint(backend, **kwargs): - """ - Generate a flask_restful Resource class using the configured backend. In main.py - these generated classes are registered with the api e.g. - `api.add_resource(get_endpoint("Datafiles", DATAFILE), "/datafiles")` - - :param backend: The backend instance used for processing requests - :type backend: :class:`DatabaseBackend` or :class:`PythonICATBackend` - :return: The generated endpoint class - """ - pass - - class InstrumentsFacilityCyclesCount(Resource): - def get(self, id_): - """ - --- - summary: Count an Instrument's FacilityCycles - description: Return the count of the Facility Cycles that have - investigations that occur within that cycle on the specified instrument - that would be retrieved given the filters provided - tags: - - FacilityCycles - parameters: - - in: path - required: true - name: id_ - description: The id of the instrument to count the facility cycles of - schema: - type: integer - - WHERE_FILTER - - DISTINCT_FILTER - responses: - 200: - description: Success - The count of the instrument's facility cycles - that satisfy the filters - content: - application/json: - schema: - type: integer - 400: - description: Bad request - Something was wrong with the request - 401: - description: Unauthorized - No session ID found in HTTP Auth. header - 403: - description: Forbidden - The session ID provided is invalid - 404: - description: No such record - Unable to find a record in ICAT - """ - return ( - backend.get_facility_cycles_for_instrument_count_with_filters( - get_session_id_from_auth_header(), - id_, - get_filters_from_query_string("datagateway_api"), - **kwargs, - ), - 200, - ) - - return InstrumentsFacilityCyclesCount - - -def instrument_investigation_endpoint(backend, **kwargs): - """ - Generate a flask_restful Resource class using the configured backend. In main.py - these generated classes are registered with the api e.g. - `api.add_resource(get_endpoint("Datafiles", DATAFILE), "/datafiles")` - - :param backend: The backend instance used for processing requests - :type backend: :class:`DatabaseBackend` or :class:`PythonICATBackend` - :return: The generated endpoint class - """ - pass - - class InstrumentsFacilityCyclesInvestigations(Resource): - def get(self, instrument_id, cycle_id): - """ - --- - summary: Get the investigations for a given Facility Cycle & Instrument - description: Given an Instrument id and Facility Cycle id, get the - investigations that occur within that cycle on that instrument, subject - to the given filters - tags: - - Investigations - parameters: - - in: path - required: true - name: instrument_id - description: The id of the instrument to retrieve the investigations - of - schema: - type: integer - - in: path - required: true - name: cycle_id - description: The id of the facility cycle to retrieve the - investigations - schema: - type: integer - - WHERE_FILTER - - ORDER_FILTER - - LIMIT_FILTER - - SKIP_FILTER - - DISTINCT_FILTER - - INCLUDE_FILTER - responses: - 200: - description: Success - returns a list of the investigations for the - given instrument and facility cycle that satisfy the filters - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/INVESTIGATION' - 400: - description: Bad request - Something was wrong with the request - 401: - description: Unauthorized - No session ID found in HTTP Auth. header - 403: - description: Forbidden - The session ID provided is invalid - 404: - description: No such record - Unable to find a record in ICAT - """ - return ( - backend.get_investigations_for_instrument_facility_cycle_with_filters( - get_session_id_from_auth_header(), - instrument_id, - cycle_id, - get_filters_from_query_string("datagateway_api"), - **kwargs, - ), - 200, - ) - - return InstrumentsFacilityCyclesInvestigations - - -def count_instrument_investigation_endpoint(backend, **kwargs): - """ - Generate a flask_restful Resource class using the configured backend. In main.py - these generated classes are registered with the api e.g. - `api.add_resource(get_endpoint("Datafiles", DATAFILE), "/datafiles")` - - :param backend: The backend instance used for processing requests - :type backend: :class:`DatabaseBackend` or :class:`PythonICATBackend` - :return: The generated endpoint class - """ - pass - - class InstrumentsFacilityCyclesInvestigationsCount(Resource): - def get(self, instrument_id, cycle_id): - """ - --- - summary: Count investigations for a given Facility Cycle & Instrument - description: Given an Instrument id and Facility Cycle id, get the number of - investigations that occur within that cycle on that instrument, subject - to the given filters - tags: - - Investigations - parameters: - - in: path - required: true - name: instrument_id - description: The id of the instrument to retrieve the investigations - of - schema: - type: integer - - in: path - required: true - name: cycle_id - description: The id of the facility cycle to retrieve the - investigations - schema: - type: integer - - WHERE_FILTER - - DISTINCT_FILTER - responses: - 200: - description: Success - The count of the investigations for the given - instrument and facility cycle that satisfy the filters - content: - application/json: - schema: - type: integer - 400: - description: Bad request - Something was wrong with the request - 401: - description: Unauthorized - No session ID found in HTTP Auth. header - 403: - description: Forbidden - The session ID provided is invalid - 404: - description: No such record - Unable to find a record in ICAT - """ - return ( - backend.get_investigation_count_instrument_facility_cycle_with_filters( - get_session_id_from_auth_header(), - instrument_id, - cycle_id, - get_filters_from_query_string("datagateway_api"), - **kwargs, - ), - 200, - ) - - return InstrumentsFacilityCyclesInvestigationsCount diff --git a/datagateway_api/src/swagger/datagateway_api/openapi.yaml b/datagateway_api/src/swagger/datagateway_api/openapi.yaml index 4bc3947f..bb80fe0b 100644 --- a/datagateway_api/src/swagger/datagateway_api/openapi.yaml +++ b/datagateway_api/src/swagger/datagateway_api/openapi.yaml @@ -14709,160 +14709,6 @@ paths: summary: Refresh session tags: - Sessions - /datagateway-api/instruments/{id_}/facilitycycles: - get: - description: Given an Instrument id get facility cycles where the instrument - has investigations that occur within that cycle, subject to the given filters - parameters: - - description: The id of the instrument to retrieve the facility cycles of - in: path - name: id_ - required: true - schema: - type: integer - - $ref: '#/components/parameters/WHERE_FILTER' - - $ref: '#/components/parameters/ORDER_FILTER' - - $ref: '#/components/parameters/LIMIT_FILTER' - - $ref: '#/components/parameters/SKIP_FILTER' - - $ref: '#/components/parameters/DISTINCT_FILTER' - - $ref: '#/components/parameters/INCLUDE_FILTER' - responses: - '200': - content: - application/json: - schema: - items: - $ref: '#/components/schemas/FACILITYCYCLE' - type: array - description: Success - returns a list of the instrument's facility cycles - that satisfy the filters - '400': - description: Bad request - Something was wrong with the request - '401': - description: Unauthorized - No session ID found in HTTP Auth. header - '403': - description: Forbidden - The session ID provided is invalid - '404': - description: No such record - Unable to find a record in ICAT - summary: Get an Instrument's FacilityCycles - tags: - - FacilityCycles - /datagateway-api/instruments/{id_}/facilitycycles/count: - get: - description: Return the count of the Facility Cycles that have investigations - that occur within that cycle on the specified instrument that would be retrieved - given the filters provided - parameters: - - description: The id of the instrument to count the facility cycles of - in: path - name: id_ - required: true - schema: - type: integer - - $ref: '#/components/parameters/WHERE_FILTER' - - $ref: '#/components/parameters/DISTINCT_FILTER' - responses: - '200': - content: - application/json: - schema: - type: integer - description: Success - The count of the instrument's facility cycles that - satisfy the filters - '400': - description: Bad request - Something was wrong with the request - '401': - description: Unauthorized - No session ID found in HTTP Auth. header - '403': - description: Forbidden - The session ID provided is invalid - '404': - description: No such record - Unable to find a record in ICAT - summary: Count an Instrument's FacilityCycles - tags: - - FacilityCycles - /datagateway-api/instruments/{instrument_id}/facilitycycles/{cycle_id}/investigations: - get: - description: Given an Instrument id and Facility Cycle id, get the investigations - that occur within that cycle on that instrument, subject to the given filters - parameters: - - description: The id of the instrument to retrieve the investigations of - in: path - name: instrument_id - required: true - schema: - type: integer - - description: The id of the facility cycle to retrieve the investigations - in: path - name: cycle_id - required: true - schema: - type: integer - - $ref: '#/components/parameters/WHERE_FILTER' - - $ref: '#/components/parameters/ORDER_FILTER' - - $ref: '#/components/parameters/LIMIT_FILTER' - - $ref: '#/components/parameters/SKIP_FILTER' - - $ref: '#/components/parameters/DISTINCT_FILTER' - - $ref: '#/components/parameters/INCLUDE_FILTER' - responses: - '200': - content: - application/json: - schema: - items: - $ref: '#/components/schemas/INVESTIGATION' - type: array - description: Success - returns a list of the investigations for the given - instrument and facility cycle that satisfy the filters - '400': - description: Bad request - Something was wrong with the request - '401': - description: Unauthorized - No session ID found in HTTP Auth. header - '403': - description: Forbidden - The session ID provided is invalid - '404': - description: No such record - Unable to find a record in ICAT - summary: Get the investigations for a given Facility Cycle & Instrument - tags: - - Investigations - /datagateway-api/instruments/{instrument_id}/facilitycycles/{cycle_id}/investigations/count: - get: - description: Given an Instrument id and Facility Cycle id, get the number of - investigations that occur within that cycle on that instrument, subject to - the given filters - parameters: - - description: The id of the instrument to retrieve the investigations of - in: path - name: instrument_id - required: true - schema: - type: integer - - description: The id of the facility cycle to retrieve the investigations - in: path - name: cycle_id - required: true - schema: - type: integer - - $ref: '#/components/parameters/WHERE_FILTER' - - $ref: '#/components/parameters/DISTINCT_FILTER' - responses: - '200': - content: - application/json: - schema: - type: integer - description: Success - The count of the investigations for the given instrument - and facility cycle that satisfy the filters - '400': - description: Bad request - Something was wrong with the request - '401': - description: Unauthorized - No session ID found in HTTP Auth. header - '403': - description: Forbidden - The session ID provided is invalid - '404': - description: No such record - Unable to find a record in ICAT - summary: Count investigations for a given Facility Cycle & Instrument - tags: - - Investigations /datagateway-api/ping: get: description: Pings the API's connection method to check responsiveness diff --git a/test/integration/datagateway_api/db/conftest.py b/test/integration/datagateway_api/db/conftest.py index 33e1e0f2..124801c9 100644 --- a/test/integration/datagateway_api/db/conftest.py +++ b/test/integration/datagateway_api/db/conftest.py @@ -11,7 +11,6 @@ insert_row_into_table, ) from datagateway_api.src.datagateway_api.database.models import ( - FACILITYCYCLE, INSTRUMENT, INVESTIGATION, INVESTIGATIONINSTRUMENT, @@ -87,19 +86,7 @@ def multiple_investigation_test_data_db(): @pytest.fixture() -def isis_specific_endpoint_data_db(): - facility_cycle = FACILITYCYCLE() - facility_cycle.name = "Test cycle for DG API testing (DB)" - facility_cycle.startDate = datetime( - year=2020, month=1, day=1, hour=1, minute=1, second=1, - ) - facility_cycle.endDate = datetime( - year=2020, month=2, day=1, hour=1, minute=1, second=1, - ) - facility_cycle.facilityID = 1 - set_meta_attributes(facility_cycle) - insert_row_into_table(FACILITYCYCLE, facility_cycle) - +def related_distinct_data_db(): investigation = create_investigation_db_data() instrument = INSTRUMENT() @@ -115,10 +102,9 @@ def isis_specific_endpoint_data_db(): insert_row_into_table(INVESTIGATIONINSTRUMENT, investigation_instrument) - yield (instrument.id, facility_cycle, investigation) + yield (instrument.id, investigation) delete_row_by_id(INVESTIGATIONINSTRUMENT, investigation_instrument.id) - delete_row_by_id(FACILITYCYCLE, facility_cycle.id) delete_row_by_id(INVESTIGATION, investigation.id) delete_row_by_id(INSTRUMENT, instrument.id) diff --git a/test/integration/datagateway_api/db/endpoints/test_get_with_filters.py b/test/integration/datagateway_api/db/endpoints/test_get_with_filters.py index 98d2910f..3a0bb257 100644 --- a/test/integration/datagateway_api/db/endpoints/test_get_with_filters.py +++ b/test/integration/datagateway_api/db/endpoints/test_get_with_filters.py @@ -119,7 +119,7 @@ def test_valid_get_with_filters_multiple_distinct( ), ], ) - @pytest.mark.usefixtures("isis_specific_endpoint_data_db") + @pytest.mark.usefixtures("related_distinct_data_db") def test_valid_get_with_filters_related_distinct( self, flask_test_app_db, diff --git a/test/integration/datagateway_api/db/endpoints/test_table_endpoints_db.py b/test/integration/datagateway_api/db/endpoints/test_table_endpoints_db.py deleted file mode 100644 index 1af26ddb..00000000 --- a/test/integration/datagateway_api/db/endpoints/test_table_endpoints_db.py +++ /dev/null @@ -1,121 +0,0 @@ -from datagateway_api.src.common.config import Config - - -class TestDBTableEndpoints: - """ - This class tests the endpoints defined in table_endpoints.py, commonly referred to - as the ISIS specific endpoints - """ - - def test_valid_get_facility_cycles_with_filters( - self, - flask_test_app_db, - valid_db_credentials_header, - isis_specific_endpoint_data_db, - ): - test_response = flask_test_app_db.get( - f"{Config.config.datagateway_api.extension}/instruments" - f"/{int(isis_specific_endpoint_data_db[0])}/facilitycycles", - headers=valid_db_credentials_header, - ) - - assert test_response.json[0] == isis_specific_endpoint_data_db[1].to_dict() - - def test_invalid_get_facility_cycles_with_filters( - self, flask_test_app_db, valid_db_credentials_header, final_instrument_id, - ): - test_response = flask_test_app_db.get( - f"{Config.config.datagateway_api.extension}/instruments" - f"/{final_instrument_id + 100}/facilitycycles", - headers=valid_db_credentials_header, - ) - - assert test_response.json == [] - - def test_valid_get_facility_cycles_count_with_filters( - self, - flask_test_app_db, - valid_db_credentials_header, - isis_specific_endpoint_data_db, - ): - test_response = flask_test_app_db.get( - f"{Config.config.datagateway_api.extension}/instruments" - f"/{isis_specific_endpoint_data_db[0]}/facilitycycles/count", - headers=valid_db_credentials_header, - ) - - assert test_response.json == 1 - - def test_invalid_get_facility_cycles_count_with_filters( - self, flask_test_app_db, valid_db_credentials_header, final_instrument_id, - ): - test_response = flask_test_app_db.get( - f"{Config.config.datagateway_api.extension}/instruments" - f"/{final_instrument_id + 100}/facilitycycles/count", - headers=valid_db_credentials_header, - ) - - assert test_response.json == 0 - - def test_valid_get_investigations_with_filters( - self, - flask_test_app_db, - valid_db_credentials_header, - isis_specific_endpoint_data_db, - ): - test_response = flask_test_app_db.get( - f"{Config.config.datagateway_api.extension}/instruments" - f"/{isis_specific_endpoint_data_db[0]}/facilitycycles" - f"/{isis_specific_endpoint_data_db[1].to_dict()['id']}/investigations", - headers=valid_db_credentials_header, - ) - - assert test_response.json == [isis_specific_endpoint_data_db[2].to_dict()] - - def test_invalid_get_investigations_with_filters( - self, - flask_test_app_db, - valid_db_credentials_header, - final_instrument_id, - final_facilitycycle_id, - ): - test_response = flask_test_app_db.get( - f"{Config.config.datagateway_api.extension}/instruments" - f"/{final_instrument_id + 100}/facilitycycles" - f"/{final_facilitycycle_id + 100}/investigations", - headers=valid_db_credentials_header, - ) - - assert test_response.json == [] - - def test_valid_get_investigations_count_with_filters( - self, - flask_test_app_db, - valid_db_credentials_header, - isis_specific_endpoint_data_db, - ): - test_response = flask_test_app_db.get( - f"{Config.config.datagateway_api.extension}/instruments" - f"/{isis_specific_endpoint_data_db[0]}/facilitycycles" - f"/{isis_specific_endpoint_data_db[1].to_dict()['id']}" - "/investigations/count", - headers=valid_db_credentials_header, - ) - - assert test_response.json == 1 - - def test_invalid_get_investigations_count_with_filters( - self, - flask_test_app_db, - valid_db_credentials_header, - final_instrument_id, - final_facilitycycle_id, - ): - test_response = flask_test_app_db.get( - f"{Config.config.datagateway_api.extension}/instruments" - f"/{final_instrument_id + 100}/facilitycycles" - f"/{final_facilitycycle_id + 100}/investigations/count", - headers=valid_db_credentials_header, - ) - - assert test_response.json == 0 diff --git a/test/integration/datagateway_api/icat/conftest.py b/test/integration/datagateway_api/icat/conftest.py index 18ea25e8..8130d433 100644 --- a/test/integration/datagateway_api/icat/conftest.py +++ b/test/integration/datagateway_api/icat/conftest.py @@ -94,45 +94,6 @@ def flask_test_app_icat(flask_test_app): yield icat_app.test_client() -@pytest.fixture() -def isis_specific_endpoint_data(icat_client): - facility_cycle = icat_client.new("facilityCycle") - facility_cycle.name = "Test cycle for DataGateway API testing" - facility_cycle.startDate = datetime( - year=2020, month=1, day=1, hour=1, minute=1, second=1, tzinfo=tzlocal(), - ) - facility_cycle.endDate = datetime( - year=2020, month=2, day=1, hour=1, minute=1, second=1, tzinfo=tzlocal(), - ) - facility_cycle.facility = icat_client.get("Facility", 1) - facility_cycle.create() - - investigation = create_investigation_test_data(icat_client) - investigation_dict = prepare_icat_data_for_assertion([investigation]) - - instrument = icat_client.new("instrument") - instrument.name = "Test Instrument for DataGateway API Endpoint Testing" - instrument.facility = icat_client.get("Facility", 1) - instrument.create() - - investigation_instrument = icat_client.new("investigationInstrument") - investigation_instrument.investigation = investigation - investigation_instrument.instrument = instrument - investigation_instrument.create() - - facility_cycle_dict = prepare_icat_data_for_assertion([facility_cycle]) - - yield (instrument.id, facility_cycle_dict, facility_cycle.id, investigation_dict) - - try: - # investigation_instrument removed when deleting the objects its related objects - icat_client.delete(facility_cycle) - icat_client.delete(investigation) - icat_client.delete(instrument) - except ICATNoObjectError as e: - print(e) - - @pytest.fixture() def final_instrument_id(flask_test_app_icat, valid_icat_credentials_header): final_instrument_result = flask_test_app_icat.get( diff --git a/test/integration/datagateway_api/icat/endpoints/test_table_endpoints_icat.py b/test/integration/datagateway_api/icat/endpoints/test_table_endpoints_icat.py deleted file mode 100644 index f6e29ccb..00000000 --- a/test/integration/datagateway_api/icat/endpoints/test_table_endpoints_icat.py +++ /dev/null @@ -1,127 +0,0 @@ -from datagateway_api.src.common.config import Config -from test.integration.datagateway_api.icat.test_query import ( - prepare_icat_data_for_assertion, -) - - -class TestICATableEndpoints: - """ - This class tests the endpoints defined in table_endpoints.py, commonly referred to - as the ISIS specific endpoints - """ - - def test_valid_get_facility_cycles_with_filters( - self, - flask_test_app_icat, - valid_icat_credentials_header, - isis_specific_endpoint_data, - ): - test_response = flask_test_app_icat.get( - f"{Config.config.datagateway_api.extension}/instruments" - f"/{isis_specific_endpoint_data[0]}/facilitycycles", - headers=valid_icat_credentials_header, - ) - - response_json = prepare_icat_data_for_assertion(test_response.json) - - assert response_json == isis_specific_endpoint_data[1] - - def test_invalid_get_facility_cycles_with_filters( - self, flask_test_app_icat, valid_icat_credentials_header, final_instrument_id, - ): - test_response = flask_test_app_icat.get( - f"{Config.config.datagateway_api.extension}/instruments" - f"/{final_instrument_id + 100}/facilitycycles", - headers=valid_icat_credentials_header, - ) - - assert test_response.json == [] - - def test_valid_get_facility_cycles_count_with_filters( - self, - flask_test_app_icat, - valid_icat_credentials_header, - isis_specific_endpoint_data, - ): - test_response = flask_test_app_icat.get( - f"{Config.config.datagateway_api.extension}/instruments" - f"/{isis_specific_endpoint_data[0]}/facilitycycles/count", - headers=valid_icat_credentials_header, - ) - - assert test_response.json == 1 - - def test_invalid_get_facility_cycles_count_with_filters( - self, flask_test_app_icat, valid_icat_credentials_header, final_instrument_id, - ): - test_response = flask_test_app_icat.get( - f"{Config.config.datagateway_api.extension}/instruments" - f"/{final_instrument_id + 100}/facilitycycles/count", - headers=valid_icat_credentials_header, - ) - - assert test_response.json == 0 - - def test_valid_get_investigations_with_filters( - self, - flask_test_app_icat, - valid_icat_credentials_header, - isis_specific_endpoint_data, - ): - test_response = flask_test_app_icat.get( - f"{Config.config.datagateway_api.extension}/instruments" - f"/{isis_specific_endpoint_data[0]}/facilitycycles" - f"/{isis_specific_endpoint_data[2]}/investigations", - headers=valid_icat_credentials_header, - ) - - response_json = prepare_icat_data_for_assertion(test_response.json) - - assert response_json == isis_specific_endpoint_data[3] - - def test_invalid_get_investigations_with_filters( - self, - flask_test_app_icat, - valid_icat_credentials_header, - final_instrument_id, - final_facilitycycle_id, - ): - test_response = flask_test_app_icat.get( - f"{Config.config.datagateway_api.extension}/instruments" - f"/{final_instrument_id + 100}/facilitycycles" - f"/{final_facilitycycle_id + 100}/investigations", - headers=valid_icat_credentials_header, - ) - - assert test_response.json == [] - - def test_valid_get_investigations_count_with_filters( - self, - flask_test_app_icat, - valid_icat_credentials_header, - isis_specific_endpoint_data, - ): - test_response = flask_test_app_icat.get( - f"{Config.config.datagateway_api.extension}/instruments" - f"/{isis_specific_endpoint_data[0]}/facilitycycles" - f"/{isis_specific_endpoint_data[2]}/investigations/count", - headers=valid_icat_credentials_header, - ) - - assert test_response.json == 1 - - def test_invalid_get_investigations_count_with_filters( - self, - flask_test_app_icat, - valid_icat_credentials_header, - final_instrument_id, - final_facilitycycle_id, - ): - test_response = flask_test_app_icat.get( - f"{Config.config.datagateway_api.extension}/instruments" - f"/{final_instrument_id + 100}/facilitycycles" - f"/{final_facilitycycle_id + 100}/investigations/count", - headers=valid_icat_credentials_header, - ) - - assert test_response.json == 0 diff --git a/test/integration/datagateway_api/test_backends.py b/test/integration/datagateway_api/test_backends.py index 333efa93..26d597b4 100644 --- a/test/integration/datagateway_api/test_backends.py +++ b/test/integration/datagateway_api/test_backends.py @@ -39,8 +39,6 @@ class DummyBackend(Backend): entity_type = "entity_type" filters = "filters" data = "data" - instrument_id = "instrument_id" - facilitycycle_id = "facilitycycle_id" id_ = "id_" assert d.ping() is None @@ -56,27 +54,3 @@ class DummyBackend(Backend): assert d.get_with_id(session_id, entity_type, id_) is None assert d.delete_with_id(session_id, entity_type, id_) is None assert d.update_with_id(session_id, entity_type, id_, data) is None - assert ( - d.get_facility_cycles_for_instrument_with_filters( - session_id, instrument_id, filters, - ) - is None - ) - assert ( - d.get_facility_cycles_for_instrument_count_with_filters( - session_id, instrument_id, filters, - ) - is None - ) - assert ( - d.get_investigations_for_instrument_facility_cycle_with_filters( - session_id, instrument_id, facilitycycle_id, filters, - ) - is None - ) - assert ( - d.get_investigation_count_instrument_facility_cycle_with_filters( - session_id, instrument_id, facilitycycle_id, filters, - ) - is None - ) diff --git a/test/integration/test_endpoint_rules.py b/test/integration/test_endpoint_rules.py index 39afab27..5fce4ace 100644 --- a/test/integration/test_endpoint_rules.py +++ b/test/integration/test_endpoint_rules.py @@ -44,31 +44,6 @@ def test_entity_endpoints(self, flask_test_app, endpoint_ending, expected_method ["DELETE", "GET", "POST", "PUT"], id="sessions", ), - pytest.param( - f"{Config.config.datagateway_api.extension}/instruments/" - f"/facilitycycles", - ["GET"], - id="ISIS instrument's facility cycles", - ), - pytest.param( - f"{Config.config.datagateway_api.extension}/instruments/" - f"/facilitycycles/count", - ["GET"], - id="count ISIS instrument's facility cycles", - ), - pytest.param( - f"{Config.config.datagateway_api.extension}/instruments" - "//facilitycycles//investigations", - ["GET"], - id="ISIS investigations", - ), - pytest.param( - f"{Config.config.datagateway_api.extension}/instruments" - "//facilitycycles//investigations" - "/count", - ["GET"], - id="count ISIS investigations", - ), pytest.param( f"{Config.config.search_api.extension}/Datasets", ["GET"], diff --git a/util/postman_collection_icat.json b/util/postman_collection_icat.json index fcacaccc..bdbb904f 100644 --- a/util/postman_collection_icat.json +++ b/util/postman_collection_icat.json @@ -37374,157 +37374,6 @@ } ] }, - { - "name": "ISIS Specific Endpoints", - "item": [ - { - "name": "Instrument Facility Cycles", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{sessionID}}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [], - "url": { - "raw": "http://{{datagateway-api}}/instruments/23/facilitycycles?order=\"id asc\"", - "protocol": "http", - "host": [ - "{{datagateway-api}}" - ], - "path": [ - "instruments", - "23", - "facilitycycles" - ], - "query": [ - { - "key": "order", - "value": "\"id asc\"" - } - ] - } - }, - "response": [] - }, - { - "name": "Count Instrument Facility Cycles", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "http://{{datagateway-api}}/instruments/23/facilitycycles/count", - "protocol": "http", - "host": [ - "{{datagateway-api}}" - ], - "path": [ - "instruments", - "23", - "facilitycycles", - "count" - ] - } - }, - "response": [] - }, - { - "name": "Instrument Facility Cycles Investigations", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "http://{{datagateway-api}}/instruments/23/facilitycycles/84762458/investigations?order=\"id asc\"", - "protocol": "http", - "host": [ - "{{datagateway-api}}" - ], - "path": [ - "instruments", - "23", - "facilitycycles", - "84762458", - "investigations" - ], - "query": [ - { - "key": "order", - "value": "\"id asc\"" - }, - { - "key": "where", - "value": "{\"investigationInstruments.instrument.name\": {\"like\": \"ALF\"}}", - "disabled": true - }, - { - "key": "include", - "value": "\"investigationInstruments.instrument\"", - "disabled": true - }, - { - "key": "distinct", - "value": "\"id\"", - "disabled": true - } - ] - } - }, - "response": [] - }, - { - "name": "Count Instrument Facility Cycles Investigations", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "http://{{datagateway-api}}/instruments/23/facilitycycles/84762458/investigations/count", - "protocol": "http", - "host": [ - "{{datagateway-api}}" - ], - "path": [ - "instruments", - "23", - "facilitycycles", - "84762458", - "investigations", - "count" - ] - } - }, - "response": [] - } - ], - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{sessionID}}", - "type": "string" - } - ] - }, - "event": [ - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "pm.test(\"Status: 200\", function () {", - " pm.response.to.have.status(200);", - "});" - ] - } - } - ] - }, { "name": "Session Related Requests", "item": [