コード例 #1
0
 def setUp(self):
     db.Model.metadata.create_all(engine)
     self.connection = engine.connect()
     self.trans = self.connection.begin()
     self.session = Session(bind=self.connection)
     server1, _ = create_server(self.session, server_id=1234)
     server2, _ = create_server(self.session, server_id=4321)
     self.expected_output = [server1.to_dict(), server2.to_dict()]
コード例 #2
0
    def setUp(self):
        db.Model.metadata.create_all(engine)
        self.connection = engine.connect()
        self.trans = self.connection.begin()
        self.session = Session(bind=self.connection)

        self.serverid = "1234"
        create_server(self.session, server_id=self.serverid)
コード例 #3
0
    def setUp(self):
        db.Model.metadata.create_all(engine)
        self.authtoken = "Bot " + BOT_TOKEN
        self.connection = engine.connect()
        self.trans = self.connection.begin()
        self.session = Session(bind=self.connection)

        self.serverid = "1234"
        create_server(self.session, server_id=self.serverid, banned_words=[])
コード例 #4
0
 def test_serverroute_get_collection__unauthorized(self, auth_mock):
     auth_mock.return_value = False
     create_server(self.session, server_id=1234)
     create_server(self.session, server_id=4321)
     self.assertRaises(
         AuthenticationError,
         ServerRoute().get_collection,
         self.session,
         "Bot " + "asdffdsa",
     )
コード例 #5
0
    def setUp(self):
        db.Model.metadata.create_all(engine)
        self.connection = engine.connect()
        self.trans = self.connection.begin()
        self.session = Session(bind=self.connection)
        self.serverid = 1234
        new_ban = Ban(
            server_id=self.serverid,
            banned_word="asdf",
            infracted_at=(datetime.now() -
                          timedelta(days=6)).strftime("%Y-%m-%d %H:%M:%S"),
        )
        self.record = BanRecord(server_banned_word=new_ban,
                                record_seconds=60,
                                infraction_count=420)
        self.session.add(new_ban)
        self.session.add(self.record)

        self.overloaded_server_id = 11111
        ban1 = Ban(
            server_id=self.overloaded_server_id,
            banned_word="asdf",
            infracted_at=(datetime.now() -
                          timedelta(days=6)).strftime("%Y-%m-%d %H:%M:%S"),
        )
        record1 = BanRecord(server_banned_word=ban1,
                            record_seconds=60,
                            infraction_count=420)
        ban2 = Ban(
            server_id=self.overloaded_server_id,
            banned_word="fdsa",
            infracted_at=(datetime.now() -
                          timedelta(days=6)).strftime("%Y-%m-%d %H:%M:%S"),
        )
        record2 = BanRecord(server_banned_word=ban2,
                            record_seconds=60,
                            infraction_count=420)
        self.session.add(ban1)
        self.session.add(record1)
        self.session.add(ban2)
        self.session.add(record2)

        create_server(
            self.session,
            banned_words=[ban1, ban2],
            server_id=self.overloaded_server_id,
            bannings_allowed=1,
        )

        create_server(
            self.session,
            banned_words=[new_ban],
            server_id=self.serverid,
            bannings_allowed=1,
        )
コード例 #6
0
 def setUp(self):
     db.Model.metadata.create_all(engine)
     self.connection = engine.connect()
     self.trans = self.connection.begin()
     self.session = Session(bind=self.connection)
     self.serverid = 1234
     new_ban1 = Ban(
         server_id=self.serverid,
         banned_word="asdf",
         infracted_at=(datetime.now() -
                       timedelta(days=6)).strftime("%Y-%m-%d %H:%M:%S"),
     )
     new_record1 = BanRecord(server_banned_word=new_ban1)
     new_ban2 = Ban(
         server_id=self.serverid,
         banned_word="fdsa",
         infracted_at=(datetime.now() -
                       timedelta(days=6)).strftime("%Y-%m-%d %H:%M:%S"),
     )
     new_record2 = BanRecord(server_banned_word=new_ban2)
     new_ban3 = Ban(
         server_id=self.serverid,
         banned_word="test",
         infracted_at=(datetime.now() -
                       timedelta(days=6)).strftime("%Y-%m-%d %H:%M:%S"),
     )
     new_record3 = BanRecord(server_banned_word=new_ban3)
     self.session.add(new_ban1)
     self.session.add(new_ban2)
     self.session.add(new_ban3)
     self.session.add(new_record1)
     self.session.add(new_record2)
     self.session.add(new_record3)
     create_server(
         self.session,
         server_id=self.serverid,
         banned_words=[new_ban1, new_ban2, new_ban3],
     )
コード例 #7
0
 def test_serverroute_get_collection__multiple_elements(self):
     create_server(self.session, server_id=1234)
     create_server(self.session, server_id=4321)
     result = ServerRoute().get_collection(self.session, "Bot " + BOT_TOKEN)
     self.assertEqual(len(result), 2)
コード例 #8
0
 def test_serverroute_get_collection__one_element(self):
     create_server(self.session, server_id=1234)
     result = ServerRoute().get_collection(self.session, "Bot " + BOT_TOKEN)
     self.assertEqual(len(result), 1)
     self.assertEqual(result[0]["server_id"], 1234)