So I've got "Services" in my system that handle creating, updating etc of the data.
For example state_service.create() would create a new state in the database. This state belongs to a group.
The problem is, the group needs to be created first, before the state can be added.
Now, I can always call group_service.create() first, then create the state after, like this:
def test_state_service_create(self): self.group_service.create() state_id = self.state_service.create() self.assertTrue(state_id)
however I am not sure if this is bad practice, since this now relies on group_service.create() working correctly. The alternative is to manually create the group myself, such as:
def test_state_service_create(self): self.db.groups.insert_one(self.mock_groups) state_id = self.state_service.create() self.assertTrue(state_id)
But this would just mean that I'd need to update the mock data should the schema change.
Which is the proper practice here, or is it something else entirely?