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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
silkaj
Commits
2a64d214
Commit
2a64d214
authored
1 year ago
by
Moul
Browse files
Options
Downloads
Patches
Plain Diff
money transfer --file: Use click.Path() (
#469
)
parent
e364767f
No related branches found
No related tags found
1 merge request
!242
Use click.Path() #469
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
silkaj/money/transfer.py
+4
-3
4 additions, 3 deletions
silkaj/money/transfer.py
tests/unit/money/test_transfer_file.py
+3
-3
3 additions, 3 deletions
tests/unit/money/test_transfer_file.py
with
7 additions
and
6 deletions
silkaj/money/transfer.py
+
4
−
3
View file @
2a64d214
...
...
@@ -105,6 +105,7 @@ Sending to many recipients is possible:\n\
"
file_path
"
,
"
--file
"
,
"
-f
"
,
type
=
click
.
Path
(
exists
=
True
,
dir_okay
=
False
,
path_type
=
Path
),
help
=
"
File`s path containing a list of amounts in absolute or
\
relative reference and recipients` pubkeys
"
,
cls
=
tools
.
MutuallyExclusiveOption
,
...
...
@@ -126,7 +127,7 @@ def transfer_money(
amountsud
:
List
[
float
],
allsources
:
bool
,
recipients
:
List
[
str
],
file_path
:
str
,
file_path
:
Path
,
comment
:
str
,
outputbackchange
:
str
,
yes
:
bool
,
...
...
@@ -196,7 +197,7 @@ No transaction sent.",
def
parse_file_containing_amounts_recipients
(
file_path
:
str
,
file_path
:
Path
,
)
->
Tuple
[
List
[
int
],
List
[
str
]]:
"""
Parse file in a specific format
...
...
@@ -213,7 +214,7 @@ def parse_file_containing_amounts_recipients(
"""
reference
=
""
amounts
,
recipients
=
[],
[]
with
Path
(
file_path
)
.
open
(
encoding
=
"
utf-8
"
)
as
file
:
with
file_path
.
open
(
encoding
=
"
utf-8
"
)
as
file
:
for
n
,
raw_line
in
enumerate
(
file
):
line
=
shlex
.
split
(
raw_line
,
True
)
if
line
:
...
...
This diff is collapsed.
Click to expand it.
tests/unit/money/test_transfer_file.py
+
3
−
3
View file @
2a64d214
...
...
@@ -24,7 +24,7 @@ from silkaj.money.transfer import parse_file_containing_amounts_recipients
from
tests.patched.money
import
patched_get_ud_value
from
tests.patched.test_constants
import
mock_ud_value
FILE_PATH
=
"
recipients.txt
"
FILE_PATH
=
Path
(
"
recipients.txt
"
)
@pytest.mark.parametrize
(
...
...
@@ -52,7 +52,7 @@ def test_parse_file_containing_amounts_recipients(
runner
=
CliRunner
()
with
runner
.
isolated_filesystem
():
Path
(
FILE_PATH
)
.
write_text
(
file_content
,
encoding
=
"
utf-8
"
)
FILE_PATH
.
write_text
(
file_content
,
encoding
=
"
utf-8
"
)
amounts
,
recipients
=
parse_file_containing_amounts_recipients
(
FILE_PATH
)
assert
amounts
==
amounts_exp
assert
recipients
==
recipients_exp
...
...
@@ -78,7 +78,7 @@ SPEC_ERR = "No amounts or recipients specified"
def
test_parse_file_containing_amounts_recipients_errors
(
file_content
,
error
,
capsys
):
runner
=
CliRunner
()
with
runner
.
isolated_filesystem
():
Path
(
FILE_PATH
)
.
write_text
(
file_content
,
encoding
=
"
utf-8
"
)
FILE_PATH
.
write_text
(
file_content
,
encoding
=
"
utf-8
"
)
with
pytest
.
raises
(
SystemExit
):
parse_file_containing_amounts_recipients
(
FILE_PATH
)
assert
error
in
capsys
.
readouterr
().
out
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