Implement the functionality for a simple user management system in the /app/ directory. The system should provide the following features:
User Registration: Create a class UserManager that allows for user registration. Each user must have:
A unique username (string)
An email address (string)
A password (string)
The registration method should ensure:
The username must be unique and cannot already exist in the system.
The email must be in a valid format.
The password must be at least 8 characters long.
User Retrieval: Implement a method in the UserManager class to retrieve user's details by their username.
Validation: Implement a method to validate user credentials during login, checking both username and password.
Error Handling: If any of the requirements for registration or login are not met, your implementation should raise appropriate exceptions with clear error messages.
Ensure that all functionality is encapsulated within the UserManager class, and write unit tests for the above methods to confirm they operate correctly. The tests should cover all edge cases, including duplicate username registration, invalid email formats, and incorrect login credentials.
Your implementation should be placed in the /app/ directory and the tests should clearly reflect the functionality described above.