|
| 1 | +# Local development, testing and quality checking |
| 2 | + |
| 3 | +To start developing Dracan on your local machine, you can set up a mock service for live debugging. Follow these steps to get started: |
| 4 | + |
| 5 | +1. **Clone the Repository**: First, clone the Dracan repository to your local machine if you haven't done so already. |
| 6 | + ```bash |
| 7 | + git clone https://github.com/Veinar/dracan.git |
| 8 | + cd dracan |
| 9 | + ``` |
| 10 | +2. Set Up a Virtual Environment: It’s recommended to create a virtual environment for your development work to manage dependencies. |
| 11 | + ```bash |
| 12 | + python -m venv venv |
| 13 | + source venv/bin/activate # On Windows use `venv\Scripts\Activate.ps1` |
| 14 | + ``` |
| 15 | +3. Install Required Dependencies: Install the necessary Python packages using pip. Ensure you have Flask installed, as it is used for the mock service. |
| 16 | + ```bash |
| 17 | + pip install -r requirements.txt |
| 18 | + ``` |
| 19 | +4. Run the Mock Service: Start the mock service provided in the Dracan package. This service is located in `tests/destination_mock.py` and simulates the application your Dracan middleware will be interfacing with. |
| 20 | + ```bash |
| 21 | + python tests/destination_mock.py |
| 22 | + ``` |
| 23 | +5. Live Debugging: With the mock service running, you can now run Dracan in your local environment. This allows you to test and debug how Dracan interacts with the mock service in real-time. |
| 24 | +6. Modify and Test: Make changes to Dracan's code as needed, and observe the interactions with the mock service. This setup enables you to develop efficiently and troubleshoot any issues in real-time. |
| 25 | +
|
| 26 | +## Running Unit Tests |
| 27 | +
|
| 28 | +> **This is "must have" to be done before submitting a PR to avoid breaking Dracan itself** |
| 29 | +
|
| 30 | +Dracan includes a suite of unit tests to ensure the functionality and reliability of the code. Running these tests is an important step when contributing to the project, especially when adding new features or enhancements. |
| 31 | +Please note that these tests were written using ChatGPT due to my lack of experience in this area. |
| 32 | +
|
| 33 | +### Prerequisites |
| 34 | +
|
| 35 | +Before running the tests, make sure you have **pytest** installed in your environment. You can install it using pip: |
| 36 | +
|
| 37 | +```bash |
| 38 | +pip install pytest |
| 39 | +``` |
| 40 | +
|
| 41 | +### Running the tests |
| 42 | +
|
| 43 | +To run the unit tests for Dracan, execute the following command from the root directory of the project: |
| 44 | +
|
| 45 | +```bash |
| 46 | +pytest tests/ |
| 47 | +``` |
| 48 | +
|
| 49 | +This command will run all the tests located in the `tests` directory and provide you with feedback on the results. |
| 50 | +
|
| 51 | +### Expanding Tests |
| 52 | +
|
| 53 | +As you work on expanding Dracan with new features or validations, it is essential to also expand the test suite. Ensure that any new validations or limiting functionalities are covered by corresponding tests. This practice not only helps maintain the integrity of the project but also provides assurance that existing functionality remains unaffected by new changes. |
| 54 | +
|
| 55 | +We encourage you to contribute by writing additional tests and improving the overall test coverage. Your efforts in this area will help ensure that Dracan remains a reliable and robust middleware solution. |
| 56 | +
|
| 57 | +## Running Linter |
| 58 | +
|
| 59 | +> **This should be done before submitting a PR to avoid major issues in code** |
| 60 | +
|
| 61 | +To maintain code quality and ensure adherence to coding standards, Dracan uses a linter to analyze the codebase. Linting is essential in identifying stylistic errors and enforcing a consistent code format, making it easier to read and maintain. |
| 62 | +
|
| 63 | +### Prerequisites |
| 64 | +
|
| 65 | +Before running the linter, ensure that **pylint** is installed in your environment. You can install it using pip: |
| 66 | +
|
| 67 | +```bash |
| 68 | +pip install pylint |
| 69 | +``` |
| 70 | +To run the linter for Dracan, execute the following command from the root directory of the project. This command checks for code issues while disabling the C0301 rule, which restricts line length: |
| 71 | +
|
| 72 | +```bash |
| 73 | +pylint --disable=C0301 dracan/ |
| 74 | +``` |
| 75 | +
|
| 76 | +## Running Security analysis |
| 77 | +
|
| 78 | +> **This should be done before submitting a PR to avoid major security issues in code** |
| 79 | +
|
| 80 | +Security analysis is a critical step to help identify potential vulnerabilities in the code. Dracan uses Bandit, a security tool designed to detect common security issues in Python code. |
| 81 | +
|
| 82 | +### Prerequisites |
| 83 | +
|
| 84 | +Before running the security analysis, make sure bandit is installed in your environment. You can install it with the following command: |
| 85 | +
|
| 86 | +```bash |
| 87 | +pip install bandit |
| 88 | +``` |
| 89 | +
|
| 90 | +To run a security analysis on the Dracan codebase, execute the following command from the root directory of the project: |
| 91 | +
|
| 92 | +```bash |
| 93 | +bandit -r dracan/ |
| 94 | +``` |
| 95 | +This command scans the code recursively and reports any detected security issues. |
0 commit comments