Ejemplo n.º 1
0
    def __init__(self):
        super(ChessCmd, self).__init__()

        print("Logging in...")

        # Set up login and async
        self.loop = asyncio.new_event_loop()
        self.client = APIClient(token=Config.API_TOKEN, loop=self.loop)
        self.data_streamer = DataStreamer(self.client, self.loop)
        self.data_streamer.setDaemon(True)
        self.data_streamer.start()

        self.challenges = OrderedDict()
        self.games = OrderedDict()
        self.game = None

        # Set prompt and intro
        self.prompt = "(clichess) "
        self.intro = "Welcome! Type help or ? for a list of commands."

        # Get account
        task = asyncio.run_coroutine_threadsafe(
            self.client.account.get_my_profile(), self.loop)
        if task.result().entity.status != enums.StatusTypes.SUCCESS:
            print("There was an error fetching your account data")
            self.account = None
            self.username = None
        else:
            self.account = task.result().entity.content
            self.username = self.account['username']
    def test__01__initialize__setup_APIClient__all_parameters_set_correctly(
            self) -> None:
        TestClient.client = APIClient(token=self.token,
                                      loop=asyncio.get_event_loop())

        self.assertIsInstance(self.client._client,
                              BaseClient,
                              msg="BaseClient incorrectly set.")
        self.assertIsInstance(self.client.account,
                              Account,
                              msg="Account incorrectly set.")
        self.assertIsInstance(self.client.broadcast,
                              Broadcast,
                              msg="Broadcast incorrectly set.")
        self.assertIsInstance(self.client.challenges,
                              Challenges,
                              msg="Challenges incorrectly set.")
        self.assertIsInstance(self.client.chess_bot,
                              ChessBot,
                              msg="ChessBot incorrectly set.")
        self.assertIsInstance(self.client.games,
                              Games,
                              msg="Games incorrectly set.")
        self.assertIsInstance(self.client.messaging,
                              Messaging,
                              msg="Messaging incorrectly set.")
        self.assertIsInstance(self.client.relations,
                              Relations,
                              msg="Relations incorrectly set.")
        self.assertIsInstance(self.client.simulations,
                              Simulations,
                              msg="Simulations incorrectly set.")
        self.assertIsInstance(self.client.studies,
                              Studies,
                              msg="Studies incorrectly set.")
        self.assertIsInstance(self.client.teams,
                              Teams,
                              msg="Teams incorrectly set.")
        self.assertIsInstance(self.client.tournaments,
                              Tournaments,
                              msg="Tournaments incorrectly set.")
        self.assertIsInstance(self.client.users,
                              Users,
                              msg="Users incorrectly set.")
        self.assertIsInstance(self.client.bots,
                              Bots,
                              msg="Bots incorrectly set.")
        self.assertIsInstance(self.client.boards,
                              Boards,
                              msg="Boards incorrectly set.")
 def setUp(cls) -> None:
     cls.client = APIClient(token=cls.token)
Ejemplo n.º 4
0
async def _request_rankings(token, names):
    client = APIClient(token)
    r = await client.users.get_users_by_id(names)
    return r.entity