Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tests #8

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions {{cookiecutter.project_name}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@ pip install -r requirements.txt

4- create your env
```
cp .env.example .env
cp .env.example .env && rm .env.example
```

5- Create tables
5- spin off docker compose
```
python manage.py migrate
docker compose -f docker-compose.dev.yml up -d
```

6- spin off docker compose
6- Create tables
```
docker compose -f docker-compose.dev.yml up -d
python manage.py migrate
```


7- run the project
```
python manage.py runserver
Expand Down
42 changes: 42 additions & 0 deletions {{cookiecutter.project_name}}/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import pytest
from rest_framework.test import APIClient
from rest_framework_simplejwt.tokens import RefreshToken
from {{cookiecutter.project_slug}}.users.models import BaseUser
from {{cookiecutter.project_slug}}.tests.factories import (
BaseUserFactory,
ProfileFactory,
SubscriptionFactory,
PostFactory,
)


@pytest.fixture
def api_client():
user = BaseUser.objects.create_user(email='[email protected]', password='pass@1test')
client = APIClient()
refresh = RefreshToken.for_user(user)
client.credentials(HTTP_AUTHORIZATION=f'Bearer {refresh.access_token}')

return client

@pytest.fixture
def user1():
return BaseUserFactory()

@pytest.fixture
def user2():
return BaseUserFactory()

@pytest.fixture
def profile1(user1):
return ProfileFactory(user=user1)


@pytest.fixture
def subscription1(user1, user2):
return SubscriptionFactory(target=user1, subscriber=user2)


@pytest.fixture
def post1(user1):
return PostFactory(author=user1)