def test_broke_boi_share(self): user = User("fake_user") command = Command("damn") friend = User("bizmarkie") command.allow_user(user.name) assert user.name in command.users() assert friend.name not in command.users() subject = CommandSharer( user=user.name, command=command.name, friend=friend.name, ) subject.share() assert user.name in command.users() assert friend.name not in command.users() assert command.cost() == 1
def test_invalid_command(self): user = User("fake_user") friend = User("bizmarkie") result = CommandSharer( user=user.name, command="fake_command", friend=friend.name, ).share() assert result == "@fake_user cannot share !fake_command as it's invalid"
def test_share(self): user = User("fake_user") user.update_cool_points(1) command = Command("damn") friend = User("bizmarkie") command.allow_user(user.name) assert user.name in command.users() assert friend.name not in command.users() subject = CommandSharer( user=user.name, command=command.name, friend=friend.name, ) subject.share() assert user.name in command.users() assert friend.name in command.users() assert user.cool_points() == 0 assert command.cost() == 3
def share(self): parser = CommandParser( user=self.user, command=self.command, args=self.args, allow_random_sfx=True, allow_random_user=True, ).parse() if parser.target_sfx == "random": commands = User(self.user).commands() parser.target_sfx = random.sample(commands, 1)[0] if parser.target_user == "random" or parser.target_user is None: if parser.target_sfx: parser.target_user = find_random_user( blacklisted_users=Command(parser.target_sfx).users()) if parser.target_user and parser.target_sfx: return CommandSharer(self.user, parser.target_sfx, parser.target_user).share() else: return f"Error Sharing - Command: {parser.target_sfx} | User: {parser.target_user}"