You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -256,7 +250,7 @@ You can also run `pre-commit` with `uv run pre-commit run -v` if you have some c
256
250
Dependencies are defined in different places:
257
251
258
252
- In [pyproject.toml](pyproject.toml#L28), those are all the dependencies.
259
-
- In [requirements.txt](requirements.txt) and [requirements/](requirements/), those are locked dependencies managed by [Hatch plugin pip-compile](https://github.com/juftin/hatch-pip-compile), do not edit them.
253
+
- In [uv.lock](uv.lock), those are the locked dependencies managed by UV, do not edit them.
260
254
- In [.conda/meta.yaml](.conda/meta.yaml#L21), those are the dependencies for the Conda pacakge targeting Python 3.7 and higher versions.
261
255
262
256
@@ -268,8 +262,8 @@ To make generating documentation easier, we use [`sphinx` package](https://www.s
268
262
269
263
In order to make changes, edit the `.rst` files that are in the `/docs/edit` folder, and then run in root folder:
270
264
271
-
```
272
-
uv run docs
265
+
```sh
266
+
uv run --only-group doc task docs
273
267
```
274
268
275
269
to regenerate the html files.
@@ -281,8 +275,6 @@ to regenerate the html files.
281
275
- Create a PR bumping the version with `uv run bumpver update --patch`. For a release candidate, use `uv run bumpver update --set-version 3.0.0_rc1`.
282
276
- Run `uv run python3 .github/check_version.py` to check version consistancy.
283
277
- Update the dependencies with `uv sync --upgrade`
284
-
- Export a requirements.txt `uv pip freeze > requirements.txt`.
285
-
- Keep pre-commit up-to-date with `uv run task precommit-update`.
286
278
-[Build Documentation](#documentation) with `uv run --only-group doc task docs`.
287
279
- Push the changes.
288
280
- Merge the PR.
@@ -299,13 +291,11 @@ Start a Docker image in the same directory and bind-mount the current directory
Copy file name to clipboardExpand all lines: carbonserver/tests/TESTING.md
+4-27Lines changed: 4 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,6 @@
1
1
# Testing the carbon server
2
2
3
-
4
-
## Behaviors to test :
5
-
3
+
## Behaviors to test
6
4
7
5
### Domain logic
8
6
To test the interface exposed by entities, in memory repositories can be used to isolate the domain logic from technical
@@ -29,55 +27,34 @@ To test the interface exposed by entities, in memory repositories can be used to
29
27
Domain logic can be tested at a higher level, with more complex setups, in service/use cases tests.
30
28
Use case tests mocks repositories returns to focus on
31
29
32
-
33
-
34
30
### Routers
35
31
To test a router, validation parameters are ensured by pydantic (available on the swagger documentation),
36
32
and logic is tested by interfaces.
37
33
A Postman collection of requests is available: ```carbonserver/tests/postman/TestCollection.postman_collection.json```.
38
34
39
-
40
-
41
35
### Integration
42
36
- Database: in the CI, a prod-like database can be used to test features on real data (TODO)
43
37
- Code Carbon package: Launch a train scenario (TODO)
44
38
45
-
46
39
## Running the tests:
47
40
48
-
### Install the test setup
49
-
50
-
In a virtual environment, install and build the api package:
51
41
```bash
52
-
git clone git@github.com:mlco2/codecarbon.git
53
-
git checkout api
54
-
cd carbonserver
55
-
python -m setup install
56
-
python -m setup build # Verify the build on local environment
57
-
pip install -r requirements-dev.txt # Install test dependencies
42
+
uv run --extra api task test-api-unit # Unit tests on api
43
+
uv run --extra api task test-api-integ # Integration tests
58
44
```
59
45
60
-
61
-
### Run tests
62
-
```bash
63
-
hatch run api:test-unit # Unit tests on api
64
-
hatch run api:test-integ # Integration tests
65
-
```
66
-
67
-
68
46
To test the HTTP layer, you can also deploy a local instance:
69
47
70
48
```bash
71
49
cd carbonserver/
72
-
uvicorn main:app --reload
50
+
uv run --extra api uvicorn main:app --reload
73
51
```
74
52
75
53
Swagger documentation is available at http://localhost:8000/docs
76
54
77
55
78
56
### Run locally the CI
79
57
80
-
81
58
To test the full build process, the Github Actions workflow can be executed locally with act ([install available here](https://raw.githubusercontent.com/nektos/act/master/install.sh)):
0 commit comments