Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion checkers/post_v1_account_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class PostV1AccountLogin:
@classmethod
def check_response_values(
cls,
login
login,
response
):
today = datetime.now().strftime('%Y-%m-%d')
Expand Down
7 changes: 7 additions & 0 deletions config/prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
service:
dm_api_account: "http://185.185.143.231:5051"
mailhog: "http://185.185.143.231:5025"

user:
login: "katya_test"
password: "123456"
7 changes: 7 additions & 0 deletions config/stg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
service:
dm_api_account: "http://185.185.143.231:5051"
mailhog: "http://185.185.143.231:5025"

user:
login: "katya_test"
password: "123456"
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ certifi==2026.1.4
charset-normalizer==3.4.4
colorama==0.4.6
curlify==3.0.0
distconfig3==1.0.1
idna==3.11
iniconfig==2.3.0
packaging==26.0
Expand All @@ -13,9 +14,13 @@ pydantic_core==2.41.5
Pygments==2.19.2
PyHamcrest==2.1.0
pytest==9.0.2
PyYAML==6.0.3
requests==2.32.5
retrying==1.4.2
structlog==25.5.0
toml==0.10.2
typing-inspection==0.4.2
typing_extensions==4.15.0
urllib3==2.6.3
vyper-config==1.2.1
watchdog==6.0.0
42 changes: 36 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
from services.dm_api_account import DMApiAccount
from restclient.configuration import Configuration as MailhogConfiguration
from restclient.configuration import Configuration as DmApiConfiguration
from vyper import (
vyper,
v,
)
import structlog
from pathlib import Path

structlog.configure(
processors=[
Expand All @@ -17,15 +22,40 @@
)
]
)

options = (
'service.dm_api_account',
'service.mailhog',
'user.login',
'user.password',
)

@pytest.fixture(scope="session", autouse=True)
def set_config(request):
config = Path(__file__).joinpath("../../").joinpath("config")
config_name = request.config.getoption("--env")
v.set_config_name(config_name)
v.add_config_path(config)
v.read_in_config()
for option in options:
v.set(f"{option}", request.config.getoption(f"--{option}"))

def pytest_addoption(parser):
parser.addoption("--env", action="store", default="stg", help="run stg")

for option in options:
parser.addoption(f"--{option}", action="store", default=None)


@pytest.fixture(scope="function")
def mailhog_api():
mailhog_configuration = MailhogConfiguration(host='http://185.185.143.231:5025')
mailhog_configuration = MailhogConfiguration(host=v.get("service.mailhog"), disable_log=False)
mailhog_client = MailHogApi(configuration=mailhog_configuration)
return mailhog_client

@pytest.fixture(scope="function")
def account_api():
dm_api_configuration = DmApiConfiguration(host='http://185.185.143.231:5051', disable_log=False)
dm_api_configuration = DmApiConfiguration(host=v.get("service.dm_api_account"), disable_log=False)
account = DMApiAccount(configuration=dm_api_configuration)
return account

Expand All @@ -36,12 +66,12 @@ def account_helper(account_api, mailhog_api):

@pytest.fixture(scope="function")
def auth_account_helper(mailhog_api):
dm_api_configuration = DmApiConfiguration(host='http://185.185.143.231:5051', disable_log=False)
dm_api_configuration = DmApiConfiguration(host=v.get("service.dm_api_account"), disable_log=False)
account = DMApiAccount(configuration=dm_api_configuration)
account_helper = AccountHelper(dm_account_api=account, mailhog=mailhog_api)
account_helper.auth_client(
login = "katya_test",
password = "123456"
login = v.get("user.login"),
password = v.get("user.password")
)
return account_helper

Expand All @@ -51,7 +81,7 @@ def prepare_user():
data = now.strftime("%d_%m_%Y_%H_%M_%S")
login = f'katya_test{data}'
email = f'{login}@mail.ru'
password = '123456'
password = v.get("user.password")
User = namedtuple("user", ["login", "password", "email"])
user = User(login=login, password=password, email=email)
return user
2 changes: 1 addition & 1 deletion tests/functional/get_v1_account/test_get_v1_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_get_v1_account_auth(auth_account_helper):
assert_that(response.resource.online).is_instance_of(datetime)
assert_that(response.resource.roles).contains(UserRole.GUEST, UserRole.PLAYER)

GetV1Account.check_response_values(response)
GetV1Account.check_response_values(response=response, login="katya_test")

def test_get_v1_account_no_auth(account_helper):
with check_status_code_http(401, "User must be authenticated"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_post_v1_account_login(prepare_user, account_helper):

account_helper.register_new_user(login=login, password=password, email=email)
response = account_helper.user_login(login=login, password=password, validate_response=True)
PostV1AccountLogin.check_response_values(response)
PostV1AccountLogin.check_response_values(response=response, login=login)



Expand Down