diff --git a/datagateway_api/common/backend.py b/datagateway_api/common/backend.py index c09d06a6..a6ca914a 100644 --- a/datagateway_api/common/backend.py +++ b/datagateway_api/common/backend.py @@ -172,7 +172,7 @@ def get_facility_cycles_for_instrument_count_with_filters( pass @abstractmethod - def get_investigations_for_instrument_in_facility_cycle_with_filters( + def get_investigations_for_instrument_facility_cycle_with_filters( self, session_id, instrument_id, facilitycycle_id, filters, ): """ @@ -188,7 +188,7 @@ def get_investigations_for_instrument_in_facility_cycle_with_filters( pass @abstractmethod - def get_investigation_count_for_instrument_facility_cycle_with_filters( + def get_investigation_count_instrument_facility_cycle_with_filters( self, session_id, instrument_id, facilitycycle_id, filters, ): """ diff --git a/datagateway_api/common/database/backend.py b/datagateway_api/common/database/backend.py index 65d7eb6c..8ee01d87 100644 --- a/datagateway_api/common/database/backend.py +++ b/datagateway_api/common/database/backend.py @@ -124,7 +124,7 @@ def get_facility_cycles_for_instrument_count_with_filters( @requires_session_id @queries_records - def get_investigations_for_instrument_in_facility_cycle_with_filters( + def get_investigations_for_instrument_facility_cycle_with_filters( self, session_id, instrument_id, facilitycycle_id, filters, ): return get_investigations_for_instrument_in_facility_cycle( @@ -133,7 +133,7 @@ def get_investigations_for_instrument_in_facility_cycle_with_filters( @requires_session_id @queries_records - def get_investigation_count_for_instrument_facility_cycle_with_filters( + def get_investigation_count_instrument_facility_cycle_with_filters( self, session_id, instrument_id, facilitycycle_id, filters, ): return get_investigations_for_instrument_in_facility_cycle_count( diff --git a/datagateway_api/common/helpers.py b/datagateway_api/common/helpers.py index 55dec407..0a86dd33 100644 --- a/datagateway_api/common/helpers.py +++ b/datagateway_api/common/helpers.py @@ -6,7 +6,6 @@ from flask_restful import reqparse from sqlalchemy.exc import IntegrityError -from datagateway_api.common.query_filter import QueryFilterFactory from datagateway_api.common.exceptions import ( ApiError, AuthenticationError, @@ -14,6 +13,7 @@ FilterError, MissingCredentialsError, ) +from datagateway_api.common.query_filter import QueryFilterFactory log = logging.getLogger() diff --git a/datagateway_api/common/icat/backend.py b/datagateway_api/common/icat/backend.py index d4167546..af206560 100644 --- a/datagateway_api/common/icat/backend.py +++ b/datagateway_api/common/icat/backend.py @@ -136,7 +136,7 @@ def get_facility_cycles_for_instrument_count_with_filters( @requires_session_id @queries_records - def get_investigations_for_instrument_in_facility_cycle_with_filters( + def get_investigations_for_instrument_facility_cycle_with_filters( self, session_id, instrument_id, facilitycycle_id, filters, **kwargs, ): client = kwargs["client"] if kwargs["client"] else create_client() @@ -146,7 +146,7 @@ def get_investigations_for_instrument_in_facility_cycle_with_filters( @requires_session_id @queries_records - def get_investigation_count_for_instrument_facility_cycle_with_filters( + def get_investigation_count_instrument_facility_cycle_with_filters( self, session_id, instrument_id, facilitycycle_id, filters, **kwargs, ): client = kwargs["client"] if kwargs["client"] else create_client() diff --git a/datagateway_api/common/query_filter.py b/datagateway_api/common/query_filter.py index f81067b3..e0928ff2 100644 --- a/datagateway_api/common/query_filter.py +++ b/datagateway_api/common/query_filter.py @@ -25,7 +25,6 @@ def get_query_filter(request_filter): """ backend_type = config.get_backend_type() - print(f"Backend inside staticmethod: {backend_type}") if backend_type == "db": from datagateway_api.common.database.filters import ( DatabaseDistinctFieldFilter as DistinctFieldFilter, diff --git a/datagateway_api/src/main.py b/datagateway_api/src/main.py index 8162e344..3b06614b 100644 --- a/datagateway_api/src/main.py +++ b/datagateway_api/src/main.py @@ -24,9 +24,9 @@ ) from datagateway_api.src.resources.table_endpoints.table_endpoints import ( count_instrument_facility_cycles_endpoint, + count_instrument_investigation_endpoint, instrument_facility_cycles_endpoint, instrument_investigation_endpoint, - count_instrument_investigation_endpoint, ) from datagateway_api.src.swagger.apispec_flask_restful import RestfulPlugin from datagateway_api.src.swagger.initialise_spec import initialise_spec @@ -51,7 +51,7 @@ def create_app_infrastructure(flask_app): security=[{"session_id": []}], ) - cors = CORS(flask_app) + CORS(flask_app) flask_app.url_map.strict_slashes = False api = Api(flask_app) @@ -70,24 +70,21 @@ def create_api_endpoints(flask_app, api, spec): try: backend_type = flask_app.config["TEST_BACKEND"] config.set_backend_type(backend_type) - print(f"test backend: {backend_type}") except KeyError: backend_type = config.get_backend_type() - print(f"config backend: {backend_type}") # TODO - Add :param backend: to the endpoint functions backend = create_backend(backend_type) - print(f"Backend: {backend}, Type: {type(backend)}") for entity_name in endpoints: get_endpoint_resource = get_endpoint( - entity_name, endpoints[entity_name], backend + entity_name, endpoints[entity_name], backend, ) api.add_resource(get_endpoint_resource, f"/{entity_name.lower()}") spec.path(resource=get_endpoint_resource, api=api) get_id_endpoint_resource = get_id_endpoint( - entity_name, endpoints[entity_name], backend + entity_name, endpoints[entity_name], backend, ) api.add_resource(get_id_endpoint_resource, f"/{entity_name.lower()}/") spec.path(resource=get_id_endpoint_resource, api=api) @@ -114,15 +111,15 @@ def create_api_endpoints(flask_app, api, spec): # Table specific endpoints instrument_facility_cycle_resource = instrument_facility_cycles_endpoint(backend) api.add_resource( - instrument_facility_cycle_resource, "/instruments//facilitycycles" + instrument_facility_cycle_resource, "/instruments//facilitycycles", ) # spec.path(resource=instrument_facility_cycle_resource, api=api) - count_instrument_facility_cycle_resource = count_instrument_facility_cycles_endpoint( - backend + count_instrument_facility_cycle_res = count_instrument_facility_cycles_endpoint( + backend, ) api.add_resource( - count_instrument_facility_cycle_resource, + count_instrument_facility_cycle_res, "/instruments//facilitycycles/count", ) # spec.path(resource=count_instrument_facility_cycle_resource, api=api) @@ -135,7 +132,7 @@ def create_api_endpoints(flask_app, api, spec): # spec.path(resource=instrument_investigation_resource, api=api) count_instrument_investigation_resource = count_instrument_investigation_endpoint( - backend + backend, ) api.add_resource( count_instrument_investigation_resource, diff --git a/datagateway_api/src/resources/entities/entity_endpoint.py b/datagateway_api/src/resources/entities/entity_endpoint.py index 3446913d..da26dbba 100644 --- a/datagateway_api/src/resources/entities/entity_endpoint.py +++ b/datagateway_api/src/resources/entities/entity_endpoint.py @@ -1,15 +1,11 @@ from flask import request from flask_restful import Resource -from datagateway_api.common.backends import create_backend -from datagateway_api.common.config import config from datagateway_api.common.helpers import ( get_filters_from_query_string, get_session_id_from_auth_header, ) -# backend = create_backend(config.get_backend_type()) - def get_endpoint(name, entity_type, backend): """ diff --git a/datagateway_api/src/resources/non_entities/sessions_endpoints.py b/datagateway_api/src/resources/non_entities/sessions_endpoints.py index 36a33922..febc969d 100644 --- a/datagateway_api/src/resources/non_entities/sessions_endpoints.py +++ b/datagateway_api/src/resources/non_entities/sessions_endpoints.py @@ -3,22 +3,17 @@ from flask import request from flask_restful import Resource -from datagateway_api.common.backends import create_backend -from datagateway_api.common.config import config from datagateway_api.common.exceptions import AuthenticationError from datagateway_api.common.helpers import get_session_id_from_auth_header log = logging.getLogger() -# backend = create_backend(config.get_backend_type()) - def session_endpoints(backend): """ TODO - Add docstring """ - log.info("test") class Sessions(Resource): def post(self): diff --git a/datagateway_api/src/resources/table_endpoints/table_endpoints.py b/datagateway_api/src/resources/table_endpoints/table_endpoints.py index 507d3295..6f2907a7 100644 --- a/datagateway_api/src/resources/table_endpoints/table_endpoints.py +++ b/datagateway_api/src/resources/table_endpoints/table_endpoints.py @@ -1,14 +1,10 @@ from flask_restful import Resource -from datagateway_api.common.backends import create_backend -from datagateway_api.common.config import config from datagateway_api.common.helpers import ( get_filters_from_query_string, get_session_id_from_auth_header, ) -backend = create_backend(config.get_backend_type()) - def instrument_facility_cycles_endpoint(backend): """ @@ -179,7 +175,7 @@ def get(self, instrument_id, cycle_id): description: No such record - Unable to find a record in ICAT """ return ( - backend.get_investigations_for_instrument_in_facility_cycle_with_filters( + backend.get_investigations_for_instrument_facility_cycle_with_filters( get_session_id_from_auth_header(), instrument_id, cycle_id, @@ -240,7 +236,7 @@ def get(self, instrument_id, cycle_id): description: No such record - Unable to find a record in ICAT """ return ( - backend.get_investigation_count_for_instrument_facility_cycle_with_filters( + backend.get_investigation_count_instrument_facility_cycle_with_filters( get_session_id_from_auth_header(), instrument_id, cycle_id, diff --git a/test/icat/endpoints/test_count_with_filters.py b/test/icat/endpoints/test_count_with_filters.py index 112af2f7..9fb8fe0e 100644 --- a/test/icat/endpoints/test_count_with_filters.py +++ b/test/icat/endpoints/test_count_with_filters.py @@ -4,7 +4,7 @@ class TestCountWithFilters: @pytest.mark.usefixtures("single_investigation_test_data") def test_valid_count_with_filters( - self, flask_test_app_icat, valid_credentials_header + self, flask_test_app_icat, valid_credentials_header, ): test_response = flask_test_app_icat.get( '/investigations/count?where={"title": {"like": "Test data for the Python' diff --git a/test/icat/endpoints/test_create.py b/test/icat/endpoints/test_create.py index ed253eea..e7f5137a 100644 --- a/test/icat/endpoints/test_create.py +++ b/test/icat/endpoints/test_create.py @@ -57,7 +57,7 @@ def test_valid_create_data(self, flask_test_app_icat, valid_credentials_header): ) def test_valid_boundary_create_data( - self, flask_test_app_icat, valid_credentials_header + self, flask_test_app_icat, valid_credentials_header, ): """Create a single investigation, as opposed to multiple""" diff --git a/test/icat/endpoints/test_delete_by_id.py b/test/icat/endpoints/test_delete_by_id.py index e0124001..4c811919 100644 --- a/test/icat/endpoints/test_delete_by_id.py +++ b/test/icat/endpoints/test_delete_by_id.py @@ -13,7 +13,7 @@ def test_valid_delete_with_id( assert test_response.status_code == 204 def test_invalid_delete_with_id( - self, flask_test_app_icat, valid_credentials_header + self, flask_test_app_icat, valid_credentials_header, ): """Request with a non-existent ID""" diff --git a/test/icat/endpoints/test_endpoint_rules.py b/test/icat/endpoints/test_endpoint_rules.py index f6e3c716..f703e4f6 100644 --- a/test/icat/endpoints/test_endpoint_rules.py +++ b/test/icat/endpoints/test_endpoint_rules.py @@ -61,7 +61,7 @@ def test_entity_endpoints(self, flask_test_app, endpoint_ending, expected_method ], ) def test_non_entity_endpoints( - self, flask_test_app, endpoint_name, expected_methods + self, flask_test_app, endpoint_name, expected_methods, ): endpoint_found = False diff --git a/test/icat/test_query.py b/test/icat/test_query.py index 8e11722d..6ee3e53d 100644 --- a/test/icat/test_query.py +++ b/test/icat/test_query.py @@ -122,7 +122,6 @@ def test_include_fields_list_flatten(self, icat_client): test_query = ICATQuery(icat_client, "User") flat_list = test_query.flatten_query_included_fields(included_field_set) - print(flat_list) assert flat_list == [ "instrumentScientists", diff --git a/test/icat/test_session_handling.py b/test/icat/test_session_handling.py index 6e329321..4828e6db 100644 --- a/test/icat/test_session_handling.py +++ b/test/icat/test_session_handling.py @@ -12,14 +12,12 @@ def test_session_id_decorator(self): pass def test_get_valid_session_details( - self, flask_test_app_icat, valid_credentials_header + self, flask_test_app_icat, valid_credentials_header, ): session_details = flask_test_app_icat.get( "/sessions", headers=valid_credentials_header, ) - print(f"JSON: {session_details.json}, Code: {session_details.status_code}") - # Check username is correct assert ( session_details.json["USERNAME"] == f"{config.get_test_mechanism()}/" diff --git a/test/test_helpers.py b/test/test_helpers.py index 5501a39f..b3972987 100644 --- a/test/test_helpers.py +++ b/test/test_helpers.py @@ -203,7 +203,7 @@ def test_limit_filter(self): 1, len(filters), msg="Returned incorrect number of filters", ) self.assertIs( - DatabaseLimitFilter, type(filters[0]), msg="Incorrect type of filter" + DatabaseLimitFilter, type(filters[0]), msg="Incorrect type of filter", ) def test_order_filter(self):