1
0
This commit is contained in:
2024-01-15 20:20:10 +00:00
parent c75ea4ea9d
commit 38cd64ea9a
87 changed files with 3946 additions and 2040 deletions

View File

@@ -1,18 +1,20 @@
# -*- coding: utf-8 -*-
# type: ignore
from unittest import mock
from bthlabs_jsonrpc_core import exceptions
from django.test import RequestFactory
import pytest
from bthlabs_jsonrpc_django import executor
@pytest.fixture
def fake_can_call():
def fake_can_call() -> mock.Mock:
return mock.Mock()
def test_init(rf, fake_can_call):
def test_init(rf: RequestFactory, fake_can_call: mock.Mock):
# Given
request = rf.get('/')
@@ -24,7 +26,7 @@ def test_init(rf, fake_can_call):
assert result.can_call == fake_can_call
def test_enrich_args(rf, fake_can_call):
def test_enrich_args(rf: RequestFactory, fake_can_call: mock.Mock):
# Given
request = rf.get('/')
@@ -37,7 +39,7 @@ def test_enrich_args(rf, fake_can_call):
assert result == [request, 'spam']
def test_before_call(rf, fake_can_call):
def test_before_call(rf: RequestFactory, fake_can_call: mock.Mock):
# Given
request = rf.get('/')
@@ -50,7 +52,8 @@ def test_before_call(rf, fake_can_call):
fake_can_call.assert_called_with(request, 'test', ['spam'], {'spam': True})
def test_before_call_access_denied(rf, fake_can_call):
def test_before_call_access_denied(rf: RequestFactory,
fake_can_call: mock.Mock):
# Given
fake_can_call.return_value = False