def test_submitting_js(self, irc_msg): user = User("uzi") user.save() irc_response = irc_msg("uzi", "!js https://gitlab.com/snippets/1990806/raw") result = CommandRouter(irc_response, logger).build_response() assert result == "Thanks for the custom JS @uzi!"
def test_peace_scenario(self): fence_sitter = User("CoolCat") fence_sitter.save() clap_command = Command("clap") clap_command.allow_user(fence_sitter.name) fence_sitter.update_street_cred(10) fence_sitter.update_cool_points(10) peace_keeper = User("picakhu") damn_command = Command("damn") damn_command.allow_user(peace_keeper.name) Vote(peace_keeper.name).vote("peace") peace_keeper.update_cool_points(11) peace_keeper.update_street_cred(10) peace_keeper.update_cool_points(10) peace_keeper2 = User("beginbotsmonster") wassup_command = Command("wassup_command") wassup_command.allow_user(peace_keeper2.name) Vote(peace_keeper2.name).vote("peace") revolutionary = User("beginbot") listen_command = Command("listen") listen_command.allow_user(revolutionary.name) Vote(revolutionary.name).vote("revolution") subject = Revolution(peace_keeper.name) subject.attempt_coup("peace") assert peace_keeper.name in listen_command.users() assert peace_keeper2.name not in listen_command.users() assert revolutionary.name not in listen_command.users() assert fence_sitter.name not in clap_command.users() assert fence_sitter.street_cred() == 10 assert fence_sitter.cool_points() == 10
def test_top_8_features(self, irc_msg): user = User("bill.evans") miles = User("miles.davis") miles.save() irc_response = irc_msg("bill.evans", "!top8 miles.davis") result = CommandRouter(irc_response, logger).build_response() assert result == "@miles.davis is now in @bill.evans's Top 8!" assert user.top_eight() == ["miles.davis"]
def test_breaking_news(self): user = User("bill.evans") user.save() command = Command("damn") command.save() command.increase_cost(10) other_cmd = Command("win") other_cmd.save() subject = BreakingNewsBot()
def test_bot_survivor(self, irc_msg): user = User("uzi") user.save() User("uzibot").save() User.register_bot("uzibot", "don.cannon") irc_response = irc_msg("uzi", "!hatebot uzibot") result = CommandRouter(irc_response, logger).build_response() BotVote.count() == 1 assert result == "Thank you for your vote @uzi"
def test_do_over(self): command = Command("damn") command.save() command.increase_cost(9) user = User("future", 100) user.save() assert user.cool_points() == 100 result = ModeratorRouter("beginbotbot", "do_over", ["@future"]).route() assert command.cost() == 5 assert result == "Society now must rebuild"
def test_fence_sitters(self): revolutionary = User("beginbot") peace_keeper = User("beginbotsmonster") fence_sitter = User("picakhu") fence_sitter.save() Vote(revolutionary.name).vote("revolution") Vote(peace_keeper.name).vote("peace") assert Vote.fence_sitters() == ["picakhu"]
def test_breaking_news_initialization(self): user = User("bill.evans") user.save() command = Command("damn") command.save() command.increase_cost(10) other_cmd = Command("win") other_cmd.save() subject = BreakingNewsBot() assert subject.in_coup == False assert subject.last_breaking_time == None assert subject.initial_most_expensive["name"] == "damn" assert subject.initial_richest_user["name"] == "bill.evans"
def test_user_events(self, irc_msg): user = User("bill.evans") miles = User("miles.davis") miles.save() irc_response = irc_msg("bill.evans", "!top8 miles.davis") result = CommandRouter(irc_response, logger).build_response() last_event = UserEvent.last() assert last_event["user"] == "bill.evans" assert last_event["msg"] == "!top8 miles.davis" assert last_event[ "result"] == "@miles.davis is now in @bill.evans's Top 8!" assert last_event["command"] == "top8"
def test_giving_and_stealing_and_5_percent(self): random.seed(5) # 79 from randint(0, 100) thief = "uzi" target_sfx = "clap" victim = User("future") victim.save() busted, percentage = CaughtStealing(thief, target_sfx, "future", steal_count=2, give_count=0).call() assert percentage == 40 busted, percentage = CaughtStealing(thief, target_sfx, "future", steal_count=20, give_count=0).call() assert percentage == 0 busted, percentage = CaughtStealing(thief, target_sfx, "future", steal_count=20, give_count=40).call() assert percentage == 70 victim.update_cool_points(10) busted, percentage = CaughtStealing(thief, target_sfx, "future", steal_count=20, give_count=40).call() assert percentage == 60 victim.update_cool_points(1000) busted, percentage = CaughtStealing(thief, target_sfx, "future", steal_count=0, give_count=0).call() assert percentage == 30
def test_peace_keeper_losing_it_all(self): fence_sitter = User("CoolCat") fence_sitter.save() clap = Command("clap") clap.allow_user(fence_sitter.name) damn_command = Command("damn") peace_keeper = User("picakhu") damn_command.allow_user(peace_keeper.name) Vote(peace_keeper.name).vote("peace") assert peace_keeper.name in damn_command.users() revolutionary = User("beginbot") Vote(revolutionary.name).vote("revolution") revolutionary.update_cool_points(11) subject = Revolution(revolutionary.name) subject.attempt_coup("revolution") assert peace_keeper.name not in damn_command.users() assert revolutionary.name in damn_command.users() assert "damn" not in fence_sitter.commands() assert fence_sitter.name not in clap.users()
def test_richest_street_cred(self): User.richest_street_cred() == None watto = User("watto") watto.save() watto.update_street_cred(3) artmattdank = User("artmattdank") artmattdank.save() artmattdank.update_street_cred(9) tpain = User("tpain") tpain.save() tpain.update_street_cred(1) User.richest_street_cred()["name"] == "artmattdank"