def test_child_garden_system_id_update(self, child_garden, child_system_v1_diff_id): """If the systems of a child garden are updated such that the names, namespaces and versions remain constant, but the IDs are different, the original systms are removed and replaced with the new systems when the garden is saved.""" orig_system_ids = set( map(lambda x: str(getattr(x, "id")), child_garden.systems) # noqa: B009 ) new_system_id = str(child_system_v1_diff_id.id) assert new_system_id not in orig_system_ids child_garden.systems = [child_system_v1_diff_id] child_garden.deep_save() db_garden = Garden.objects().first() new_system_ids = set( map(lambda x: str(getattr(x, "id")), db_garden.systems) # noqa: B009 ) assert new_system_id in new_system_ids assert orig_system_ids.intersection(new_system_ids) == set()
def test_child_garden_system_attrib_update(self, child_garden, child_system_v2): """If the systems of a child garden are updated such that their names, namespaces, or versions are changed, the original systems are removed and replaced with the new systems when the garden is saved.""" orig_system_ids = set( map(lambda x: str(getattr(x, "id")), child_garden.systems) # noqa: B009 ) orig_system_versions = set( map( lambda x: str(getattr(x, "version")), child_garden.systems # noqa: B009 )) assert (self.v1_str in orig_system_versions and self.v2_str not in orig_system_versions) child_garden.systems = [child_system_v2] child_garden.deep_save() # we check that the garden written to the DB has the correct systems db_garden = Garden.objects().first() new_system_ids = set( map(lambda x: str(getattr(x, "id")), db_garden.systems) # noqa: B009 ) new_system_versions = set( map(lambda x: str(getattr(x, "version")), db_garden.systems) # noqa: B009 ) assert (self.v1_str not in new_system_versions and self.v2_str in new_system_versions) assert new_system_ids.intersection(orig_system_ids) == set()