21 lines
893 B
Python
21 lines
893 B
Python
import pytest
|
|
from channels.testing import WebsocketCommunicator
|
|
from django.urls import reverse
|
|
from project.config.asgi import application
|
|
from project.remotectl.models import RemoteHost, BatchScript
|
|
|
|
@pytest.mark.django_db(transaction=True)
|
|
@pytest.mark.asyncio
|
|
async def test_batch_model_creation(django_user_model):
|
|
user = await django_user_model.objects.acreate(username='u')
|
|
b = await BatchScript.objects.acreate(name='test', description='d', script='echo hi')
|
|
assert b.name == 'test'
|
|
|
|
@pytest.mark.django_db(transaction=True)
|
|
@pytest.mark.asyncio
|
|
async def test_batch_ws_requires_auth():
|
|
communicator = WebsocketCommunicator(application, "/ws/ssh/11111111-1111-1111-1111-111111111111/stream/")
|
|
connected, _ = await communicator.connect()
|
|
assert connected is False or (await communicator.receive_nothing(timeout=0.1) is None)
|
|
await communicator.disconnect()
|