Skip to content

Commit

Permalink
chore: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jbarreau committed Nov 29, 2024
1 parent 510c5ec commit 5312481
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,20 @@ def test_rename_collection_should_throw_if_try_to_rename_a_collection_which_is_t
def test_rename_collection_should_rename_a_collection_owning_a_polymorphic_many_to_one(self):
self.decorated_datasource.rename_collections({"Rating": "Whatever"})
self.assertIsInstance(self.decorated_datasource.get_collection("Whatever"), RenameCollectionCollectionDecorator)

def test_rename_collection_can_rename_all_in_once_with_a_function(self):
to_not_rename = ["Bar", "Restaurant"]
self.decorated_datasource.rename_collections(lambda name: f"new_{name}" if name not in to_not_rename else None)

for collection in self.decorated_datasource.collections:
if collection.name not in to_not_rename:
self.assertTrue(collection.name.startswith("new_"))
else:
self.assertFalse(collection.name.startswith("new_"))

def test_rename_collection_should_not_rename_collection_when_none_is_returned(self):
self.decorated_datasource.rename_collections(lambda name: f"new_{name}" if name == "Book" else None)

for collection in self.decorated_datasource.collections:
if collection.name.startswith("new_"):
self.assertEqual(collection.name, "new_Book")

0 comments on commit 5312481

Please sign in to comment.