Question: User Class Represents a user in the social network. Contains a Profile instance representing the user's details ( username , password, screen name, email )

User Class Represents a user in the social network. Contains a Profile instance representing the user's
details (username, password, screen name, email). Manages user activities such as creating posts and
sending messages.
Attributes:
profile (Profile): User's profile.
posts (list of Post): List of posts created by the user.
messages (list of Message): List of messages sent by the user.
Methods:
__init__(self, username, password, screen_name, email): Initialize a User
instance.
create_post(self, content)-> Post: Create a new post for the user. Raise
ValueError if the content of the post is empty.
send_message(self, receiver, content)-> Message: Send a message to another
user. Raise ValueError if the receiver ID or message content is empty.
__str__(self): Return a string representation of the User.
Part 2: hw2_test.py - Testing
Testing is a crucial part of software development to ensure that your classes and methods work as expected.
For this homework, you are required to thoroughly test all the classes and methods you implement. Utilize the
unittest framework to create test cases for each class and their respective methods. Pay close attention to
edge cases and ensure that your code handles them gracefully.
Example Testing
Here's a brief example of how you might structure your test cases:
1. Profile Class Tests
Test the initialization of a Profile instance.
Modify the profile using the modify_profile method and check if the changes are reflected.
2. Activity Class Tests
Test the initialization of an Activity instance.
Check if the __str__ method returns the expected string.
3. Post Class Tests
Test the creation of posts.
4. Message Class Tests
Test the creation of messages.
5. User Class Tests
Test the initialization of a User instance.
Test a post and a message with empty content.Expecting a ValueError to be raised.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!