def test_create_user(): name = 'test user' reputation = 498 is_moderator = True test_user = User(name=name, reputation=reputation, is_moderator=is_moderator) assert(type(test_user) == User and test_user.name == name and test_user.reputation == reputation and test_user.is_moderator == is_moderator)
from mymodule.reddit import User, Comment ryan = User(name="ryan", reputation=5000, is_moderator=False) windsurfing_topic = ryan.post_topic(title="windsurfing is cool", body="who wants to go windsurfing?") troll_comment = ryan.post_comment(topic=windsurfing_topic, body="windsurfing is lame") nice_comment = Comment(topic=windsurfing_topic, body="windsurfing is the best", down_votes=50, user=ryan) print(nice_comment.up_votes) ryan.up_vote(nice_comment) ryan.up_vote(windsurfing_topic) susan = User(name="susan", reputation=5000, is_moderator=False) go_windsurfing_comment = susan.post_comment(topic=windsurfing_topic, body="wanna go windsurfing?") ryan.up_vote(go_windsurfing_comment) print(nice_comment.up_votes)
def test_user(): test_user = User(name='test user', reputation=5000, is_moderator=False) return test_user
from mymodule.reddit import User, Comment ryan = User(name='ryan', karma='5000', is_moderator=False) susan = User(name='Susan', karma='3000', is_moderator=False) windsurfing_topic = ryan.post_topic(title='windsurfing is cool', body='...') troll_comment = ryan.post_comment(topic=windsurfing_topic, body='windsurfing sux dix') nice_comment = Comment(topic=windsurfing_topic, body='<3', down_votes=0, up_votes=10000, user=ryan) print(nice_comment.up_votes) ryan.up_vote(nice_comment) go_windsurfing_comment = susan.post_comment(topic=windsurfing_topic, body="wanna go surfing with me?") ryan.up_vote(go_windsurfing_comment) print(go_windsurfing_comment.up_votes) print([i.title for i in ryan.topics], [i.body for i in susan.comments])
from mymodule.reddit import User, Comment ryan = User(name='ryan', reputation=5000, is_moderator=False) windsurfing_topic = ryan.post_topic(title='windsurfing is cool', body='who wants to go windsurfing?') troll_comment = ryan.post_comment(topic=windsurfing_topic, body='windsurfing is lame') nice_comment = Comment(topic=windsurfing_topic, body='windsurfing is the best', down_votes=50, user=ryan) print(nice_comment.up_votes) ryan.up_vote(nice_comment) ryan.up_vote(windsurfing_topic) susan = User(name='susan', reputation=5000, is_moderator=False) go_windsurfing_comment = susan.post_comment(topic=windsurfing_topic, body='wanna go windsurfing?') ryan.up_vote(go_windsurfing_comment) print(nice_comment.up_votes)