def testMinigameLB(self) -> None: """Tests the minigame leaderboard functionality """ assert len(self.module.minigamePoints.keys()) == 0 message = dummies.DummyMessage( arguments=["-addpoints", "testuser"], sender=dummies.DummyUser(isAdmin=True), room=self.connection.getRoom("testroom") ) self.module.addPoints(message) assert self.module.minigamePoints["testroom"]["testuser"] == 1 message = dummies.DummyMessage( arguments=["-addpoints", "testuser", "-2"], sender=dummies.DummyUser(isAdmin=True), room=self.connection.getRoom("testroom") ) self.module.addPoints(message) assert self.module.minigamePoints["testroom"]["testuser"] == -1 message = dummies.DummyMessage( arguments=["-removeplayer", "testuser"], sender=dummies.DummyUser(isAdmin=True), room=self.connection.getRoom("testroom") ) self.module.removePlayers(message) assert "testuser" not in self.module.minigamePoints["testroom"]
def testCountSnippets(self) -> None: """Tests the snippet-counting command """ message = dummies.DummyMessage(arguments=["-countfacts", "testroom"]) self.module.countSnippets(message) assert message.response and "0" in message.response message = dummies.DummyMessage(arguments=["-counttopics", "testroom"]) self.module.countSnippets(message) assert message.response and "0" in message.response message = dummies.DummyMessage(arguments=["-countquotes", "testroom"]) self.module.countSnippets(message) assert message.response and "0" in message.response
def testEval(self) -> None: """Tests the eval command """ message = dummies.DummyMessage(arguments=["-eval", "(2 + 2**2) / 2"], sender=dummies.DummyUser( isAdmin=True, userid='annika')) self.module.eval(message) assert message.response and message.response.strip("!code ").strip( '\n').strip('`') == f"{(2 + 2**2) / 2}"
def testJoinphrase(self) -> None: """Tests adding and removing joinphrases through commands """ # Remove any previous `testroom2` data left in data.json for user in list(self.connection.getRoom("testroom2").joinphrases.keys()): self.connection.getRoom("testroom2").removeJoinphrase(user) assert len(self.connection.getRoom("testroom2").joinphrases) == 0 message = dummies.DummyMessage( arguments=["-addjp", "testroom2", "Test User", "Join pHRase &&||"], sender=dummies.DummyUser(isAdmin=True), connection=self.connection ) # Adding in PMs self.module.addJP(message) assert len(self.connection.getRoom("testroom2").joinphrases) == 1 assert self.connection.getRoom("testroom2").joinphrases["testuser"] == "Join pHRase &&||" message = dummies.DummyMessage( arguments=["-removejp", "testroom2", "Test User"], sender=dummies.DummyUser(isAdmin=True), connection=self.connection ) # Removing in PMs self.module.deleteJP(message) assert len(self.connection.getRoom("testroom2").joinphrases) == 0 message = dummies.DummyMessage( arguments=["-addjp", "Test User", "Join pHRase &&||"], sender=dummies.DummyUser(isAdmin=True), room=self.connection.getRoom("testroom2") ) # Adding in a room self.module.addJP(message) assert len(self.connection.getRoom("testroom2").joinphrases) == 1 assert self.connection.getRoom("testroom2").joinphrases["testuser"] == "Join pHRase &&||" message = dummies.DummyMessage( arguments=["-removejp", "Test User"], sender=dummies.DummyUser(isAdmin=True), room=self.connection.getRoom("testroom2") ) # Removing in a room self.module.deleteJP(message) assert len(self.connection.getRoom("testroom2").joinphrases) == 0
def testSuperhero(self) -> None: """Tests the superhero command """ # This might have issues since it relies on the API responses not changing, but there's not a great way to test this. message = dummies.DummyMessage(arguments=["-superhero", "t H\\ orå"]) self.module.superhero(message) start = '!show https://' assert message.response and message.response[:len(start)] == start assert message.HTMLResponse and "Thor" in message.HTMLResponse assert "Loki (step-brother)" in message.HTMLResponse assert "Asgardian" in message.HTMLResponse assert "King of Asgard" in message.HTMLResponse
def testReversio(self) -> None: """Tests the reversio commands """ self.module.reversioWords = {"testroom": []} assert self.module.reversioWords["testroom"] == [] message = dummies.DummyMessage( arguments=["-addreversioword", "testroom", "Test Word"], sender=dummies.DummyUser(isAdmin=True)) self.module.addReversioWord(message) assert len(self.module.reversioWords["testroom"]) == 1 assert self.module.reversioWords["testroom"][0].lower().strip( ) == "test word" message = dummies.DummyMessage(arguments=["-reverse", "testroom"]) self.module.reverse(message) assert message.response == "/wall drow tset" message = dummies.DummyMessage( arguments=["-rmreversioword", "testroom", "Test Word"], sender=dummies.DummyUser(isAdmin=True)) self.module.removeReversioWord(message) assert len(self.module.reversioWords["testroom"]) == 0