1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Add GraphQL for virtualization

This commit is contained in:
jeremystretch
2021-06-25 15:31:43 -04:00
parent 881b18f6d0
commit 605b7c5b3e
8 changed files with 100 additions and 18 deletions

View File

@@ -425,10 +425,16 @@ class APIViewTestCases:
class GraphQLTestCase(APITestCase):
def _get_graphql_base_name(self, plural=False):
if plural:
return getattr(self, 'graphql_base_name_plural',
self.model._meta.verbose_name_plural.lower().replace(' ', '_'))
return getattr(self, 'graphql_base_name', self.model._meta.verbose_name.lower().replace(' ', '_'))
@override_settings(LOGIN_REQUIRED=True)
def test_graphql_get_object(self):
url = reverse('graphql')
object_type = self.model._meta.verbose_name.lower().replace(' ', '_')
object_type = self._get_graphql_base_name()
object_id = self._get_queryset().first().pk
query = f"""
{{
@@ -459,7 +465,7 @@ class APIViewTestCases:
@override_settings(LOGIN_REQUIRED=True)
def test_graphql_list_objects(self):
url = reverse('graphql')
object_type = self.model._meta.verbose_name_plural.lower().replace(' ', '_')
object_type = self._get_graphql_base_name(plural=True)
query = f"""
{{
{object_type} {{