def test_easting_northing_no_zone(self): """ In the case of a Easting/Northing only schema the zone is mandatory if the project datum is not a projected one (e.g: WSG84) """ from main.constants import is_projected_srid project = self.project_1 # project datum is not a Zone one self.assertEqual(project.datum, 4326) self.assertFalse(is_projected_srid(project.datum)) fields_no_zone = [{ "name": "Observation Date", "type": "date", "format": "any", "constraints": { "required": True, } }, { "name": "Northing", "type": "number", "format": "default", "constraints": { "required": True, }, }, { "name": "Easting", "type": "number", "format": "default", "constraints": { "required": True, }, }] url = reverse('api:dataset-list') client = self.data_engineer_1_client data = { "name": "New for Unit test", "type": Dataset.TYPE_OBSERVATION, "project": project.pk, 'data_package': helpers.create_data_package_from_fields(fields_no_zone) } resp = client.post(url, data, format='json') self.assertEqual(resp.status_code, status.HTTP_400_BAD_REQUEST) # check error message resp_data = resp.json() errors = resp_data.get('data_package') self.assertEqual(len(errors), 1) self.assertIn('Northing/easting coordinates require a zone', errors[0]) # change the project datum project.datum = 28350 # 'GDA94 / MGA zone 50' project.save() self.assertTrue(is_projected_srid(project.datum)) resp = client.post(url, data, format='json') self.assertEqual(resp.status_code, status.HTTP_201_CREATED)
def _more_setup(self): self.fields = [{ "name": "Column A", "type": "string", "constraints": helpers.NOT_REQUIRED_CONSTRAINTS }, { "name": "Column B", "type": "string", "constraints": helpers.REQUIRED_CONSTRAINTS }] self.data_package = helpers.create_data_package_from_fields( self.fields) self.ds = factories.DatasetFactory(project=self.project_1, type=Dataset.TYPE_GENERIC, data_package=self.data_package) self.url = reverse('api:dataset-upload', kwargs={'pk': self.ds.pk})