Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #17969: Fix system info export when a config revision exists #17991

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions netbox/core/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,3 +346,32 @@ def test_worker(self):
self.assertIn(str(worker1.name), str(response.content))
self.assertIn('Birth', str(response.content))
self.assertIn('Total working time', str(response.content))


class SystemTestCase(TestCase):

def setUp(self):
super().setUp()

self.user.is_staff = True
self.user.save()

def test_system_view_default(self):
# Test UI render
response = self.client.get(reverse('core:system'))
self.assertEqual(response.status_code, 200)

# Test export
response = self.client.get(f"{reverse('core:system')}?export=true")
self.assertEqual(response.status_code, 200)

def test_system_view_with_config_revision(self):
ConfigRevision.objects.create()

# Test UI render
response = self.client.get(reverse('core:system'))
self.assertEqual(response.status_code, 200)

# Test export
response = self.client.get(f"{reverse('core:system')}?export=true")
self.assertEqual(response.status_code, 200)
6 changes: 1 addition & 5 deletions netbox/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,11 +626,7 @@ def get(self, request):
}

# Configuration
try:
config = ConfigRevision.objects.get(pk=cache.get('config_version'))
except ConfigRevision.DoesNotExist:
# Fall back to using the active config data if no record is found
config = get_config()
config = get_config()

# Raw data export
if 'export' in request.GET:
Expand Down