You've already forked bthlabs-jsonrpc
v1.1.0b1
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# type: ignore
|
||||
from bthlabs_jsonrpc_core import exceptions
|
||||
from django.contrib.auth.models import User
|
||||
from django.test import Client
|
||||
|
||||
|
||||
def test_view(client):
|
||||
def test_view(client: Client):
|
||||
# Given
|
||||
batch = [
|
||||
{
|
||||
@@ -48,25 +51,27 @@ def test_view(client):
|
||||
assert data == expected_result_data
|
||||
|
||||
|
||||
def test_view_empty_response(client, call):
|
||||
def test_view_empty_response(client: Client, single_call: dict):
|
||||
# Given
|
||||
call.pop('id')
|
||||
single_call.pop('id')
|
||||
|
||||
# When
|
||||
response = client.post('/rpc', data=call, content_type='application/json')
|
||||
response = client.post(
|
||||
'/rpc', data=single_call, content_type='application/json',
|
||||
)
|
||||
|
||||
# Then
|
||||
assert response.status_code == 200
|
||||
assert response.content == b''
|
||||
|
||||
|
||||
def test_view_with_auth_checks(client, user, call):
|
||||
def test_view_with_auth_checks(client: Client, user: User, single_call: dict):
|
||||
# Given
|
||||
client.force_login(user)
|
||||
|
||||
# When
|
||||
response = client.post(
|
||||
'/rpc/private', data=call, content_type='application/json',
|
||||
'/rpc/private', data=single_call, content_type='application/json',
|
||||
)
|
||||
|
||||
# Then
|
||||
@@ -75,16 +80,17 @@ def test_view_with_auth_checks(client, user, call):
|
||||
data = response.json()
|
||||
expected_result_data = {
|
||||
'jsonrpc': '2.0',
|
||||
'id': 'system.list_methods',
|
||||
'id': 'test',
|
||||
'result': ['system.list_methods'],
|
||||
}
|
||||
assert data == expected_result_data
|
||||
|
||||
|
||||
def test_view_with_auth_checks_permission_denied(client, call):
|
||||
def test_view_with_auth_checks_permission_denied(client: Client,
|
||||
single_call: dict):
|
||||
# When
|
||||
response = client.post(
|
||||
'/rpc/private', data=call, content_type='application/json',
|
||||
'/rpc/private', data=single_call, content_type='application/json',
|
||||
)
|
||||
|
||||
# Then
|
||||
|
||||
Reference in New Issue
Block a user