sunholo-data / sunholo-py

A python library to enable GenAI and LLMOps within Google Cloud Platform
https://dev.sunholo.com/
Apache License 2.0
11 stars 2 forks source link

Create tests #10

Closed MarkEdmondson1234 closed 6 months ago

MarkEdmondson1234 commented 6 months ago

@ellipsis-dev can you help create some tests?

ellipsis-dev[bot] commented 6 months ago

To help me create an implementation plan for the tests, could you please provide more details? Specifically, I need to know:

[No tentative implementation steps.]


For more information about Ellipsis, check the documentation.

MarkEdmondson1234 commented 6 months ago

Hi @ellipsis-dev I would like unit tests using pytest for just basic configuration within the python folder sunholo/ - I intend to use it with a check upon build to make sure I've not broken any existing functionality

MarkEdmondson1234 commented 6 months ago

Are you working on this @ellipsis-dev ?

ellipsis-dev[bot] commented 6 months ago

I'm sorry for the delay. I was in the process of viewing the contents of the Python files in the 'sunholo/' folder to understand the basic configuration that needs to be tested. Once I have this information, I will be able to create an implementation plan for creating the tests. If you have any questions or need further assistance, please let me know.

[No tentative implementation steps.]


For more information about Ellipsis, check the documentation.

MarkEdmondson1234 commented 6 months ago

@ellipsis-dev is this still under way?

MarkEdmondson1234 commented 6 months ago

@ellipsis-dev ok thanks. Thats one file done, several to go ;). We can work through them slowly though. Can you put all the tests into a test/ folder? And do another test for the next file, not just chat_history. how about agents/dispatch_to_qa.py ?

MarkEdmondson1234 commented 6 months ago

@ellipsis-dev please make pytests for the python scripts within the sunholo/utils/ folder

ellipsis-dev[bot] commented 6 months ago

Sorry, Ellipsis encountered a problem while generating a pull request. Our team has been alerted and is investigating. (wflow_IHS3Yv4Npensv1o7) :robot:

nsbradford commented 6 months ago

^ sorry about this! patched this issue and rerunning...

ellipsis-dev[bot] commented 6 months ago

I'm sorry for the delay. I was in the process of viewing the contents of the Python files in the 'sunholo/' folder to understand the basic configuration that needs to be tested. Once I have this information, I will be able to create an implementation plan for creating the tests. If you have any questions or need further assistance, please let me know.

Implementation Steps (work in progress)

  1. Create unit tests for the 'config.py' script

      1. Create a new file named 'test_config.py' in the 'test/' folder.
  2. At the top of the file, import the necessary libraries and modules. This includes the pytest framework and the functions from the 'config.py' script.

  3. Define a test function for each main functionality of the 'config.py' script. These functionalities include fetching configuration data from a Google Cloud Storage bucket, getting the file path of a module, loading configuration data from a file, and loading a specific key from the configuration data.

  4. In each test function, call the function being tested with mock input and use an assert statement to check the output. The assert statement should compare the actual output of the function to the expected output. Provide a failure message for each assert statement.

  5. Consider any dependencies or setup required for the tests. This may include creating mock configuration data and setting environment variables.

  6. After writing the tests, run them using the pytest framework to ensure they pass and accurately test the functionalities of the 'config.py' script.

  7. Create unit tests for the 'gcp.py' script

      1. Create a new file named 'test_gcp.py' in the 'test/' folder.
  8. At the top of the file, import the necessary libraries and modules. This includes the pytest framework and the functions from the 'gcp.py' script.

  9. Define a test function for each main functionality of the 'gcp.py' script. These functionalities include checking if the application is running on Cloud Run or GCP, getting the project ID or service account email from environment variables or GCP metadata, and getting the GCP region.

  10. In each test function, call the function being tested with mock input and use an assert statement to check the output. The assert statement should compare the actual output of the function to the expected output. Provide a failure message for each assert statement.

  11. Consider any dependencies or setup required for the tests. This may include setting environment variables.

  12. After writing the tests, run them using the pytest framework to ensure they pass and accurately test the functionalities of the 'gcp.py' script.

  13. Create unit tests for the 'parsers.py' script

      1. Create a new file named 'test_parsers.py' in the 'test/' folder.
  14. At the top of the file, import the necessary libraries and modules. This includes the pytest framework and the functions from the 'parsers.py' script.

  15. Define a test function for each main functionality of the 'parsers.py' script. These functionalities include checking if a string contains a URL, extracting URLs from a string, computing the SHA-1 hash of a file or a string, and removing whitespace from a string.

  16. In each test function, call the function being tested with mock input and use an assert statement to check the output. The assert statement should compare the actual output of the function to the expected output. Provide a failure message for each assert statement.

  17. Consider any dependencies or setup required for the tests. This may include creating mock strings and files.

  18. After writing the tests, run them using the pytest framework to ensure they pass and accurately test the functionalities of the 'parsers.py' script.


For more information about Ellipsis, check the documentation.

nsbradford commented 6 months ago

@MarkEdmondson1234 right now Ellipsis is best used for a single change at a time - above, it's timing out while building its plan. We're rolling out a new feature over next few days for batch changes like the one you're requesting above, but until then, results will be much better for single tasks

MarkEdmondson1234 commented 6 months ago

Makes sense, I'll try it one file at a time