Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop Branch to Master Branch #13

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

theja0473
Copy link

Create unit tests for the app.py script using pytest, we need to focus on testing different functionalities like the session states, file upload, PDF loading, text splitting, vector store creation, and the QA chain. Since the script uses external libraries like LangChain and Streamlit, we'll mock the dependencies for proper testing.

To create unit tests for the app.py script using pytest, we need to focus on testing different functionalities like the session states, file upload, PDF loading, text splitting, vector store creation, and the QA chain. Since the script uses external libraries like LangChain and Streamlit, we'll mock the dependencies for proper testing.
GitHub Actions YAML workflow that runs the pytest tests for the app.py application and the test_app.py script. This YAML file will automate the testing process each time a commit is pushed or a pull request is created.
Modify the GitHub Actions workflow to:

- Install dependencies from a requirements.txt file.
- Run the workflow only on the develop branch (instead of main).
This should fix the pytest: command not found error by ensuring that pytest is properly installed and executed in the correct environment.
Key Fixes:
setup_streamlit_session_state: The autouse=True fixture initializes the Streamlit session state for each test. This is crucial to avoid the AttributeError for missing session state variables like template, prompt, vectorstore, etc.
Mock objects: Since the vectorstore, llm, and other session state variables are complex objects, they are mocked to avoid needing to initialize them with actual functionality during the tests. This allows the tests to focus on the logic and session state, not the external dependencies.
Explanation of Fixes in test_app.py:
Session State Initialization: The session state is initialized in the test setup, so tests that depend on it (test_initial_session_state, test_chat_interaction, etc.) don't throw AttributeError.
Mocks: Dependencies like llm, vectorstore, and qa_chain are mocked to avoid actual interactions with LangChain or external libraries. This keeps the tests fast and isolated.
With these changes, the tests should now pass without session state or attribute errors.
o ensure the GitHub Actions workflow continues running even if some of the test cases fail, you can modify the workflow to add the continue-on-error flag to the job that runs the tests. This way, the test suite will run to completion, and the workflow will not stop immediately when a test fails.

Here’s the updated .github/workflows/python-app.yml
@theja0473 theja0473 closed this Sep 11, 2024
@theja0473 theja0473 reopened this Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant