Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JosXa committed Jun 2, 2022
1 parent da58e3d commit ea8faad
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
5 changes: 5 additions & 0 deletions examples/automation/dinoparkbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from typing import Optional
from typing import Tuple

from decouple import config

from pyrogram import Client
from pyrogram import filters as f

Expand All @@ -27,6 +29,9 @@
def create_client(session_name: str) -> Client:
return Client(
name=session_name,
api_id=config("API_ID"),
api_hash=config("API_HASH"),
session_string=config("SESSION_STRING"),
workdir=str(examples_dir),
)

Expand Down
14 changes: 7 additions & 7 deletions examples/automation/idletown.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import traceback
from pathlib import Path
from typing import Dict
from decouple import config

from pyrogram import Client
from pyrogram import filters as f
Expand All @@ -25,13 +26,13 @@

# This example uses the configuration of `config.ini` (see examples/README)
def create_client(session_name: str = SESSION_NAME) -> Client:
client = Client(
session_name=session_name,
workdir=examples_dir,
config_file=examples_dir / "config.ini",
return Client(
name=session_name,
api_id=config("API_ID"),
api_hash=config("API_HASH"),
session_string=config("SESSION_STRING"),
workdir=str(examples_dir),
)
client.load_config()
return client


def create_game_controller(client: Client = None) -> BotController:
Expand Down Expand Up @@ -76,7 +77,6 @@ async def click_button(menu: Dict[str, str], key: str) -> Dict[str, str]:

# Get World Exp if possible
if "worldexp" in main_menu:

worldexp_menu = await click_button(main_menu, "worldexp")
confirm_menu = await click_button(worldexp_menu, "claimx1")
await click_button(confirm_menu, "yes")
Expand Down
1 change: 1 addition & 0 deletions examples/readme_example/readmeexample.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def create_client(session_name: str = SESSION_NAME) -> Client:
name=session_name,
api_id=config("API_ID"),
api_hash=config("API_HASH"),
session_string=config("SESSION_STRING"),
workdir=str(examples_dir),
)

Expand Down
3 changes: 2 additions & 1 deletion scripts/create_session_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

async def create_session_string(test_mode: bool = False):
memory_client = Client(
session_name=":memory:",
name=":memory:",
in_memory=True,
api_id=config("API_ID"),
api_hash=config("API_HASH"),
test_mode=test_mode,
Expand Down
15 changes: 8 additions & 7 deletions tests/integration/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
pytestmark = pytest.mark.asyncio


async def test_dinopark_example(session_name):
# Late import so that the autouse fixtures run first
from examples.automation import dinoparkbot

client = dinoparkbot.create_client(session_name)
game = dinoparkbot.create_game_controller(client)
await game.perform_full_run()
# TODO: Bot is offline. Does anyone have a nice alternative to automate?
# async def test_dinopark_example(session_name):
# # Late import so that the autouse fixtures run first
# from examples.automation import dinoparkbot
#
# client = dinoparkbot.create_client(session_name)
# game = dinoparkbot.create_game_controller(client)
# await game.perform_full_run()


async def test_idletown_example(session_name):
Expand Down

0 comments on commit ea8faad

Please sign in to comment.