This project is a Python application for generating usernames based on input records. It includes a command-line tool and unit tests to ensure the functionality of the username generation process.
ugen.py: Contains the main logic for generating usernames from user records.test_ugen.py: Contains unit tests forugen.py.conftest.py: Contains pytest configuration and fixtures for setting up and tearing down test data.test.py: A script for running pytest with custom options, such as specifying the test data file.
To set up the project, you will need to install the necessary Python packages. It is recommended to use a virtual environment for this purpose.
-
Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate # Linux/MacOS .\.venv\Scripts\activate # Windows
-
Install the required packages:
Use the requirements.txt file to install all necessary dependencies:
pip install -r requirements.txtTo run the username generator script (ugen.py), you need to provide an output file and one or more input files. The input files should contain user records, and the output file will contain the generated usernames along with the original records.
Example usage:
python3 ugen.py --output output_file.txt input_file1.txt input_file2.txt
To run the unit tests for the project, use the test.py script. This script uses pytest to run tests with the specified test data file.
Example usage:
python3 test.py ugen.py test_data.txt
Test results are automatically saved in a JUnit XML report file named report.xml. You can review this file to analyze the test results.
Example usage:
python3 test.py ugen.py test_data.txt
The project requires the following Python packages, listed in requirements.txt:
pytest: For running the unit tests.
You can install these dependencies using the command:
pip install -r requirements.txt