network_inventory/backend/backups/tests/test_backups_views.py

88 lines
2.5 KiB
Python
Raw Normal View History

2020-11-30 17:11:10 +01:00
import pytest
from django.urls import reverse
@pytest.mark.django_db
def test_unauthorized_request_backup_method(api_client):
2020-12-06 14:15:52 +01:00
url = reverse('backupmethod-list')
2020-11-30 17:11:10 +01:00
response = api_client.get(url)
assert response.status_code == 403
@pytest.mark.django_db
2020-12-07 15:41:45 +01:00
def test_authorized_request_backup_method(api_client_authenticated):
url = reverse('backupmethod-list')
2020-12-07 15:41:45 +01:00
response = api_client_authenticated.get(url)
assert response.status_code == 200
2020-11-30 17:11:10 +01:00
@pytest.mark.django_db
def test_unauthorized_request_backup(api_client):
url = reverse('backup-list')
response = api_client.get(url)
assert response.status_code == 403
@pytest.mark.django_db
2020-12-07 15:41:45 +01:00
def test_authorized_request_backup(api_client_authenticated):
url = reverse('backup-list')
2020-12-07 15:41:45 +01:00
response = api_client_authenticated.get(url)
assert response.status_code == 200
2020-11-30 17:11:10 +01:00
@pytest.mark.django_db
def test_unauthorized_request_target_device(api_client):
2020-12-06 14:15:52 +01:00
url = reverse('targetdevice-list')
2020-11-30 17:11:10 +01:00
response = api_client.get(url)
assert response.status_code == 403
@pytest.mark.django_db
2020-12-07 15:41:45 +01:00
def test_authorized_request_target_device(api_client_authenticated):
url = reverse('targetdevice-list')
2020-12-07 15:41:45 +01:00
response = api_client_authenticated.get(url)
assert response.status_code == 200
2020-11-30 17:11:10 +01:00
@pytest.mark.django_db
def test_unauthorized_request_notificaton_from_backup(api_client):
2020-12-06 14:15:52 +01:00
url = reverse('notificationfrombackup-list')
2020-11-30 17:11:10 +01:00
response = api_client.get(url)
assert response.status_code == 403
2020-11-30 17:23:35 +01:00
@pytest.mark.django_db
2020-12-07 15:41:45 +01:00
def test_authorized_request_notificaton_from_backup(api_client_authenticated):
url = reverse('notificationfrombackup-list')
2020-12-07 15:41:45 +01:00
response = api_client_authenticated.get(url)
assert response.status_code == 200
2020-11-30 17:23:35 +01:00
@pytest.mark.django_db
def test_unauthorized_request_notificaton(api_client):
url = reverse('notification-list')
response = api_client.get(url)
assert response.status_code == 403
@pytest.mark.django_db
2020-12-07 15:41:45 +01:00
def test_authorized_request_notificaton(api_client_authenticated):
url = reverse('notification-list')
2020-12-07 15:41:45 +01:00
response = api_client_authenticated.get(url)
assert response.status_code == 200
2020-11-30 17:23:35 +01:00
@pytest.mark.django_db
def test_unauthorized_request_notificaton_type(api_client):
2020-12-06 14:15:52 +01:00
url = reverse('notificationtype-list')
2020-11-30 17:23:35 +01:00
response = api_client.get(url)
assert response.status_code == 403
@pytest.mark.django_db
2020-12-07 15:41:45 +01:00
def test_authorized_request_notificaton_type(api_client_authenticated):
url = reverse('notificationtype-list')
2020-12-07 15:41:45 +01:00
response = api_client_authenticated.get(url)
assert response.status_code == 200