From 4b1a23b781690778f2da6174f9292e15be9962d5 Mon Sep 17 00:00:00 2001 From: Alex Swindler Date: Fri, 20 Sep 2024 11:00:25 -0600 Subject: [PATCH] Update tests --- seed/models/columns.py | 2 +- seed/serializers/meter_readings.py | 3 ++- seed/tests/test_audit_template_configs.py | 2 +- seed/tests/test_element_views.py | 2 +- seed/tests/test_property_views.py | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/seed/models/columns.py b/seed/models/columns.py index c2c744ffcb..7619e7e1a2 100644 --- a/seed/models/columns.py +++ b/seed/models/columns.py @@ -966,7 +966,7 @@ def _serialize_for_extra_data(column_value): setattr(datum, new_column.column_name, getattr(datum, self.column_name)) setattr(datum, self.column_name, None) datum.save() - except (ValidationError, DataError): + except (ValidationError, DataError, ValueError): return [ False, "The column data aren't formatted properly for the new column due to type constraints (e.g., Datatime, Quantities, etc.).", diff --git a/seed/serializers/meter_readings.py b/seed/serializers/meter_readings.py index b651c5016d..dbbbbed9ba 100644 --- a/seed/serializers/meter_readings.py +++ b/seed/serializers/meter_readings.py @@ -3,6 +3,7 @@ See also https://github.com/SEED-platform/seed/blob/main/LICENSE.md """ +from collections import OrderedDict from typing import Tuple import dateutil.parser @@ -107,7 +108,7 @@ def create(self, validated_data) -> MeterReading: return updated_reading def to_representation(self, obj): - result = super().to_representation(obj) + result = OrderedDict(super().to_representation(obj)) # TODO: we need to actually read the units from the meter, then convert accordingly. # SEED stores all energy data in kBtus diff --git a/seed/tests/test_audit_template_configs.py b/seed/tests/test_audit_template_configs.py index 3e3437af15..aa311b648b 100644 --- a/seed/tests/test_audit_template_configs.py +++ b/seed/tests/test_audit_template_configs.py @@ -60,7 +60,7 @@ def test_audit_template_config_create(self): # testing one-to-one relationship response = self.client.post(url, params, content_type="application/json") assert response.status_code == 400 - assert response.json()["errors"] == {"organization": ["This field must be unique."]} + assert response.json()["errors"] == {"organization": ["audit template config with this organization already exists."]} def test_audit_template_config_update(self): # Invalid params diff --git a/seed/tests/test_element_views.py b/seed/tests/test_element_views.py index cfd4ec14f0..eeb7ed395c 100644 --- a/seed/tests/test_element_views.py +++ b/seed/tests/test_element_views.py @@ -195,7 +195,7 @@ def test_get_org_element_permissions(self): self.login_as_child_member() response = self.client.get(url) assert response.status_code == 404 - assert response.json() == {"detail": "Not found."} + assert response.json() == {"detail": "No Element matches the given query."} # root user can see element self.login_as_root_member() diff --git a/seed/tests/test_property_views.py b/seed/tests/test_property_views.py index d9deb30aa0..5643b4c757 100644 --- a/seed/tests/test_property_views.py +++ b/seed/tests/test_property_views.py @@ -173,7 +173,7 @@ def test_create_property_in_diff_org(self): url = reverse("api:v3:properties-list") + f"?organization_id={org_2.pk}" response = self.client.post(url, params, content_type="application/json") self.assertEqual(response.status_code, 403) - self.assertEqual(response.json()["detail"], "You do not have permission to perform this action.") + self.assertEqual(response.json()["detail"], "Incorrect org id.") def test_create_property_with_protected_fields(self): state = self.property_state_factory.get_property_state()