Skip to content

Commit d7ece20

Browse files
authored
Merge pull request #113 from jmrivas86/dev
Update tests and docs
2 parents bb2240f + ae33968 commit d7ece20

11 files changed

+781
-152
lines changed

CONTRIBUTING.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Contributing
2+
3+
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
4+
5+
You can contribute in many ways:
6+
7+
## Types of Contributions
8+
9+
### Report Bugs
10+
11+
Report bugs at https://github.com/jmrivas86/django-json-widget/issues.
12+
13+
If you are reporting a bug, please include:
14+
15+
* Your operating system name and version.
16+
* Any details about your local setup that might be helpful in troubleshooting.
17+
* Detailed steps to reproduce the bug.
18+
19+
### Fix Bugs
20+
21+
Look through the GitHub issues for bugs. Anything tagged with "bug" is open to whoever wants to implement it.
22+
23+
### Implement Features
24+
25+
Look through the GitHub issues for features. Anything tagged with "feature" is open to whoever wants to implement it.
26+
27+
### Write Documentation
28+
29+
django-json-widget could always use more documentation, whether as part of the official django-json-widget docs, in docstrings, or even on the web in blog posts, articles, and such.
30+
31+
### Submit Feedback
32+
33+
The best way to send feedback is to file an issue at https://github.com/jmrivas86/django-json-widget/issues.
34+
35+
If you are proposing a feature:
36+
37+
* Explain in detail how it would work.
38+
* Keep the scope as narrow as possible, to make it easier to implement.
39+
* Remember that this is a volunteer-driven project, and that contributions are welcome :)
40+
41+
## Get Started!
42+
43+
Ready to contribute? Here's how to set up `django-json-widget` for local development.
44+
45+
1. Fork the `django-json-widget` repo on GitHub.
46+
47+
2. Clone your fork locally:
48+
```bash
49+
git clone [email protected]:your_name_here/django-json-widget.git
50+
```
51+
52+
3. Install development dependencies:
53+
```bash
54+
cd django-json-widget/
55+
python -m venv .venv
56+
source .venv/bin/activate
57+
pip install -r requirements_test.txt
58+
```
59+
60+
4. Create a branch for local development from the dev branch:
61+
```bash
62+
git checkout dev
63+
git checkout -b name-of-your-branch
64+
```
65+
66+
Now you can make your changes locally.
67+
68+
5. Commit your changes and push your branch:
69+
```bash
70+
git add .
71+
git commit -m "Your detailed description of your changes."
72+
git push origin name-of-your-branch
73+
```
74+
75+
6. Submit a pull request through the GitHub website.
76+
77+
## Pull Request Guidelines
78+
79+
Before you submit a pull request, check that it meets these guidelines:
80+
81+
1. **The pull request must be submitted against the `dev` branch.**
82+
2. Please explain what you have done in the pull request.
83+
3. Make sure you have had passed pre-commit hooks.

CONTRIBUTING.rst

Lines changed: 0 additions & 113 deletions
This file was deleted.

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
include AUTHORS.rst
22
include CONTRIBUTING.rst
3-
include CHANGELOG.rst
3+
include CHANGELOG.md
44
include LICENSE
55
include README.rst
66
recursive-include django_json_widget *.html *.png *.gif *js *.css *jpg *jpeg *svg *py

README.rst

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,92 @@ After:
9393
.. image:: https://raw.githubusercontent.com/jmrivas86/django-json-widget/master/imgs/jsonfield_1.png
9494

9595

96+
Development Guide
97+
-----------------
98+
99+
This section provides instructions for setting up a development environment and contributing to django-json-widget.
100+
101+
Setting up Development Environment
102+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
103+
104+
1. **Clone the repository**::
105+
106+
git clone https://github.com/jmrivas86/django-json-widget.git
107+
cd django-json-widget
108+
109+
2. **Create a virtual environment** (recommended)::
110+
111+
python -m venv venv
112+
source venv/bin/activate # On Windows: venv\Scripts\activate
113+
114+
3. **Install development dependencies**::
115+
116+
pip install -r requirements_dev.txt
117+
118+
4. **Install test dependencies**::
119+
120+
pip install -r requirements_test.txt
121+
122+
5. **Install the package in development mode**::
123+
124+
pip install -e .
125+
126+
Running Tests
127+
~~~~~~~~~~~~~
128+
129+
The project includes several ways to run tests:
130+
131+
**Using the runtests.py script** (recommended)::
132+
133+
python runtests.py
134+
135+
This will run all tests using Django's test runner with the test settings.
136+
137+
**Using tox for multiple environments**::
138+
139+
tox
140+
141+
This will run tests against multiple Python and Django version combinations as defined in ``tox.ini``.
142+
143+
**With coverage reporting**::
144+
145+
coverage run --source django_json_widget runtests.py
146+
coverage report
147+
coverage html # Generates HTML coverage report
148+
149+
Test Structure
150+
~~~~~~~~~~~~~~
151+
152+
The test suite is organized as follows:
153+
154+
* ``tests/test_widgets.py`` - Core widget functionality tests
155+
* ``tests/test_widget_security.py`` - Security-focused tests
156+
* ``tests/settings.py`` - Test-specific Django settings
157+
158+
The tests cover:
159+
160+
* Widget initialization and configuration
161+
* Media file handling (CSS/JS)
162+
* Template rendering and context generation
163+
* Form integration
164+
* Security aspects (XSS prevention, safe JSON handling)
165+
* Performance with large datasets
166+
* Edge cases and error handling
167+
168+
Code Quality
169+
~~~~~~~~~~~~
170+
171+
**Run linting with auto-fix**::
172+
173+
ruff check --fix
174+
175+
**Check test coverage**::
176+
177+
coverage run --source django_json_widget runtests.py
178+
coverage report --show-missing
179+
180+
Aim for maintaining or improving test coverage.
181+
96182
Credits
97183
-------
98184

0 commit comments

Comments
 (0)