Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
silkaj
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
silkaj
Commits
f0a4903a
Commit
f0a4903a
authored
3 years ago
by
Moul
Browse files
Options
Downloads
Patches
Plain Diff
[mypy] Define class for tx tests counter (
#163
)
It was wrongly done before Defining an attribute of a function
parent
7c38a863
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!214
#163: Introduce mypy
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/patched/money.py
+7
-6
7 additions, 6 deletions
tests/patched/money.py
tests/test_unit_tx.py
+6
-6
6 additions, 6 deletions
tests/test_unit_tx.py
with
13 additions
and
12 deletions
tests/patched/money.py
+
7
−
6
View file @
f0a4903a
...
...
@@ -86,10 +86,10 @@ def patched_get_sources(pubkey):
max_ud
=
0
max_tx
=
3
elif
pubkey
==
"
HcRgKh4LwbQVYuAc3xAdCynYXpKoiPE6qdxCMa8JeHat
"
:
if
patched_get_sources
.
counter
==
0
:
if
Counter
.
counter
==
0
:
max_ud
=
0
max_tx
=
53
elif
patched_get_sources
.
counter
==
1
:
elif
Counter
.
counter
==
1
:
listinput
.
append
(
InputSource
(
amount
=
100
*
MAX_INPUTS_PER_TX
,
# 100 * 46 = 4600
...
...
@@ -105,10 +105,10 @@ def patched_get_sources(pubkey):
max_ud
=
10
max_tx
=
0
elif
pubkey
==
"
9cwBBgXcSVMT74xiKYygX6FM5yTdwd3NABj1CfHbbAmp
"
:
if
patched_get_sources
.
counter
==
0
:
if
Counter
.
counter
==
0
:
max_ud
=
50
max_tx
=
20
elif
patched_get_sources
.
counter
==
1
:
elif
Counter
.
counter
==
1
:
listinput
.
append
(
InputSource
(
amount
=
mock_ud_value
*
MAX_INPUTS_PER_TX
,
# 46 UD = 46*314 = 1444
...
...
@@ -139,8 +139,9 @@ def patched_get_sources(pubkey):
balance
=
listinput_UD
(
listinput
,
balance
,
pubkey
,
max_ud
)
balance
=
listinput_TX
(
listinput
,
balance
,
max_tx
)
patched_get_sources
.
counter
+=
1
Counter
.
counter
+=
1
return
listinput
,
balance
patched_get_sources
.
counter
=
0
class
Counter
:
counter
=
0
This diff is collapsed.
Click to expand it.
tests/test_unit_tx.py
+
6
−
6
View file @
f0a4903a
...
...
@@ -28,7 +28,7 @@ from duniterpy.documents.transaction import (
from
patched.auth
import
patched_auth_method
from
patched.blockchain_tools
import
fake_block_id
,
patched_get_head_block
from
patched.money
import
patched_get_sources
,
patched_get_ud_value
from
patched.money
import
Counter
,
patched_get_sources
,
patched_get_ud_value
from
patched.test_constants
import
mock_ud_value
from
patched.tools
import
patched_get_currency_symbol
from
patched.wot
import
patched_is_member
...
...
@@ -421,8 +421,8 @@ def test_get_list_input_for_transaction(
# patched functions
monkeypatch
.
setattr
(
money
,
"
get_sources
"
,
patched_get_sources
)
# reset
patched_get_sources
counter
patched_get_sources
.
counter
=
0
# reset
Counter.
counter
Counter
.
counter
=
0
# testing error exit
if
isinstance
(
expected
,
str
):
with
pytest
.
raises
(
SystemExit
)
as
pytest_exit
:
...
...
@@ -830,7 +830,7 @@ def test_handle_intermediaries_transactions(
tx
,
"
generate_and_send_transaction
"
,
patched_generate_and_send_transaction
)
patched_get_sources
.
counter
=
0
Counter
.
counter
=
0
# testing
tx
.
handle_intermediaries_transactions
(
...
...
@@ -1025,8 +1025,8 @@ def test_send_transaction(
monkeypatch
.
setattr
(
money
,
"
get_sources
"
,
patched_get_sources
)
monkeypatch
.
setattr
(
money
,
"
get_ud_value
"
,
patched_get_ud_value
)
# reset
patched_get_sources
patched_get_sources
.
counter
=
0
# reset
Counter.counter
Counter
.
counter
=
0
# total amount for pubkey_fifi
total_amount
=
5300
# compute amounts list
...
...
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