|
@@ -5,12 +5,29 @@ import os
|
|
from rival_regions_wrapper import LocalAuthentication, ApiWrapper
|
|
from rival_regions_wrapper import LocalAuthentication, ApiWrapper
|
|
from dotenv import load_dotenv
|
|
from dotenv import load_dotenv
|
|
import pytest
|
|
import pytest
|
|
|
|
+import telegram
|
|
|
|
|
|
|
|
|
|
load_dotenv()
|
|
load_dotenv()
|
|
|
|
|
|
-class MissingAuthenticationError(Exception):
|
|
+class MissingEnvironmentError(Exception):
|
|
- """Error for missing authentication"""
|
|
+ """Error for missing environment variable"""
|
|
|
|
+
|
|
|
|
+@pytest.fixture(scope="module")
|
|
|
|
+def telegram_channel():
|
|
|
|
+ """Set up telegram channel"""
|
|
|
|
+ return os.environ.get('TELEGRAM_CHANNEL', None)
|
|
|
|
+
|
|
|
|
+@pytest.fixture(scope="module")
|
|
|
|
+def telegram_bot():
|
|
|
|
+ """Set up telegram bot before test"""
|
|
|
|
+ telegram_key = os.environ.get('TELEGRAM_KEY', None)
|
|
|
|
+ if None in (telegram_key, telegram_channel):
|
|
|
|
+ raise MissingEnvironmentError(
|
|
|
|
+ 'Load the following variables in your user environment: '
|
|
|
|
+ 'TELEGRAM_KEY'
|
|
|
|
+ )
|
|
|
|
+ return telegram.Bot(token=telegram_key)
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
@pytest.fixture(scope="module")
|
|
@@ -20,7 +37,7 @@ def api_wrapper():
|
|
rr_password = os.environ.get('RIVAL_REGIONS_PASSWORD', None)
|
|
rr_password = os.environ.get('RIVAL_REGIONS_PASSWORD', None)
|
|
rr_login_method = os.environ.get('RIVAL_REGIONS_LOGIN_METHOD', None)
|
|
rr_login_method = os.environ.get('RIVAL_REGIONS_LOGIN_METHOD', None)
|
|
if None in (rr_username, rr_password, rr_login_method):
|
|
if None in (rr_username, rr_password, rr_login_method):
|
|
- raise MissingAuthenticationError(
|
|
+ raise MissingEnvironmentError(
|
|
'Load the following variables in your user environment: '
|
|
'Load the following variables in your user environment: '
|
|
'RIVAL_REGIONS_USERNAME, RIVAL_REGIONS_PASSWORD, RIVAL_REGIONS_LOGIN_METHOD'
|
|
'RIVAL_REGIONS_USERNAME, RIVAL_REGIONS_PASSWORD, RIVAL_REGIONS_LOGIN_METHOD'
|
|
)
|
|
)
|