Skip to content

Commit

Permalink
Further create e2e tests #342
Browse files Browse the repository at this point in the history
  • Loading branch information
joelvdavies committed Aug 5, 2024
1 parent 0345d92 commit b975908
Show file tree
Hide file tree
Showing 3 changed files with 291 additions and 269 deletions.
34 changes: 26 additions & 8 deletions test/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ def check_created_and_modified_times_updated_correctly(post_response: Response,

@staticmethod
def replace_unit_values_with_ids_in_properties(data: dict, unit_value_id_dict: dict[str, str]) -> dict:
"""Inserts unit IDs into some data that may have a 'properties' list within it
"""Inserts unit IDs into some data that may have a 'properties' list within it.
:param data: Dictionary of data that could have a 'properties' value within it
:param unit_value_id_dict: Dictionary of unit value and ID pairs for unit ID lookups
:return: The data with any needed unit IDs inserted
:param data: Dictionary of data that could have a 'properties' value within it.
:param unit_value_id_dict: Dictionary of unit value and ID pairs for unit ID lookups.
:return: The data with any needed unit IDs inserted.
"""

if "properties" in data and data["properties"]:
Expand All @@ -131,11 +131,11 @@ def replace_unit_values_with_ids_in_properties(data: dict, unit_value_id_dict: d

@staticmethod
def replace_property_names_with_ids_in_properties(data: dict, property_name_id_dict: dict[str, str]) -> dict:
"""Inserts property IDs into some data that may have a 'properties' list within it
"""Inserts property IDs into some data that may have a 'properties' list within it.
:param data: Dictionary of data that could have a 'properties' value within it
:param property_name_id_dict: Dictionary of property name and ID pairs for property ID lookups
:return: The data with any needed property IDs inserted
:param data: Dictionary of data that could have a 'properties' value within it.
:param property_name_id_dict: Dictionary of property name and ID pairs for property ID lookups.
:return: The data with any needed property IDs inserted.
"""

if "properties" in data and data["properties"]:
Expand All @@ -147,3 +147,21 @@ def replace_property_names_with_ids_in_properties(data: dict, property_name_id_d
new_properties.append(new_property)
return {**data, "properties": new_properties}
return data

@staticmethod
def add_property_ids_to_properties(data: dict, property_name_id_dict: dict[str, str]) -> dict:
"""Inserts property IDs into some data that may have a 'properties' list within it.
:param data: Dictionary of data that could have a 'properties' value within it.
:param property_name_id_dict: Dictionary of property name and ID pairs for property ID lookups.
:return: The data with any needed property IDs inserted.
"""

if "properties" in data and data["properties"]:
new_properties = []
for prop in data["properties"]:
new_property = {**prop}
new_property["id"] = property_name_id_dict[prop["name"]]
new_properties.append(new_property)
return {**data, "properties": new_properties}
return data
Loading

0 comments on commit b975908

Please sign in to comment.