Skip to content

Commit

Permalink
Small typo fixes and doc mention router import (#1317)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelg100 authored Oct 15, 2024
1 parent 7d211c2 commit 9ff32ec
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions docs/docs/guides/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ from ninja.testing import TestClient

class HelloTest(TestCase):
def test_hello(self):
# don't forget to import router from code above
client = TestClient(router)
response = client.get("/hello")

Expand All @@ -49,15 +50,15 @@ class HelloTest(TestCase):
```

### Headers
It is also possible to specify headers, both from the TestCase instanciation and the actual request:
It is also possible to specify headers, both from the TestCase instantiation and the actual request:
```python
client = TestClient(router, headers={"A": "a", "B": "b"})
# The request will be made with {"A": "na", "B": "b", "C": "nc"} headers
response = client.get("/test-headers", headers={"A": "na", "C": "nc"})
```

### Cookies
It is also possible to specify cookies, both from the TestCase instanciation and the actual request:
It is also possible to specify cookies, both from the TestCase instantiation and the actual request:
```python
client = TestClient(router, COOKIES={"A": "a", "B": "b"})
# The request will be made with {"A": "na", "B": "b", "C": "nc"} cookies
Expand Down
2 changes: 1 addition & 1 deletion tests/env-matrix/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This `env-matrix` speeds up test execution across all environments (Pytho 3.[6,7,8], Django2.0,...,3.1)
This `env-matrix` speeds up test execution across all environments (Python 3.[6,7,8], Django2.0,...,3.1)

To execute

Expand Down
4 changes: 2 additions & 2 deletions tests/test_pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def paginate_queryset(self, items, pagination: Input, **params):


class ResultsPaginator(PaginationBase):
"Use 'results' insted of 'items' for the output"
"Use 'results' instead of 'items' for the output"

class Input(Schema):
skip: int
Expand Down Expand Up @@ -432,7 +432,7 @@ def invalid2(request):
def test_pagination_works_with_unnamed_classes():
"""
This test lets you check that the typing.Any case handled in `ninja.pagination.make_response_paginated`
works for Python>=3.11, as a typing.Any does possess the __name__ atribute past that version
works for Python>=3.11, as a typing.Any does possess the __name__ attribute past that version
"""
operation = Operation("/whatever", ["GET"], lambda: None, response=List[int])
operation.response_models[200].__annotations__["response"] = List[object()]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_router_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SomeResponse(Schema):
],
)
def test_router_defaults(oparg, retdict, assertone, asserttwo):
"""Test that the router level settings work and can be overriden at the op level"""
"""Test that the router level settings work and can be overridden at the op level"""
api = NinjaAPI()
router = Router(**{oparg: True})
api.add_router("/", router)
Expand Down

0 comments on commit 9ff32ec

Please sign in to comment.