mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
* Fix skipped API tests * Remove invalid tests * Correct logger name
This commit is contained in:
@ -1,13 +1,10 @@
|
||||
import datetime
|
||||
from unittest import skipIf
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.urls import reverse
|
||||
from django.utils.timezone import make_aware
|
||||
from django_rq.queues import get_connection
|
||||
from rest_framework import status
|
||||
from rq import Worker
|
||||
|
||||
from dcim.models import Device, DeviceRole, DeviceType, Manufacturer, Rack, Location, RackRole, Site
|
||||
from extras.api.views import ReportViewSet, ScriptViewSet
|
||||
@ -16,8 +13,6 @@ from extras.reports import Report
|
||||
from extras.scripts import BooleanVar, IntegerVar, Script, StringVar
|
||||
from utilities.testing import APITestCase, APIViewTestCases
|
||||
|
||||
rq_worker_running = Worker.count(get_connection('default'))
|
||||
|
||||
|
||||
class AppTest(APITestCase):
|
||||
|
||||
@ -539,16 +534,6 @@ class ReportTest(APITestCase):
|
||||
|
||||
self.assertEqual(response.data['name'], self.TestReport.__name__)
|
||||
|
||||
@skipIf(not rq_worker_running, "RQ worker not running")
|
||||
def test_run_report(self):
|
||||
self.add_permissions('extras.run_script')
|
||||
|
||||
url = reverse('extras-api:report-run', kwargs={'pk': None})
|
||||
response = self.client.post(url, {}, format='json', **self.header)
|
||||
self.assertHttpStatus(response, status.HTTP_200_OK)
|
||||
|
||||
self.assertEqual(response.data['result']['status']['value'], 'pending')
|
||||
|
||||
|
||||
class ScriptTest(APITestCase):
|
||||
|
||||
@ -589,27 +574,6 @@ class ScriptTest(APITestCase):
|
||||
self.assertEqual(response.data['vars']['var2'], 'IntegerVar')
|
||||
self.assertEqual(response.data['vars']['var3'], 'BooleanVar')
|
||||
|
||||
@skipIf(not rq_worker_running, "RQ worker not running")
|
||||
def test_run_script(self):
|
||||
self.add_permissions('extras.run_script')
|
||||
|
||||
script_data = {
|
||||
'var1': 'FooBar',
|
||||
'var2': 123,
|
||||
'var3': False,
|
||||
}
|
||||
|
||||
data = {
|
||||
'data': script_data,
|
||||
'commit': True,
|
||||
}
|
||||
|
||||
url = reverse('extras-api:script-detail', kwargs={'pk': None})
|
||||
response = self.client.post(url, data, format='json', **self.header)
|
||||
self.assertHttpStatus(response, status.HTTP_200_OK)
|
||||
|
||||
self.assertEqual(response.data['result']['status']['value'], 'pending')
|
||||
|
||||
|
||||
class CreatedUpdatedFilterTest(APITestCase):
|
||||
|
||||
|
@ -836,7 +836,7 @@ class VLANTest(APIViewTestCases.APIViewTestCase):
|
||||
|
||||
self.add_permissions('ipam.delete_vlan')
|
||||
url = reverse('ipam-api:vlan-detail', kwargs={'pk': vlan.pk})
|
||||
with disable_warnings('django.request'):
|
||||
with disable_warnings('netbox.api.views.ModelViewSet'):
|
||||
response = self.client.delete(url, **self.header)
|
||||
|
||||
self.assertHttpStatus(response, status.HTTP_409_CONFLICT)
|
||||
|
@ -12,7 +12,7 @@ class AppTest(APITestCase):
|
||||
def test_root(self):
|
||||
|
||||
url = reverse('users-api:api-root')
|
||||
response = self.client.get('{}?format=api'.format(url), **self.header)
|
||||
response = self.client.get(f'{url}?format=api', **self.header)
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
@ -36,14 +36,17 @@ class UserTest(APIViewTestCases.APIViewTestCase):
|
||||
'password': 'password6',
|
||||
},
|
||||
]
|
||||
bulk_update_data = {
|
||||
'email': 'test@example.com',
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def setUpTestData(cls):
|
||||
|
||||
users = (
|
||||
User(username='User_1'),
|
||||
User(username='User_2'),
|
||||
User(username='User_3'),
|
||||
User(username='User_1', password='password1'),
|
||||
User(username='User_2', password='password2'),
|
||||
User(username='User_3', password='password3'),
|
||||
)
|
||||
User.objects.bulk_create(users)
|
||||
|
||||
@ -74,6 +77,12 @@ class GroupTest(APIViewTestCases.APIViewTestCase):
|
||||
)
|
||||
Group.objects.bulk_create(users)
|
||||
|
||||
def test_bulk_update_objects(self):
|
||||
"""
|
||||
Disabled test. There's no attribute we can set in bulk for Groups.
|
||||
"""
|
||||
return
|
||||
|
||||
|
||||
class TokenTest(
|
||||
# No GraphQL support for Token
|
||||
|
Reference in New Issue
Block a user