Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wax
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
wax
Commits
92e7ffd0
Commit
92e7ffd0
authored
1 month ago
by
Michał Kudela
Browse files
Options
Downloads
Patches
Plain Diff
Add conftest for wax-base-tests and update existing tests
parent
312e4a5c
No related branches found
No related tags found
2 merge requests
!262
Duplicate typeScript tests to python
,
!230
Implementation of the python wax interface
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/tests/base_api/conftest.py
+86
-0
86 additions, 0 deletions
python/tests/base_api/conftest.py
python/tests/base_api/test_operation_get_impacted_accounts.py
+3
-5
3 additions, 5 deletions
...on/tests/base_api/test_operation_get_impacted_accounts.py
with
89 additions
and
5 deletions
python/tests/base_api/conftest.py
0 → 100644
+
86
−
0
View file @
92e7ffd0
from
__future__
import
annotations
import
re
import
shutil
from
pathlib
import
Path
from
typing
import
TYPE_CHECKING
,
AsyncGenerator
,
Generator
import
pytest
from
beekeepy
import
AsyncBeekeeper
,
Settings
from
wax
import
ITransaction
,
IWaxBaseInterface
,
create_wax_foundation
if
TYPE_CHECKING
:
from
beekeepy
import
AsyncUnlockedWallet
@pytest.fixture
(
autouse
=
True
)
def
beekeeper_output_dir
(
request
:
pytest
.
FixtureRequest
)
->
Generator
[
Path
,
None
,
None
]:
function_dir
=
__get_directory_for_function
(
request
)
if
function_dir
.
exists
():
shutil
.
rmtree
(
function_dir
)
function_dir
.
mkdir
(
exist_ok
=
True
)
yield
function_dir
if
not
any
(
function_dir
.
iterdir
()):
shutil
.
rmtree
(
function_dir
)
@pytest.fixture
async
def
beekeeper
(
beekeeper_output_dir
:
Path
)
->
AsyncGenerator
[
AsyncBeekeeper
,
None
]:
async
with
await
AsyncBeekeeper
.
factory
(
settings
=
Settings
(
working_directory
=
beekeeper_output_dir
))
as
beekeeper
:
yield
beekeeper
@pytest.fixture
async
def
wallet
(
beekeeper
:
AsyncBeekeeper
)
->
AsyncUnlockedWallet
:
session
=
await
beekeeper
.
create_session
()
await
session
.
create_wallet
(
name
=
"
beekeeper_wallet_name
"
,
password
=
"
beekeeper_wallet_password
"
)
# noqa: S106
return
await
(
await
session
.
open_wallet
(
name
=
"
beekeeper_wallet_name
"
)).
unlock
(
"
beekeeper_wallet_password
"
)
@pytest.fixture
def
wax
()
->
IWaxBaseInterface
:
return
create_wax_foundation
()
@pytest.fixture
def
tapos
()
->
str
:
return
"
04c507a8c7fe5be96be64ce7c86855e1806cbde3
"
@pytest.fixture
def
transaction
(
wax
:
IWaxBaseInterface
,
tapos
:
str
)
->
ITransaction
:
return
wax
.
create_transaction_with_tapos
(
tapos
)
def
__convert_test_name_to_directory_name
(
test_name
:
str
)
->
str
:
def
__truncate_name
(
name
:
str
,
max_length
:
int
=
100
)
->
str
:
if
len
(
name
)
>
max_length
:
return
name
[:
max_length
]
+
"
_truncated
"
return
name
directory_name
=
[]
parametrized_test_match
=
re
.
match
(
r
"
([\w_]+)\[(.*)\]
"
,
test_name
)
if
parametrized_test_match
:
test_name
=
f
"
{
parametrized_test_match
[
1
]
}
_with_parameters_
{
parametrized_test_match
[
2
]
}
"
for
character
in
test_name
:
character_to_append
=
character
if
not
(
character_to_append
.
isalnum
()
or
character_to_append
in
"
-_
"
):
character_to_append
=
f
"
-0x
{
ord
(
character
)
:
X
}
-
"
directory_name
.
append
(
character_to_append
)
return
__truncate_name
(
""
.
join
(
directory_name
))
def
__get_directory_for_function
(
request
:
pytest
.
FixtureRequest
)
->
Path
:
assert
request
.
scope
==
"
function
"
directory_name
=
__convert_test_name_to_directory_name
(
request
.
node
.
name
)
return
Path
(
request
.
node
.
fspath
.
dirpath
()
/
"
generated_during_
"
+
directory_name
)
This diff is collapsed.
Click to expand it.
python/tests/base_api/test_operation_get_impacted_accounts.py
+
3
−
5
View file @
92e7ffd0
...
...
@@ -5,10 +5,11 @@ from typing import TYPE_CHECKING, Final
import
pytest
from
wax
import
create_wax_foundation
from
wax.proto
import
authority_pb2
,
operation_pb2
,
recover_account_pb2
from
wax.proto.vote_pb2
import
vote
if
TYPE_CHECKING
:
from
wax.interfaces
import
IWaxBaseInterface
from
wax.models.operations
import
Operation
...
...
@@ -43,10 +44,7 @@ EXPECTED_AMOUNT_OF_IMPACTED_ACCOUNTS: Final[int] = 1
@pytest.mark.parametrize
(
"
operation
"
,
[
PROTO_OPERATION
,
API_OPERATION_DICT
,
API_OPERATION_JSON
])
def
test_operation_get_impacted_accounts
(
operation
:
Operation
)
->
None
:
# ARRANGE
wax
=
create_wax_foundation
()
def
test_operation_get_impacted_accounts
(
wax
:
IWaxBaseInterface
,
operation
:
Operation
)
->
None
:
# ACT
result
=
wax
.
get_operation_impacted_accounts
(
operation
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment