Skip to content

Commit

Permalink
Improve consistency with id's and fullstops in docstrings #314
Browse files Browse the repository at this point in the history
  • Loading branch information
joelvdavies committed Jul 25, 2024
1 parent e7b84e4 commit 7a0a6f2
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 29 deletions.
3 changes: 1 addition & 2 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from bson import ObjectId


VALID_ACCESS_TOKEN = (
"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InVzZXJuYW1lIiwiZXhwIjoyNTM0MDIzMDA3OTl9.bagU2Wix8wKzydVU_L3Z"
"ZuuMAxGxV4OTuZq_kS2Fuwm839_8UZOkICnPTkkpvsm1je0AWJaIXLGgwEa5zUjpG6lTrMMmzR9Zi63F0NXpJqQqoOZpTBMYBaggsXqFkdsv-yAKUZ"
Expand Down Expand Up @@ -49,7 +48,7 @@ def add_ids_to_properties(properties_with_ids: Optional[list], properties_withou
unit_id = None

if properties_with_ids:
# Match up property and unit ids
# Match up property and unit IDs
for property_with_id in properties_with_ids:
if property_with_id["name"] == property_without_id["name"]:
prop_id = property_with_id["id"]
Expand Down
4 changes: 2 additions & 2 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
:return: The data with any needed unit IDs inserted
"""

if "properties" in data and data["properties"]:
Expand Down
10 changes: 5 additions & 5 deletions test/e2e/test_catalogue_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ def post_catalogue_category(self, catalogue_category_data: dict) -> Optional[str
successful.
:param catalogue_category_data: Dictionary containing the basic catalogue category data as would be required
for a `CatalogueCategoryPostSchema` but with any unit_id's replaced by the
'unit' value in its properties as the ids will be added automatically.
:return: ID of the created catalogue category (or None if not successful).
for a `CatalogueCategoryPostSchema` but with any `unit_id`'s replaced by the
'unit' value in its properties as the IDs will be added automatically.
:return: ID of the created catalogue category (or `None` if not successful).
"""

# Replace any unit values with unit ids
# Replace any unit values with unit IDs
catalogue_category_data = E2ETestHelpers.replace_unit_values_with_ids_in_properties(
catalogue_category_data, self.unit_value_id_dict
)
Expand Down Expand Up @@ -455,7 +455,7 @@ def post_nested_catalogue_categories(self, number: int) -> list[Optional[str]]:
parent.
:param number: Number of catalogue categories to create.
:return: List of ids of the created catalogue categories.
:return: List of IDs of the created catalogue categories.
"""

parent_id = None
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def post_nested_systems(self, number: int) -> list[Optional[str]]:
Posts the given number of nested systems where each successive one has the previous as its parent.
:param number: Number of systems to create.
:return: List of ids of the created systems.
:return: List of IDs of the created systems.
"""

parent_id = None
Expand Down
14 changes: 7 additions & 7 deletions test/unit/repositories/test_catalogue_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def test_has_child_elements_with_no_child_items(test_helpers, database_mock, cat

def test_has_child_elements_with_child_items(test_helpers, database_mock, catalogue_item_repository):
"""
Test has_child_elements returns true when there are child items
Test has_child_elements returns true when there are child items.
"""

catalogue_category_id = str(ObjectId())
Expand All @@ -483,9 +483,9 @@ def test_has_child_elements_with_child_items(test_helpers, database_mock, catalo

def test_list_ids(database_mock, catalogue_item_repository):
"""
Test getting catalogue item ids.
Test getting catalogue item IDs.
Verify that the `list_ids` method properly handles the retrieval of catalogue item ids given a
Verify that the `list_ids` method properly handles the retrieval of catalogue item IDs given a
catalogue_category_id to filter by.
"""
session = MagicMock()
Expand All @@ -507,10 +507,10 @@ def test_list_ids(database_mock, catalogue_item_repository):
@patch("inventory_management_system_api.repositories.catalogue_item.datetime")
def test_insert_property_to_all_matching(datetime_mock, test_helpers, database_mock, catalogue_item_repository):
"""
Test inserting a property
Test inserting a property.
Verify that the `insert_property_to_all_matching` method properly handles the insertion of a
property
property.
"""
session = MagicMock()
catalogue_category_id = str(ObjectId())
Expand All @@ -534,10 +534,10 @@ def test_insert_property_to_all_matching(datetime_mock, test_helpers, database_m
@patch("inventory_management_system_api.repositories.catalogue_item.datetime")
def test_update_names_of_all_properties_with_id(datetime_mock, test_helpers, database_mock, catalogue_item_repository):
"""
Test updating the names of all properties with a given id
Test updating the names of all properties with a given id.
Verify that the `update_names_of_all_properties_with_id` method properly handles the update of
property names
property names.
"""
session = MagicMock()
property_id = str(ObjectId())
Expand Down
2 changes: 1 addition & 1 deletion test/unit/repositories/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def mock_get(self, system_id: str, system_in_data: Optional[dict]) -> None:
:param system_id: ID of the system to be obtained.
:param system_in_data: Either `None` or a dictionary containing the system data as would be required for a
`SystemIn` database model (i.e. No id or created and modified times required).
`SystemIn` database model (i.e. No ID or created and modified times required).
"""

self._expected_system_out = (
Expand Down
22 changes: 11 additions & 11 deletions test/unit/services/test_catalogue_category.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ def construct_properties_in_and_post_with_ids(
) -> tuple[list[CatalogueCategoryPropertyIn], list[CatalogueCategoryPostPropertySchema]]:
"""
Returns a list of property post schemas and expected property in models by adding
in unit ids. It also assigns `unit_value_id_dict` for looking up these ids.
in unit IDs. It also assigns `unit_value_id_dict` for looking up these IDs.
:param catalogue_category_properties_data: List of dictionaries containing the data for each property as would
be required for a `CatalogueCategoryPostPropertySchema` but without
any unit_id's.
any `unit_id`'s.
:returns: Tuple of lists. The first contains the expected `CatalogueCategoryPropertyIn` models and the second
the `CatalogueCategoryPostPropertySchema` schema's that should be posted in order to obtain them.
"""
Expand All @@ -98,7 +98,7 @@ def construct_properties_in_and_post_with_ids(
unit_id = None
prop_without_unit = prop.copy()

# Give units ids and remove the unit value from the prop for the post schema
# Give unit IDs and remove the unit value from the prop for the post schema
if "unit" in prop and prop["unit"]:
unit_id = str(ObjectId())
self.unit_value_id_dict[prop["unit"]] = unit_id
Expand All @@ -115,7 +115,7 @@ def mock_add_property_unit_values(
"""
Mocks database methods appropriately for when the `_add_property_unit_values` repo method will be called.
Also generates unit ids that are stored inside `unit_value_id_dict` for future lookups.
Also generates unit IDs that are stored inside `unit_value_id_dict` for future lookups.
:param units_in_data: List of dictionaries (or `None`) containing the unit data as would be required for a
`UnitIn` database model. These values will be used for any unit look ups required by
Expand Down Expand Up @@ -167,7 +167,7 @@ def mock_create(
:param catalogue_category_data: Dictionary containing the basic catalogue category data as would be required
for a `CatalogueCategoryPostSchema` but with any unit_id's replaced by the
'unit' value in its properties as the ids will be added automatically.
'unit' value in its properties as the IDs will be added automatically.
:param parent_catalogue_category_in_data: Either `None` or a dictionary containing the parent catalogue category
data as would be required for a `CatalogueCategoryIn` database model.
:param units_in_data: Either `None` or a list of dictionaries (or `None`) containing the unit data as would be
Expand All @@ -187,7 +187,7 @@ def mock_create(
),
)

# When properties are given need to mock any units and ensure the expected data inserts the unit ids as well
# When properties are given need to mock any units and ensure the expected data inserts the unit IDs as well
property_post_schemas = []
expected_properties_in = []
if "properties" in catalogue_category_data and catalogue_category_data["properties"]:
Expand Down Expand Up @@ -251,7 +251,7 @@ def check_create_success(self) -> None:
)

if self._catalogue_category_post.properties:
# To assert with property ids we must compare as dicts and use ANY here as otherwise the ObjectIds will
# To assert with property IDs we must compare as dicts and use ANY here as otherwise the ObjectIds will
# always be different
actual_catalogue_category_in = self.mock_catalogue_category_repository.create.call_args_list[0][0][0]
assert isinstance(actual_catalogue_category_in, CatalogueCategoryIn)
Expand All @@ -269,7 +269,7 @@ def check_create_success(self) -> None:
def check_create_failed_with_exception(self, message: str) -> None:
"""
Checks that a prior call to `call_create_expecting_error` worked as expected, raising an exception
with the correct message.]
with the correct message.
:param message: Expected message of the raised exception.
"""
Expand Down Expand Up @@ -484,7 +484,7 @@ def mock_update(
:param catalogue_category_id: ID of the catalogue category that will be obtained.
:param catalogue_category_update_data: Dictionary containing the basic patch data as would be required for a
`CatalogueCategoryPatchSchema` but with any unit_id's replaced by the
'unit' value in its properties as the ids will be added automatically.
'unit' value in its properties as the IDs will be added automatically.
:param stored_catalogue_category_post_data: Dictionary containing the catalogue category data for the existing
stored catalogue category as would be required for a
`CatalogueCategoryPostSchema` (i.e. no ID, code or created and modified
Expand Down Expand Up @@ -541,7 +541,7 @@ def mock_update(
),
)

# When properties are given need to mock any units and ensure the expected data inserts the unit ids as well
# When properties are given need to mock any units and ensure the expected data inserts the unit IDs as well
expected_properties_in = []
if "properties" in catalogue_category_update_data and catalogue_category_update_data["properties"]:
expected_properties_in, property_post_schemas = self.construct_properties_in_and_post_with_ids(
Expand Down Expand Up @@ -629,7 +629,7 @@ def check_update_success(self) -> None:
self._catalogue_category_patch.properties
)

# To assert with property ids we must compare as dicts and use ANY here as otherwise the ObjectIds will
# To assert with property IDs we must compare as dicts and use ANY here as otherwise the ObjectIds will
# always be different

update_call_args = self.mock_catalogue_category_repository.update.call_args_list[0][0]
Expand Down

0 comments on commit 7a0a6f2

Please sign in to comment.