NASA-IMPACT / COSMOS

COSMOS is a web application designed to manage collections indexed in NASA's Science Discovery Engine (SDE), facilitating precise content selection and allowing metadata modification before indexing.
https://sde-indexing-helper.nasa-impact.net/
3 stars 1 forks source link

API Tests that Use Local Tokens to Actually Hit the Dev Server and Lis Server #1096

Open CarsonDavis opened 1 week ago

CarsonDavis commented 1 week ago

Description

Implementation Considerations

Deliverable

Dependencies

depends on #

### Acceptance Criteria
- [ ] Criteria 1
saifrk commented 2 days ago

Updated Api tests have been included in PR #1104, which tests the following:

-test_process_response_success: Validates that the process_response method correctly handles successful HTTP responses by returning the expected JSON data. -test_process_response_failure: Ensures that the process_response method raises an exception when the HTTP status code indicates a failure (e.g., 500 Internal Server Error). -test_query: Checks that the query method sends the correct payload to the backend and processes the response appropriately, expecting a successful result. -test_sql_query: Tests the execution of SQL queries via the API, including the correct processing and updating of returned data based on a specified SQL command and collection. -test_get_full_texts: Assesses the functionality for fetching full texts from the API, ensuring that data retrieval and subsequent processing are handled as expected. -test_process_and_update_data: Verifies that data received from the API is processed correctly and then updated in the database, checking the correctness of the operation by querying the database. -test_fetch_and_replace_full_text: Evaluates the Celery task responsible for fetching and replacing full text, ensuring that it processes and updates records correctly. -test_api_init: Validates the initialization of the Api class with different configurations, ensuring it handles both valid and invalid configurations appropriately. -test_query_dev_server_authentication: Tests the query functionality on development servers that require authentication, ensuring the correct credentials are appended to the request URL. -test_sql_query_pagination: Tests the SQL query functionality with pagination, making sure that the method handles multiple pages of results correctly. -test_process_full_text_response: Checks that the _process_full_text_response method correctly processes the batch data, transforming it into the expected format. -test_process_full_text_response_with_invalid_data: Tests error handling in the _process_full_text_response method, verifying it raises a ValueError when data is missing required elements or the 'Rows' key is absent. -test_sql_query_missing_token: Ensures that the sql_query method raises an error when no authentication token is available, which is required for accessing the SQL endpoint.

Note: The objective of these tests is also to assess how the server behaves and responds, ensuring that we are informed of any changes from the server end. Since potential changes are already accommodated through error handling in the code, there is no need to hit the actual servers.