File: conftest.py

package info (click to toggle)
strawberry-graphql-django 0.62.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,968 kB
  • sloc: python: 27,530; sh: 17; makefile: 16
file content (29 lines) | stat: -rw-r--r-- 568 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from collections import UserDict

import pytest
from django.contrib import auth as django_auth

UserModel = django_auth.get_user_model()


@pytest.fixture
def context(mocker):
    class Session(UserDict):
        def cycle_key(self):
            pass

        def flush(self):
            pass

    context = mocker.Mock()
    context.request.session = Session()
    django_auth.logout(context.request)
    return context


@pytest.fixture
def user(db, group, tag):
    return UserModel.objects.create_user(
        username="user",
        password="password",
    )