Skip to content

Commit 2e5ea4e

Browse files
Fix: Update AGENTS.md with correct test instructions
The previous instructions in AGENTS.md for running tests were outdated. This commit updates AGENTS.md to reflect the correct steps for running tests as defined in the .github/workflows/ci.yml file, which uses pnpm.
1 parent beb4efd commit 2e5ea4e

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

AGENTS.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,33 @@ This document provides guidance for AI agents working on the `django-cf` reposit
1717

1818
### Running Tests
1919

20-
1. **Prerequisites**: Ensure all dependencies are installed as per the "Dependencies" section.
21-
2. **Worker Server**: Tests rely on a running Cloudflare worker. The `tests/test_worker.py` file includes a `WorkerFixture` that handles:
22-
* Running `npm install` in `templates/durable-objects/`.
23-
* Starting the `npx wrangler dev` server using the version of `wrangler` specified in `templates/durable-objects/package.json`.
24-
3. **Execute Pytest**: Run tests using the `pytest` command from the root of the repository.
25-
4. **Test Structure**:
26-
* Integration tests are located in the `tests/` directory. This directory must contain an `__init__.py` file to be treated as a package.
27-
* Tests use the `requests` library to make HTTP calls to the worker.
28-
* The `web_server` fixture (defined in `tests/test_worker.py` and available to all test files) provides the base URL for the running worker.
29-
* Special management URLs (e.g., `/__run_migrations__/`, `/__create_admin__/` in `templates/durable-objects/src/app/urls.py`) are available for test setup. These create an admin user with username `admin` and password `password`.
20+
The project uses `pnpm` for managing Node.js dependencies and running scripts. The test execution process is defined in `.github/workflows/ci.yml` and can be replicated locally as follows:
21+
22+
1. **Install pnpm**: If you don't have pnpm installed, you can install it globally using npm:
23+
```bash
24+
npm install -g pnpm
25+
```
26+
2. **Install Project Dependencies**: Navigate to the project root and run:
27+
```bash
28+
pnpm install
29+
```
30+
This command installs both Node.js and Python dependencies required for the project, including those for the worker in `templates/durable-objects/`.
31+
3. **Set up Tests**: Run the test setup script:
32+
```bash
33+
pnpm run setup-test
34+
```
35+
This script typically handles tasks like installing Python development dependencies (e.g., `pytest`, Django) and setting up the Django environment within the worker.
36+
4. **Run Tests**: Execute the tests using:
37+
```bash
38+
pnpm run test
39+
```
40+
This command will execute `pytest` which, in turn, uses the `WorkerFixture` in `tests/test_worker.py`. The fixture manages the Cloudflare worker lifecycle (starting `wrangler dev`) for the integration tests.
41+
42+
**Test Structure Details**:
43+
* Integration tests are located in the `tests/` directory. This directory must contain an `__init__.py` file to be treated as a package.
44+
* Tests use the `requests` library to make HTTP calls to the worker.
45+
* The `web_server` fixture (defined in `tests/test_worker.py` and available to all test files) provides the base URL for the running worker.
46+
* Special management URLs (e.g., `/__run_migrations__/`, `/__create_admin__/` in `templates/durable-objects/src/app/urls.py`) are available for test setup. These create an admin user with username `admin` and password `password`.
3047

3148
### Coding Conventions
3249

0 commit comments

Comments
 (0)