def test_that_a_new_user_can_be_registered_successfully(self): user_dto = UserRegistrationDTO(email='*****@*****.**', username='******', password='******') user = User.register(user_dto) assert user is not None assert isinstance(user, User) assert user.id is not None try: UUID(str(user.id)) except ValueError: pytest.fail("ID is not valid UUID")
def register_user(cls, command: UserRegistrationCommand): # Convert a Command Object into a DTO, to pass into the domain user_dto = UserRegistrationDTO(email=command.email, username=command.username, password=command.password) # Call a factory method to construct a User object user = User.register(user_dto) # Persist the new User object user_repo = current_domain.repository_for(User) user_repo.add(user) # Convert the persisted user object into a resource # to be passed onto the callee user_resource = UserRepresentation().dump(user) return user_resource