68 lines
No EOL
2.7 KiB
Markdown
68 lines
No EOL
2.7 KiB
Markdown
# Core
|
|
|
|
This directory contains the backend of the C3LF System3 project, which is built using Django and Django Rest Framework.
|
|
|
|
## Modules
|
|
|
|
- `authentication`: Handles user authentication and authorization.
|
|
- `files`: Manages file uploads and related operations.
|
|
- `inventory`: Handles inventory management, including events, containers and items.
|
|
- `mail`: Manages email-related functionalities, including sending and receiving emails.
|
|
- `notify_sessions`: Handles real-time notifications and WebSocket sessions.
|
|
- `tickets`: Manages the ticketing system for issue tracking.
|
|
|
|
## Modules Structure
|
|
|
|
Most modules follow a similar structure, including the following components:
|
|
|
|
- `<module>/models.py`: Contains the database models for the module.
|
|
- `<module>/serializers.py`: Contains the serializers for the module models.
|
|
- `<module>/api_<api_version>.py`: Contains the API views and endpoints for the module.
|
|
- `<module>/migrations/`: Contains database migration files. Needs to contain an `__init__.py` file to be recognized as
|
|
a Python package and automatically migration creation to work.
|
|
- `<module>/tests/<api_version>/test_<feature_model_or_testcase>.py`: Contains the test cases for the module.
|
|
|
|
## Development Setup
|
|
|
|
follow the instructions under 'Backend-API-Only' or 'Fullstack-Lite' in the root level `README.md` to set up a
|
|
development environment.
|
|
|
|
## Test-Driven Development (TDD) Workflow
|
|
|
|
The project follows a TDD workflow to ensure code quality and reliability. Here is a step-by-step guide to the TDD
|
|
process:
|
|
|
|
1. **Write a Test**: Start by writing a test case for the new feature or bug fix. Place the test case in the appropriate
|
|
module within the `<module>/tests/<api_version>/test_<feature_model_or_testcase>.py` file.
|
|
|
|
2. **Run the Test**: Execute the test to ensure it fails, confirming that the feature is not yet implemented or the bug
|
|
exists.
|
|
```bash
|
|
python manage.py test
|
|
```
|
|
|
|
3. **Write the Code**: Implement the code required to pass the test. Write the code in the appropriate module within the
|
|
project.
|
|
|
|
4. **Run the Test Again**: Execute the test again to ensure it passes.
|
|
```bash
|
|
python manage.py test
|
|
```
|
|
|
|
5. **Refactor**: Refactor the code to improve its structure and readability while ensuring that all tests still pass.
|
|
|
|
6. **Repeat**: Repeat the process for each new feature or bug fix.
|
|
|
|
## Measuring Test Coverage
|
|
|
|
The project uses the `coverage` package to measure test coverage. To generate a coverage report, run the following
|
|
command:
|
|
|
|
```bash
|
|
coverage run --source='.' manage.py test
|
|
coverage report
|
|
```
|
|
|
|
## Additional Information
|
|
|
|
For more detailed information on the project structure and development modes, refer to the root level `README.md`. |