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:
initself username, password, screenname, email: Initialize a User
instance.
createpostself content Post: Create a new post for the user. Raise
ValueError if the content of the post is empty.
sendmessageself receiver, content Message: Send a message to another
user. Raise ValueError if the receiver ID or message content is empty.
strself: Return a string representation of the User.
Part : hwtest.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:
Profile Class Tests
Test the initialization of a Profile instance.
Modify the profile using the modifyprofile method and check if the changes are reflected.
Activity Class Tests
Test the initialization of an Activity instance.
Check if the str method returns the expected string.
Post Class Tests
Test the creation of posts.
Message Class Tests
Test the creation of messages.
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
