From 7eec8bd1e56939b63ea6849de0baeb55391e9ad4 Mon Sep 17 00:00:00 2001 From: wlorenzetti Date: Tue, 31 Dec 2024 14:26:52 +0100 Subject: [PATCH] Fix test for Django 4.2 --- .../tests/data/editing_test_qgis334.qgs | 1390 +++++++++-------- g3w-admin/editing/tests/test_models.py | 4 - g3w-admin/qplotly/tests/test_api.py | 39 +- g3w-admin/qplotly/tests/test_models.py | 28 +- g3w-admin/qplotly/tests/test_views.py | 17 +- g3w-admin/qtimeseries/tests/base.py | 28 +- g3w-admin/usersmanage/tests/test_api.py | 1 - g3w-admin/usersmanage/tests/test_utils.py | 1 - 8 files changed, 778 insertions(+), 730 deletions(-) diff --git a/g3w-admin/editing/tests/data/editing_test_qgis334.qgs b/g3w-admin/editing/tests/data/editing_test_qgis334.qgs index 37f6fe5b4..c1c476b05 100644 --- a/g3w-admin/editing/tests/data/editing_test_qgis334.qgs +++ b/g3w-admin/editing/tests/data/editing_test_qgis334.qgs @@ -1,5 +1,5 @@ - + editing_test @@ -17,22 +17,22 @@ true - + - + - + - + @@ -43,16 +43,16 @@ cities_54d40b01_2af8_4b17_8495_c5833485536e - + - - - + + + - + degrees -5.75647150000001062 @@ -79,24 +79,24 @@ - - - + Annotations_82e32697_04fc_4e3b_9178_f7f2a5fe15ca @@ -157,9 +157,21 @@ - + + + 8.88083699999999965 + 42.40723200000000048 + 13.44107799999999919 + 46.01007784502829878 + + + 8.88083699999999965 + 42.40723200000000048 + 13.44107799999999919 + 46.01007784502829878 + cities_54d40b01_2af8_4b17_8495_c5833485536e - dbname='./editing_test.db' table="cities" (geometry) + dbname='/home/walter/PycharmProjects/g3w_suite_qgis_api/g3w-admin/editing/tests/data/editing_test.db' table="cities" (geometry) @@ -211,7 +223,7 @@ - + @@ -222,7 +234,7 @@ spatialite - + @@ -238,181 +250,181 @@ 1 0 - + - + - + - + - + - + - + - + - + - + - + @@ -426,66 +438,66 @@ - 0 0 1 - - - - + + + + - + - + @@ -493,16 +505,16 @@ - + - + @@ -679,30 +691,30 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -731,82 +743,82 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -814,31 +826,31 @@ - @@ -869,30 +881,30 @@ def my_form_open(dialog, layer, feature): 0 generatedlayout - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -926,9 +938,21 @@ def my_form_open(dialog, layer, feature): geonameid - + + + -5.14223100000000954 + 35.4922069999999934 + 19.42738900000000513 + 55.05564899999998829 + + + -5.14223100000000954 + 35.4922069999999934 + 19.42738900000001578 + 55.05564899999994566 + countries_63e59c18_a1d0_4e25_968a_ccbaecd11725 - dbname='./editing_test.db' table="countries" (geometry) + dbname='/home/walter/PycharmProjects/g3w_suite_qgis_api/g3w-admin/editing/tests/data/editing_test.db' table="countries" (geometry) @@ -988,173 +1012,173 @@ def my_form_open(dialog, layer, feature): 1 0 - + - + - + - + - + - + - + - + - + - + - + @@ -1168,13 +1192,13 @@ def my_form_open(dialog, layer, feature): 0 0 1 - + @@ -1311,24 +1335,24 @@ def my_form_open(dialog, layer, feature): - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -1351,64 +1375,64 @@ def my_form_open(dialog, layer, feature): - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -1416,25 +1440,25 @@ def my_form_open(dialog, layer, feature): - @@ -1457,9 +1481,21 @@ def my_form_open(dialog, layer, feature): "name_local" - + + + 7.07773409230401018 + 41.02184299999998984 + 18.93406205412870591 + 46.83325600000000577 + + + 7.07773409230401018 + 41.02184299999998984 + 18.93406205412870591 + 46.83325600000000577 + rivers_ec97a7c6_e390_4453_a410_f39843596012 - dbname='./editing_test.db' table="rivers" (geometry) + dbname='/home/walter/PycharmProjects/g3w_suite_qgis_api/g3w-admin/editing/tests/data/editing_test.db' table="rivers" (geometry) @@ -1519,189 +1555,189 @@ def my_form_open(dialog, layer, feature): 1 0 - + - + - + - + - + - + - + - + - + - + - + @@ -1719,7 +1755,7 @@ def my_form_open(dialog, layer, feature): 0 0 1 - + @@ -1744,24 +1780,24 @@ def my_form_open(dialog, layer, feature): - - + + - - + + - - + + - - + + @@ -1823,6 +1859,14 @@ def my_form_open(dialog, layer, feature): m2 meters + + 0 + + 0 + 1 + + 0 + 50 5 @@ -1841,13 +1885,14 @@ def my_form_open(dialog, layer, feature): 255,0,0,255 - false + true true 2 MU + false 1 @@ -1861,6 +1906,7 @@ def my_form_open(dialog, layer, feature): None + false false @@ -1869,11 +1915,12 @@ def my_form_open(dialog, layer, feature): 1 - -0.87774635968768777 - 35.94447613939637876 - 26.50871809721871131 - 51.07642868851524298 + -0.87774635999999995 + 35.94447613900000249 + 26.50871809699999915 + 51.07642868899999655 + false conditions unknown 90 @@ -1916,9 +1963,9 @@ def my_form_open(dialog, layer, feature): @@ -1953,42 +2000,55 @@ def my_form_open(dialog, layer, feature): + + + GEOGCRS["WGS 84",ENSEMBLE["World Geodetic System 1984 ensemble",MEMBER["World Geodetic System 1984 (Transit)"],MEMBER["World Geodetic System 1984 (G730)"],MEMBER["World Geodetic System 1984 (G873)"],MEMBER["World Geodetic System 1984 (G1150)"],MEMBER["World Geodetic System 1984 (G1674)"],MEMBER["World Geodetic System 1984 (G1762)"],MEMBER["World Geodetic System 1984 (G2139)"],ELLIPSOID["WGS 84",6378137,298.257223563,LENGTHUNIT["metre",1]],ENSEMBLEACCURACY[2.0]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["Horizontal component of 3D system."],AREA["World."],BBOX[-90,-180,90,180]],ID["EPSG",4326]] + +proj=longlat +datum=WGS84 +no_defs + 3452 + 4326 + EPSG:4326 + WGS 84 + longlat + EPSG:7030 + true + + - + - + - + @@ -2005,7 +2065,7 @@ def my_form_open(dialog, layer, feature): - + diff --git a/g3w-admin/editing/tests/test_models.py b/g3w-admin/editing/tests/test_models.py index 00aefb7c2..5e1b283d5 100644 --- a/g3w-admin/editing/tests/test_models.py +++ b/g3w-admin/editing/tests/test_models.py @@ -108,10 +108,6 @@ def setUp(self): So setUpTestData is changed in setUp calss method ''' - - #Restore test database - self.reset_db_data() - call_command('loaddata', 'BaseLayer.json', '--database=default', verbosity=0) call_command('loaddata', 'G3WMapControls.json', diff --git a/g3w-admin/qplotly/tests/test_api.py b/g3w-admin/qplotly/tests/test_api.py index 988618a19..46865278f 100644 --- a/g3w-admin/qplotly/tests/test_api.py +++ b/g3w-admin/qplotly/tests/test_api.py @@ -45,26 +45,25 @@ def setUpClass(cls): cls.client = APIClient() - @classmethod - def setUpTestData(cls): - # main project group - cls.project_group = CoreGroup(name='Group1', title='Group1', header_logo_img='', + def setUp(self): + # Main project group + self.project_group = CoreGroup(name='Group1', title='Group1', header_logo_img='', srid=G3WSpatialRefSys.objects.get(auth_srid=4326)) - cls.project_group.save() + self.project_group.save() - cls.project_group_3857 = CoreGroup(name='Group3857', title='Group3857', header_logo_img='', + self.project_group_3857 = CoreGroup(name='Group3857', title='Group3857', header_logo_img='', srid=G3WSpatialRefSys.objects.get(auth_srid=3857)) - cls.project_group_3857.save() + self.project_group_3857.save() qgis_project_file = File(open('{}{}{}'.format(CURRENT_PATH, TEST_BASE_PATH, QGS_FILE), 'r', encoding='utf-8')) # Replace name property with only file name without path to simulate UploadedFileWithId instance. qgis_project_file.name = qgis_project_file.name.split('/')[-1] - cls.project = QgisProject(qgis_project_file) - cls.project.group = cls.project_group - cls.project.save() + self.project = QgisProject(qgis_project_file) + self.project.group = self.project_group + self.project.save() qgis_project_file.close() qgis_project_file_3857 = File( @@ -72,28 +71,28 @@ def setUpTestData(cls): # Replace name property with only file name without path to simulate UploadedFileWithId instance. qgis_project_file_3857.name = qgis_project_file_3857.name.split('/')[-1] - cls.project_3857 = QgisProject(qgis_project_file_3857) - cls.project_3857.group = cls.project_group_3857 - cls.project_3857.save() + self.project_3857 = QgisProject(qgis_project_file_3857) + self.project_3857.group = self.project_group_3857 + self.project_3857.save() qgis_project_file_3857.close() file = File(open(f'{DATASOURCE_PATH}cities_scatter_plot_wrong_source_layer_id.xml', 'r')) - cls.wrong_settings_source_layer_id_xml = file.read() + self.wrong_settings_source_layer_id_xml = file.read() file.close() file = File(open(f'{DATASOURCE_PATH}countries_pie_plot_with_title.xml', 'r')) - cls.countries_plot_xml = file.read() + self.countries_plot_xml = file.read() file.close() file = File(open(f'{DATASOURCE_PATH}cities_histogram_plot.xml', 'r')) - cls.cities_histogram_plot_xml = file.read() + self.cities_histogram_plot_xml = file.read() file.close() - @classmethod - def tearDownClass(cls): - cls.project.instance.delete() - super().tearDownClass() + + def tearDown(self): + self.project.instance.delete() + super().tearDown() diff --git a/g3w-admin/qplotly/tests/test_models.py b/g3w-admin/qplotly/tests/test_models.py index daec22a47..9f05a9ea8 100644 --- a/g3w-admin/qplotly/tests/test_models.py +++ b/g3w-admin/qplotly/tests/test_models.py @@ -32,43 +32,41 @@ def setUpClass(cls): cls.client = APIClient() - @classmethod - def setUpTestData(cls): + def setUp(self): - cls.project_group = CoreGroup(name='Group1', title='Group1', header_logo_img='', + self.project_group = CoreGroup(name='Group1', title='Group1', header_logo_img='', srid=G3WSpatialRefSys.objects.get(auth_srid=4326)) - cls.project_group.save() + self.project_group.save() qgis_project_file = File(open('{}{}{}'.format(CURRENT_PATH, TEST_BASE_PATH, QGS_FILE), 'r', encoding='utf-8')) # Replace name property with only file name without path to simulate UploadedFileWithId instance. qgis_project_file.name = qgis_project_file.name.split('/')[-1] - cls.project = QgisProject(qgis_project_file) - cls.project.group = cls.project_group - cls.project.save() + self.project = QgisProject(qgis_project_file) + self.project.group = self.project_group + self.project.save() qgis_project_file.close() file = File(open(f'{DATASOURCE_PATH}data_plotly_settings.xml', 'r')) - cls.histogram_countries_xml = file.read() + self.histogram_countries_xml = file.read() file.close() file = File(open(f'{DATASOURCE_PATH}cities_scatter_plot.xml', 'r')) - cls.scatter_cities_xml = file.read() + self.scatter_cities_xml = file.read() file.close() file = File(open(f'{DATASOURCE_PATH}wrong_data_plotly_settings.xml', 'r')) - cls.wrong_settings_xml = file.read() + self.wrong_settings_xml = file.read() file.close() file = File(open(f'{DATASOURCE_PATH}cities_scatter_plot_wrong_source_layer_id.xml', 'r')) - cls.wrong_settings_source_layer_id_xml = file.read() + self.wrong_settings_source_layer_id_xml = file.read() file.close() - @classmethod - def tearDownClass(cls): - cls.project.instance.delete() - super().tearDownClass() + def tearDown(self): + self.project.instance.delete() + super().tearDown() def test_widget(self): """Test QplotlyWidget model""" diff --git a/g3w-admin/qplotly/tests/test_views.py b/g3w-admin/qplotly/tests/test_views.py index 76d5bc311..f56822c4d 100644 --- a/g3w-admin/qplotly/tests/test_views.py +++ b/g3w-admin/qplotly/tests/test_views.py @@ -39,29 +39,28 @@ def setUpClass(cls): cls.client = Client() - @classmethod - def setUpTestData(cls): + def setUp(self): # main project group - cls.project_group = CoreGroup(name='Group1', title='Group1', header_logo_img='', + self.project_group = CoreGroup(name='Group1', title='Group1', header_logo_img='', srid=G3WSpatialRefSys.objects.get(auth_srid=4326)) - cls.project_group.save() + self.project_group.save() qgis_project_file = File(open('{}{}{}'.format(CURRENT_PATH, TEST_BASE_PATH, QGS_FILE), 'r', encoding='utf-8')) # Replace name property with only file name without path to simulate UploadedFileWithId instance. qgis_project_file.name = qgis_project_file.name.split('/')[-1] - cls.project = QgisProject(qgis_project_file) - cls.project.group = cls.project_group - cls.project.save() + self.project = QgisProject(qgis_project_file) + self.project.group = self.project_group + self.project.save() qgis_project_file.close() file = File(open(f'{DATASOURCE_PATH}countries_pie_plot_with_title.xml', 'r')) - cls.countries_plot_xml = file.read() + self.countries_plot_xml = file.read() file.close() file = File(open(f'{DATASOURCE_PATH}cities_histogram_plot.xml', 'r')) - cls.cities_histogram_plot_xml = file.read() + self.cities_histogram_plot_xml = file.read() file.close() def test_download_xml(self): diff --git a/g3w-admin/qtimeseries/tests/base.py b/g3w-admin/qtimeseries/tests/base.py index 4b52c1aeb..76f267d2e 100644 --- a/g3w-admin/qtimeseries/tests/base.py +++ b/g3w-admin/qtimeseries/tests/base.py @@ -35,22 +35,21 @@ def setUpClass(cls): cls.client = APIClient() - @classmethod - def setUpTestData(cls): - # main project group - cls.project_group = CoreGroup(name='Group1', title='Group1', header_logo_img='', + def setUp(self): + # Main project group + self.project_group = CoreGroup(name='Group1', title='Group1', header_logo_img='', srid=G3WSpatialRefSys.objects.get(auth_srid=4326)) - cls.project_group.save() + self.project_group.save() qgis_project_file = File(open('{}{}{}'.format(CURRENT_PATH, TEST_BASE_PATH, QGS_FILE_RASTER), 'r', encoding='utf-8')) # Replace name property with only file name without path to simulate UploadedFileWithId instance. qgis_project_file.name = qgis_project_file.name.split('/')[-1] - cls.project_raster = QgisProject(qgis_project_file) - cls.project_raster.group = cls.project_group - cls.project_raster.save() + self.project_raster = QgisProject(qgis_project_file) + self.project_raster.group = self.project_group + self.project_raster.save() qgis_project_file.close() qgis_project_file = File(open('{}{}{}'.format(CURRENT_PATH, TEST_BASE_PATH, QGS_FILE_RASTER_2), 'r', @@ -58,15 +57,14 @@ def setUpTestData(cls): # Replace name property with only file name without path to simulate UploadedFileWithId instance. qgis_project_file.name = qgis_project_file.name.split('/')[-1] - cls.project_raster_2 = QgisProject(qgis_project_file) - cls.project_raster_2.group = cls.project_group - cls.project_raster_2.save() + self.project_raster_2 = QgisProject(qgis_project_file) + self.project_raster_2.group = self.project_group + self.project_raster_2.save() qgis_project_file.close() - @classmethod - def tearDownClass(cls): - cls.project_raster.instance.delete() - super().tearDownClass() + def tearDown(self): + self.project_raster.instance.delete() + super().tearDown() def _testApiCall(self, view_name, args, kwargs={}, data=None, method='POST', username='admin01'): """Utility to make test calls for admin01 user""" diff --git a/g3w-admin/usersmanage/tests/test_api.py b/g3w-admin/usersmanage/tests/test_api.py index 6ca4e90d8..75ee89dd8 100644 --- a/g3w-admin/usersmanage/tests/test_api.py +++ b/g3w-admin/usersmanage/tests/test_api.py @@ -91,7 +91,6 @@ def test_list_users(self): self.assertEqual(res.data['count'], 3) - print(res.data['results']) self.assertEqual(res.data['results'][0], { "id": 7, "first_name": "", diff --git a/g3w-admin/usersmanage/tests/test_utils.py b/g3w-admin/usersmanage/tests/test_utils.py index 08f9c7c48..bb6234289 100644 --- a/g3w-admin/usersmanage/tests/test_utils.py +++ b/g3w-admin/usersmanage/tests/test_utils.py @@ -313,7 +313,6 @@ def test_get_perms_by_user_backend(self): self.test_editor2_3.userbackend.save() def fake_receiver(sender, **kwargs): - print ('passa') return [ 'add_user' ]