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(),
             **kwargs,
         ),
         200,
     )
Exemple #2
0
 def get(self):
     filters = get_filters_from_query_string()
     return (
         backend.get_one_with_filters(
             get_session_id_from_auth_header(), entity_type, filters, **kwargs,
         ),
         200,
     )
 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(),
             **kwargs,
         ),
         200,
     )
    def test_valid_multiple_filters(self, flask_test_app_db):
        with flask_test_app_db:
            flask_test_app_db.get("/?limit=10&skip=4")
            filters = get_filters_from_query_string()

            assert len(filters) == 2
    def test_valid_filter(self, flask_test_app_db, filter_input, filter_type):
        with flask_test_app_db:
            flask_test_app_db.get(f"/?{filter_input}")
            filters = get_filters_from_query_string()

            assert isinstance(filters[0], filter_type)
    def test_invalid_filter(self, flask_test_app_db):
        with flask_test_app_db:
            flask_test_app_db.get('/?test="test"')

            with pytest.raises(FilterError):
                get_filters_from_query_string()
    def test_valid_no_filters(self, flask_test_app_db):
        with flask_test_app_db:
            flask_test_app_db.get("/")

            assert [] == get_filters_from_query_string()