From 92d5cbf1d98e0f74a663d2cd244b11b9780ac6c8 Mon Sep 17 00:00:00 2001 From: Philip Guyton Date: Thu, 7 Nov 2024 17:09:09 +0000 Subject: [PATCH] NFS exports restored as read-only - continued 1 #2912 - Add default ordering to NFSExportGroup models. Addresses re-enabled test provoked warnings re: "UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list" --- .../storageadmin/models/nfs_export_group.py | 1 + .../storageadmin/tests/test_nfs_export.py | 24 +++++++------------ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/rockstor/storageadmin/models/nfs_export_group.py b/src/rockstor/storageadmin/models/nfs_export_group.py index 06afb5146..e3fcf328e 100644 --- a/src/rockstor/storageadmin/models/nfs_export_group.py +++ b/src/rockstor/storageadmin/models/nfs_export_group.py @@ -69,3 +69,4 @@ class NFSExportGroup(models.Model): class Meta: app_label = "storageadmin" + ordering = ['-id'] diff --git a/src/rockstor/storageadmin/tests/test_nfs_export.py b/src/rockstor/storageadmin/tests/test_nfs_export.py index 43dc8742c..7a11d2646 100644 --- a/src/rockstor/storageadmin/tests/test_nfs_export.py +++ b/src/rockstor/storageadmin/tests/test_nfs_export.py @@ -86,21 +86,15 @@ def setUpClass(cls): def tearDownClass(cls): super(NFSExportTests, cls).tearDownClass() - # TODO: FAIL {"detail":"Not found."} - # def test_get(self): - # """ - # Test GET request - # 1. Get base URL - # 2. Get request with id - # """ - # # get base URL - # self.get_base(self.BASE_URL) - # - # # get nfs-export with id - # nfs_id = self.temp_nfsexport.id - # response = self.client.get('{}/{}'.format(self.BASE_URL, nfs_id)) - # self.assertEqual(response.status_code, status.HTTP_200_OK, - # msg=response) + def test_get(self): + + # get base URL + self.get_base(self.BASE_URL) + + # get nfs-export with id + nfs_id = 3 # from fixture + response = self.client.get(f'{self.BASE_URL}/{nfs_id}') + self.assertEqual(response.status_code, status.HTTP_200_OK, msg=response) def test_invalid_get(self): # get nfs-export with invalid id