# BorgTestGenerator
> OpenAI assistants automations to generate python3 unittest files
BorgTestGenerator is a Python library that generates unit test files from Python scripts using the OpenAI API.
## Installation
### Installation from pip ( with venv )
This section provides instructions for installing the librarie package from pip using a virtual environment (venv).
1. **Create a virtual environment:**
```sh
python3 -m venv venv
```
2. **Activate the virtual environment:**
- On Linux or macOS:
```sh
source venv/bin/activate
```
- On Windows:
```sh
.\venv\Scripts\activate
```
3. **Update pip from pip:**
```sh
python3 -m pip install --upgrade pip
```
4. **Install the package from pip:**
```sh
python3 -m pip install -U BorgTestGenerator
```
## Usage of BorgTestGenerator python library
To use the `Assistant` class from the `BorgTestGenerator` module in your code, you need to follow these steps:
1. Import the `Assistant` class from the `BorgTestGenerator` module in your Python file. Make sure the `BorgTestGenerator` module is installed in your Python environment using the `pip install BorgTestGenerator` command.
```python
from BorgTestGenerator.assistant import Assistant
```
2. Create an instance of the `Assistant` class using the constructor. You can provide additional arguments to the constructor based on your application's needs.
```python
assistant = Assistant()
```
3. Set the user input that describes the task to be performed using the `set_user_input` method.
```python
assistant.create_assistant(
name="Test Assistant",
instructions="This is a test assistant.",
model="gpt-4o",
tool_code_interpreter=True,
tool_file_search=True
)
```
### How To Use AssistantBackupManager
Pour utiliser la classe [`AssistantBackupManager`]("README.md") du module `BorgTestGenerator.assistant`, suivez les étapes ci-dessous :
1. **Importer la classe [`AssistantBackupManager`]("README.md")** :
```python
from BorgTestGenerator.assistant import AssistantBackupManager
```
2. **Créer une instance de la classe `AssistantBackupManager`** :
```python
assistant_backup_manager = AssistantBackupManager()
```
3. **Définir l'entrée utilisateur qui décrit la tâche à effectuer** :
```python
assistant_backup_manager.backup()
```
Ces étapes permettent de configurer et d'utiliser le `AssistantBackupManager` pour gérer les sauvegardes de manière automatisée.
### How to use unittestwriter in your code
The following example shows how to use the `UnitTestWriter` class from the `BorgTestGenerator.agents.unittestwriter` module to generate unit test files for Python scripts.
```python
# Import the UnitTestWriter class from the BorgTestGenerator.agents.unittestwriter module
from BorgTestGenerator.agents.unittestwriter import UnitTestWriter
# Create an instance of the UnitTestWriter class with the code language specified as Python
testWriter = UnitTestWriter(code_language="python")
# Set the user input that describes the task to be performed
testWriter.set_user_input("Write the code for the test file corresponding to this Python script")
# Add the Python files for which unit tests should be generated
testWriter.add_upload(["/path/to/file1.py", "/path/to/file2.py"])
# Define the vector store name
testWriter.define_vector_store_name("test_vector_store")
# Generate the unit test files
testWriter.generate()
```
In this example:
1. **Import**: The `UnitTestWriter` class is imported from the `BorgTestGenerator.agents.unittestwriter` module.
2. **Instance**: An instance of `UnitTestWriter` is created with the `code_language` parameter set to `"python"`.
3. **User input**: The `set_user_input` method is used to set a task description in French.
4. **File addition**: The `add_upload` method adds the paths of the Python files for which tests should be generated.
5. **Vector store name**: The `define_vector_store_name` method defines the name of the vector store used.
6. **Generation**: The `generate` method triggers the generation of the unit test files.
This example demonstrates how to automate the generation of unit tests for Python scripts using the `UnitTestWriter` class.
Raw data
{
"_id": null,
"home_page": "https://github.com/smartestmanuniverse/BorgTestGenerator",
"name": "BorgTestGenerator",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": null,
"author": "0x07cb",
"author_email": "83157348+0x07CB@users.noreply.github.com",
"download_url": "https://files.pythonhosted.org/packages/38/a1/854a43d1f499d7fd76a2414242536f9ed2f4ee8b15ce7c83ec22ad74ea14/BorgTestGenerator-0.3.10.tar.gz",
"platform": null,
"description": "# BorgTestGenerator\n\n> OpenAI assistants automations to generate python3 unittest files\n\nBorgTestGenerator is a Python library that generates unit test files from Python scripts using the OpenAI API.\n\n## Installation\n\n### Installation from pip ( with venv )\n\nThis section provides instructions for installing the librarie package from pip using a virtual environment (venv).\n\n1. **Create a virtual environment:**\n ```sh\n python3 -m venv venv\n ```\n\n2. **Activate the virtual environment:**\n - On Linux or macOS:\n ```sh\n source venv/bin/activate\n ```\n - On Windows:\n ```sh\n .\\venv\\Scripts\\activate\n ```\n\n3. **Update pip from pip:**\n ```sh\n python3 -m pip install --upgrade pip\n ```\n\n4. **Install the package from pip:**\n ```sh\n python3 -m pip install -U BorgTestGenerator\n ```\n\n\n## Usage of BorgTestGenerator python library\n\nTo use the `Assistant` class from the `BorgTestGenerator` module in your code, you need to follow these steps:\n\n1. Import the `Assistant` class from the `BorgTestGenerator` module in your Python file. Make sure the `BorgTestGenerator` module is installed in your Python environment using the `pip install BorgTestGenerator` command.\n\n ```python\n from BorgTestGenerator.assistant import Assistant\n ```\n\n2. Create an instance of the `Assistant` class using the constructor. You can provide additional arguments to the constructor based on your application's needs.\n\n ```python\n assistant = Assistant()\n ```\n\n3. Set the user input that describes the task to be performed using the `set_user_input` method.\n ```python\n assistant.create_assistant(\n name=\"Test Assistant\",\n instructions=\"This is a test assistant.\",\n model=\"gpt-4o\",\n tool_code_interpreter=True,\n tool_file_search=True\n )\n ```\n\n\n### How To Use AssistantBackupManager\n\nPour utiliser la classe [`AssistantBackupManager`](\"README.md\") du module `BorgTestGenerator.assistant`, suivez les \u00e9tapes ci-dessous :\n\n1. **Importer la classe [`AssistantBackupManager`](\"README.md\")** :\n ```python\n from BorgTestGenerator.assistant import AssistantBackupManager\n ```\n\n2. **Cr\u00e9er une instance de la classe `AssistantBackupManager`** :\n ```python\n assistant_backup_manager = AssistantBackupManager()\n ```\n\n3. **D\u00e9finir l'entr\u00e9e utilisateur qui d\u00e9crit la t\u00e2che \u00e0 effectuer** :\n ```python\n assistant_backup_manager.backup()\n ```\n\nCes \u00e9tapes permettent de configurer et d'utiliser le `AssistantBackupManager` pour g\u00e9rer les sauvegardes de mani\u00e8re automatis\u00e9e.\n\n\n### How to use unittestwriter in your code\n\nThe following example shows how to use the `UnitTestWriter` class from the `BorgTestGenerator.agents.unittestwriter` module to generate unit test files for Python scripts.\n\n```python\n# Import the UnitTestWriter class from the BorgTestGenerator.agents.unittestwriter module\nfrom BorgTestGenerator.agents.unittestwriter import UnitTestWriter\n\n# Create an instance of the UnitTestWriter class with the code language specified as Python\ntestWriter = UnitTestWriter(code_language=\"python\")\n\n# Set the user input that describes the task to be performed\ntestWriter.set_user_input(\"Write the code for the test file corresponding to this Python script\")\n\n# Add the Python files for which unit tests should be generated\ntestWriter.add_upload([\"/path/to/file1.py\", \"/path/to/file2.py\"])\n\n# Define the vector store name\ntestWriter.define_vector_store_name(\"test_vector_store\")\n\n# Generate the unit test files\ntestWriter.generate()\n```\n\nIn this example:\n\n1. **Import**: The `UnitTestWriter` class is imported from the `BorgTestGenerator.agents.unittestwriter` module.\n2. **Instance**: An instance of `UnitTestWriter` is created with the `code_language` parameter set to `\"python\"`.\n3. **User input**: The `set_user_input` method is used to set a task description in French.\n4. **File addition**: The `add_upload` method adds the paths of the Python files for which tests should be generated.\n5. **Vector store name**: The `define_vector_store_name` method defines the name of the vector store used.\n6. **Generation**: The `generate` method triggers the generation of the unit test files.\n\nThis example demonstrates how to automate the generation of unit tests for Python scripts using the `UnitTestWriter` class.\n",
"bugtrack_url": null,
"license": null,
"summary": "Librairie pour g\u00e9n\u00e9rer des tests unitaires \u00e0 partir de scripts Python en utilisant OpenAI.",
"version": "0.3.10",
"project_urls": {
"Homepage": "https://github.com/smartestmanuniverse/BorgTestGenerator"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "25a71f2bb13c822ff0b6ceeeb1a1a70de9ba7600af12e683464f122834575edf",
"md5": "f663ca996a7e63ccdf3411bc844fdd2c",
"sha256": "6259dca704ae10f6867e7ca7b5d055326b1486b422f7ba4f27ec771df2d8d156"
},
"downloads": -1,
"filename": "BorgTestGenerator-0.3.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f663ca996a7e63ccdf3411bc844fdd2c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 25783,
"upload_time": "2024-08-03T15:47:05",
"upload_time_iso_8601": "2024-08-03T15:47:05.065276Z",
"url": "https://files.pythonhosted.org/packages/25/a7/1f2bb13c822ff0b6ceeeb1a1a70de9ba7600af12e683464f122834575edf/BorgTestGenerator-0.3.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "38a1854a43d1f499d7fd76a2414242536f9ed2f4ee8b15ce7c83ec22ad74ea14",
"md5": "82d7b789fee194c39724771b29985f4d",
"sha256": "8cdf50ea73f5e45a969829593ba3c9891643714f3d874e49f3c8162289de2b75"
},
"downloads": -1,
"filename": "BorgTestGenerator-0.3.10.tar.gz",
"has_sig": false,
"md5_digest": "82d7b789fee194c39724771b29985f4d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 18422,
"upload_time": "2024-08-03T15:47:07",
"upload_time_iso_8601": "2024-08-03T15:47:07.027305Z",
"url": "https://files.pythonhosted.org/packages/38/a1/854a43d1f499d7fd76a2414242536f9ed2f4ee8b15ce7c83ec22ad74ea14/BorgTestGenerator-0.3.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-03 15:47:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "smartestmanuniverse",
"github_project": "BorgTestGenerator",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "borgtestgenerator"
}