Ejemplo n.º 1
0
 def setUp(self):
     LevelRoleService.clear_table()
     LevelRoleService.add_level_role(
         LevelRole(guildId=1234, level=1, roleId=123))
     LevelRoleService.add_level_role(
         LevelRole(guildId=1234, level=5, roleId=1234))
     LevelRoleService.add_level_role(
         LevelRole(guildId=4444, level=10, roleId=12345))
Ejemplo n.º 2
0
    def test_get_level_roles_dict_by_guild_id(self):
        print('Testing get_level_roles_dict_by_guild_id()')

        roleDict = LevelRoleService.get_level_roles_dict_by_guild_id(
            guildId=1234)
        checkDict = {
            1: LevelRole(guildId=1234, level=1, roleId=123),
            5: LevelRole(guildId=1234, level=5, roleId=1234)
        }

        self._check_data(checking_obj=roleDict[1], control_obj=checkDict[1])
        self._check_data(checking_obj=roleDict[5], control_obj=checkDict[5])
        print('Successful\n')
Ejemplo n.º 3
0
    def test_add_and_get_all(self):
        print('Testing add_level_role() and get_all_level_roles()')
        LevelRoleService.add_level_role(
            LevelRole(guildId=1234, level=29, roleId=100))

        roleList = LevelRoleService.get_all_level_roles()
        checkList = [
            LevelRole(guildId=1234, level=1, roleId=123),
            LevelRole(guildId=1234, level=5, roleId=1234),
            LevelRole(guildId=4444, level=10, roleId=12345),
            LevelRole(guildId=1234, level=29, roleId=100)
        ]

        for i in range(len(roleList)):
            self._check_data(checking_obj=roleList[i],
                             control_obj=checkList[i])
        print('Successful\n')
Ejemplo n.º 4
0
    def test_update_level_role(self):
        print('Testing update_level_role()')
        newRole = LevelRole(guildId=4444, level=10, roleId=111)
        LevelRoleService.update_level_role(levelRole=newRole)

        rolesDict = LevelRoleService.get_level_roles_dict_by_guild_id(
            guildId=4444)

        self._check_data(checking_obj=rolesDict[10], control_obj=newRole)
        print('Successful\n')
Ejemplo n.º 5
0
    def test_delete_level_role(self):
        print('Testing delete_level_role()')
        newRole = LevelRole(guildId=1234, level=1, roleId=123)
        LevelRoleService.delete_level_role(levelRole=newRole)

        answer = LevelRoleService.get_level_roles_count_by_guild_id(
            guildId=1234)

        self.assertEqual(
            1, answer, 'rows_count should be {0} actual {1}'.format(1, answer))
        print('Successful\n')
    def test_get_guild_boot_setup(self):
        print('Testing get_guild_boot_setup()')
        LevelRoleService.add_level_role(
            levelRole=LevelRole(guildId=1234, level=1, roleId=10))
        LevelRoleService.add_level_role(
            levelRole=LevelRole(guildId=1234, level=5, roleId=20))
        LevelRoleService.add_level_role(
            levelRole=LevelRole(guildId=1234, level=9, roleId=30))
        LevelRoleService.add_level_role(
            levelRole=LevelRole(guildId=4444, level=1, roleId=40))
        LevelRoleService.add_level_role(
            levelRole=LevelRole(guildId=4444, level=5, roleId=50))

        guildDict = GuildService.get_guild_boot_setup()

        self.assertEqual(
            3, len(guildDict[1234].levelsMap),
            'rows_count should be {0} actual {1}'.format(
                3, len(guildDict[1234].levelsMap)))
        self.assertEqual(
            2, len(guildDict[4444].levelsMap),
            'rows_count should be {0} actual {1}'.format(
                2, len(guildDict[4444].levelsMap)))
        print('Successful\n')
Ejemplo n.º 7
0
def get_level_roles_dict_by_guild_id(guildId: int):
    rows = Repos.get_level_roles_dict_by_guild_id(guildId=guildId)
    return {row[1]: LevelRole(guildId=row[0], level=row[1], roleId=row[2]) for row in rows}
Ejemplo n.º 8
0
def get_all_level_roles():
    rows = Repos.get_all_level_roles()
    return [LevelRole(guildId=row[0], level=row[1], roleId=row[2]) for row in rows]