-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REM-1296: Get list of the batches #12
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #12 +/- ##
===========================================
+ Coverage 97.31% 97.43% +0.11%
===========================================
Files 55 55
Lines 894 973 +79
===========================================
+ Hits 870 948 +78
- Misses 24 25 +1
Continue to review full report at Codecov.
|
README.md
Outdated
@@ -76,6 +76,43 @@ $ remme account get-balance \ | |||
368440.0 | |||
``` | |||
|
|||
### Blockchain info |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you operate some libraries where you see blockchain info
, it is ok.
When you provide the independent layer of user experience, you should care about users in own way.
I mean, In the library it is blockchain information, but CLI user expects section batch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/blockchain_info/cli.py
Outdated
Get batch by id. | ||
""" | ||
if re.match(pattern=BATCH_ID_REGEXP, string=id) is None: | ||
click.echo('The following id `{batch_id}` is not valid.'.format(batch_id=id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following id
> The following batch id
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/blockchain_info/cli.py
Outdated
@batch_commands.command('get-single') | ||
def get_single(id, node_url): | ||
""" | ||
Get batch by id. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id
> identifier
in all user/business-oriented texts: documentation of products, projects, code documentation, functions names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/blockchain_info/help.py
Outdated
|
||
GET_BATCH_HEAD_ARGUMENT_HELP_MESSAGE = 'Get batch by head.' | ||
|
||
GET_BATCH_REVERSE_ARGUMENT_HELP_MESSAGE = 'Reverse result.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove blank lines between the same entities.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/blockchain_info/interfaces.py
Outdated
""" | ||
|
||
|
||
class BlockchainInfoInterface: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same I said in the first message. BlockchainInfo
> Batch
. Please, fix this anywhere: folder names, files names, classes, variables, etc. except obviously library usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/blockchain_info/interfaces.py
Outdated
|
||
async def get_batches(self, query=None): | ||
""" | ||
Get all batches from REMChain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REMChain
> blockchain
.
cli/blockchain_info/interfaces.py
Outdated
""" | ||
Get all batches from REMChain. | ||
|
||
Args: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Args
> Arguments
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/blockchain_info/interfaces.py
Outdated
|
||
Args: | ||
query (dict, optional): dictionary with specific parameters | ||
Returns: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blank line between documentation sections: arguments, returns, exceptions, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/blockchain_info/service.py
Outdated
""" | ||
Get batch by id. | ||
""" | ||
# TODO: change to get_batch_by_id after corresponding changes in remme-python-library |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move TODO
section of messy comments to the issues, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/constants.py
Outdated
@@ -3,6 +3,8 @@ | |||
""" | |||
ADDRESS_REGEXP = '[0-9a-f]{70}' | |||
|
|||
BATCH_ID_REGEXP = '[0-9a-f]{128}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove blank line between the same entities.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
e40fb89
to
44c3680
Compare
cli/batch/cli.py
Outdated
@batch_commands.command('get-list') | ||
def get_list(id, start, limit, head, reverse, node_url): | ||
""" | ||
List batches. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List batches
> Get a list of batches
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/cli.py
Outdated
if batch_id is not None and re.match(pattern=BATCH_ID_REGEXP, string=batch_id) is None: | ||
click.echo('The following batch id `{batch_id}` is not valid.'.format(batch_id=id)) | ||
sys.exit(FAILED_EXIT_FROM_COMMAND) | ||
if limit is not None and limit < 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blank line between 50 and 51 code lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/cli.py
Outdated
if limit is not None and limit < 0: | ||
click.echo("Limit can't be negative.") | ||
sys.exit(FAILED_EXIT_FROM_COMMAND) | ||
if reverse is not None and reverse not in ("true", "false"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blank line between 54 and 53.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use also single quotes if possible here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/help.py
Outdated
GET_BATCH_START_ARGUMENT_HELP_MESSAGE = 'Get batch by start.' | ||
GET_BATCH_LIMIT_ARGUMENT_HELP_MESSAGE = 'Limit amount of batches.' | ||
GET_BATCH_HEAD_ARGUMENT_HELP_MESSAGE = 'Get batch by head.' | ||
GET_BATCH_REVERSE_ARGUMENT_HELP_MESSAGE = 'Reverse result.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same as here, you should describe the argument, not command. https://github.com/Remmeauth/remme-core-cli/pull/7/files#r276177736
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/interfaces.py
Outdated
|
||
async def get_list(self, query=None): | ||
""" | ||
Get all batches from REMChain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all
> a list of
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
README.md
Outdated
@@ -104,6 +104,29 @@ $ remme account get-balance \ | |||
368440.0 | |||
``` | |||
|
|||
### Batches |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add anchor Batches
to the tree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
README.md
Outdated
@@ -104,6 +104,29 @@ $ remme account get-balance \ | |||
368440.0 | |||
``` | |||
|
|||
### Batches | |||
|
|||
Get batches — ``remme batch get-list``: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get batches — ``remme batch get-list``: | |
Get list of batches — ``remme batch get-list``: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
README.md
Outdated
|
||
| Arguments | Type | Required | Description | | ||
| :-------: | :----: | :-------: | --------------------------------------------------- | | ||
| id | String | No | Get batch by its identifier. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| id | String | No | Get batch by its identifier. | | |
| id | String | No | Identifier to get a list of batches by. | |
Check all description by this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/cli.py
Outdated
""" | ||
Provide implementation of the command line interface's batch commands. | ||
""" | ||
import sys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make alphabetical order of packages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added to technical debt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/cli.py
Outdated
@click.option('--reverse', type=str, required=False, help=GET_BATCH_REVERSE_ARGUMENT_HELP_MESSAGE) | ||
@click.option('--node-url', type=str, help=NODE_URL_ARGUMENT_HELP_MESSAGE) | ||
@batch_commands.command('get-list') | ||
def get_list(id, start, limit, head, reverse, node_url): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def get_list(id, start, limit, head, reverse, node_url): | |
def get_batches(id, start, limit, head, reverse, node_url): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/cli.py
Outdated
@click.option('--limit', type=int, required=False, help=GET_BATCH_LIMIT_ARGUMENT_HELP_MESSAGE) | ||
@click.option('--head', type=str, required=False, help=GET_BATCH_HEAD_ARGUMENT_HELP_MESSAGE) | ||
@click.option('--reverse', type=str, required=False, help=GET_BATCH_REVERSE_ARGUMENT_HELP_MESSAGE) | ||
@click.option('--node-url', type=str, help=NODE_URL_ARGUMENT_HELP_MESSAGE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@click.option('--node-url', type=str, help=NODE_URL_ARGUMENT_HELP_MESSAGE) | |
@click.option('--node-url', type=str, required=False, help=NODE_URL_ARGUMENT_HELP_MESSAGE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/cli.py
Outdated
""" | ||
List batches. | ||
""" | ||
for batch_id in (id, start, head): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
head
should be a block identifier, not a batch identifier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/cli.py
Outdated
batch_service = Batch(service=remme) | ||
batches = loop.run_until_complete(batch_service.get_list(query)) | ||
|
||
click.echo(batches) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do pull from develop, you get a new function dict_to_pretty_json
.
click.echo(batches) | |
click.echo(dict_to_pretty_json(batches)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
d721d21
to
72976b3
Compare
cli/constants.py
Outdated
@@ -2,6 +2,8 @@ | |||
Provide constants for command line interface. | |||
""" | |||
ADDRESS_REGEXP = '[0-9a-f]{70}' | |||
BATCH_ID_REGEXP = '^[0-9a-f]{128}$' | |||
BLOCK_ID_REGEXP = '^[0-9a-f]{128}$' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have in remme-client-python this: https://github.com/Remmeauth/remme-client-python/blob/17901e34f3e46c4decd6452e675f189a4f068db1/remme/models/general/patterns.py#L13. Why we need to copy/paste to another project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
6efe290
to
326892d
Compare
README.md
Outdated
@@ -16,7 +16,7 @@ | |||
* [Nodes](#nodes) | |||
* [Configuration file](#configuration-file) | |||
* [Service](#service) | |||
* [Account](#account) | |||
* [Batch](#batch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why account has been removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
README.md
Outdated
| :-------: | :----: | :-------: | --------------------------------------------------- | | ||
| ids | String | No | Identifiers to get a list of batches by. | | ||
| start | String | No | Parameter to list batches starting from. | | ||
| limit | Integer| No | Parameter to limit amount of batches. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is start
an identifier of the block
to start paging (inclusive) from?
Parameter to limit amount of batches
> Number of transactions to return
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- start - Batch identifier to start listing from.
- Maximum amount of batches to return.
README.md
Outdated
```bash | ||
$ remme batch get-list \ | ||
--ids=[c2eeb94926d3432e41cb5ceed078f78466389e4fe685ec958021a1368f634c035072e434e5d0ff64820dd01fde6e5afc67eb5a9ae6c48d3983ff43abe98aef6b] \ | ||
--node-url=159.89.104.9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provide the most full example. As here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/forms.py
Outdated
raise ValidationError("Invalid reverse field. Should be either 'true' or 'false'.") | ||
|
||
@validates('node_url') | ||
def validate_node_url(self, node_url): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use this instead.
cli/batch/forms.py
Outdated
raise ValidationError(f'The following block id `{head}` is invalid.') | ||
|
||
@validates('reverse') | ||
def validate_reverse(self, reverse): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, create custom fields instead of a validation function for now.
We already did the migrations to them.
cli/batch/interfaces.py
Outdated
query (dict, optional): dictionary with specific parameters | ||
|
||
Returns: | ||
List of batches. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apply to each method you have — #18 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/service.py
Outdated
Returns: | ||
List of batches. | ||
""" | ||
return await self.service.blockchain_info.get_batches(query=query) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actualize the service as here — https://github.com/Remmeauth/remme-core-cli/blob/develop/cli/account/service.py#L28
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/cli.py
Outdated
'reverse': reverse, | ||
} | ||
|
||
batch_service = Batch(service=remme) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actualize the CLI as here — https://github.com/Remmeauth/remme-core-cli/blob/develop/cli/account/cli.py#L54
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
46e20da
to
efad12c
Compare
README.md
Outdated
--limit=1 \ | ||
--head=56100bf24eed12d2f72fe3c3ccf75fe2f53d87c224d9dda6fb98a1411070b06a40fcf97fccc61cb9c88442953af6ae50344ad7773f1becc6bae108443c18c551 \ | ||
--reverse=true \ | ||
--node-url=159.89.104.9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use common URL as in other examples — genesis.
cli/batch/forms.py
Outdated
strict=True, | ||
required=False, | ||
validate=[ | ||
validate.Range(min=1, error="Limit must be greater than 0."), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use single quotes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/forms.py
Outdated
List batches validation form. | ||
""" | ||
|
||
ids = IdListField(allow_none=True, required=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IdListField
> BatchIdentifierListField
.
Apply to other cases. For now, we do specific naming like, in the future when we will know then few arguments from different forms could use the same field, we will create a generic one with a generic name.
cli/batch/interfaces.py
Outdated
of batches, reversed result. | ||
|
||
Arguments: | ||
query (dict, optional): dictionary with specific parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dictionary with specific parameters
> dictionary with specific parameters.
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/service.py
Outdated
@implements(BatchInterface) | ||
class Batch: | ||
""" | ||
Implements batch interface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implements batch interface.
> Implements batch.
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/interfaces.py
Outdated
""" | ||
Get a list of batches. | ||
|
||
List of batches can be filtered by identifiers, start pagging, identifier of block's head, limit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove List of batches can..
from the interface. Leave in the implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
README.md
Outdated
--start=6bd3382e3deef34d0bc63a7b450c88c7ae00152f5168c7b4dc4357feff6d52175209919cd0710441fa2768f4c12adf97143440ef8414bb5144b9459d78ff3e0e \ | ||
--limit=2 \ | ||
--head=57a7944497ca41f424932ae6b70897e7086652ab98450d4aba6a02a2d891501460947812a41028b8041f087066df6dc7e1100c4b0e5cc94bb58b002f6950eb02 \ | ||
--node-url=node-genesis-testnet.remme.io \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--node-url=node-genesis-testnet.remme.io \ | |
--reverse \ | |
--node-url=node-genesis-testnet.remme.io |
'reverse': reverse, | ||
} | ||
|
||
result, errors = Batch(service=remme).get_list( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
result, errors = Batch(service=remme).get_list( | |
result, errors = Batch(service=remme).get_list(query=query) |
cli/batch/interfaces.py
Outdated
Implements batch. | ||
""" | ||
|
||
def get_list(self, query=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def get_list(self, query=None): | |
def get_list(self, query): |
cli/batch/service.py
Outdated
""" | ||
self.service = service | ||
|
||
def get_list(self, query=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def get_list(self, query=None): | |
def get_list(self, query): |
cli/batch/service.py
Outdated
query['reverse'] = 'false' | ||
|
||
try: | ||
batch_list = loop.run_until_complete( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
batch_list = loop.run_until_complete( | |
batch_list = loop.run_until_complete(self.service.blockchain_info.get_batches(query=query)) |
tests/batch/test_get_batches.py
Outdated
NODE_IP_ADDRESS_FOR_TESTING, | ||
]) | ||
|
||
command_response = json.loads(result.output) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modify test case by example.
tests/batch/test_get_batches.py
Outdated
assert header is not None | ||
|
||
|
||
def test_get_batches_invalid_head(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cli/generic/forms/fields.py
Outdated
""" | ||
Validate data (list identifiers) that was passed to field. | ||
""" | ||
value = [v.strip() for v in value.split(',')] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cli/generic/forms/fields.py
Outdated
return value | ||
|
||
|
||
class BatchIdField(IdField): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BatchIdField
> BatchIdentifierField
.
cli/generic/forms/fields.py
Outdated
""" | ||
Implements validation of the batch identifier. | ||
|
||
Raises a ValidationError if the identifier does not correspond to HEADER_SIGNATURE_REGEXP. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
README.md
Outdated
--head=57a7944497ca41f424932ae6b70897e7086652ab98450d4aba6a02a2d891501460947812a41028b8041f087066df6dc7e1100c4b0e5cc94bb58b002f6950eb02 \ | ||
--node-url=node-6-testnet.remme.io \ | ||
--reverse | ||
"result": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the result not in the dictionary?
{
'result': ...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/cli.py
Outdated
'node_address': str(node_url) + ':8080', | ||
}) | ||
|
||
batches, errors = Batch(service=remme).get_list( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
batches, errors = Batch(service=remme).get_list( | |
result, errors = Batch(service=remme).get_list( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/forms.py
Outdated
|
||
class GetBatchesListForm(Schema): | ||
""" | ||
Get a list of batch form. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get a list of batch form. | |
Get a list of batches form. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/help.py
Outdated
""" | ||
Provide help messages for command line interface's batch commands. | ||
""" | ||
BATCH_IDS_ARGUMENT_HELP_MESSAGE = 'Identifiers to get a list of batches by.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BATCH_IDS_ARGUMENT_HELP_MESSAGE = 'Identifiers to get a list of batches by.' | |
BATCH_IDENTIFIERS_ARGUMENT_HELP_MESSAGE = 'Identifiers to get a list of batches by.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/interfaces.py
Outdated
start (string, optional): batch identifier to get a list of batches starting from. | ||
limit (int, optional): maximum amount of batches to return. | ||
head (string, optional): block identifier to get a list of batches from. | ||
reverse (string, optional): parameter to reverse result. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverse (string, optional): parameter to reverse result. | |
reverse (bool, optional): parameter to reverse result. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cli/batch/service.py
Outdated
head (string, optional): block identifier to get a list of batches from. | ||
reverse (string, optional): parameter to reverse result. | ||
""" | ||
reverse = '' if reverse else 'false' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line because it is in the python library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
from cli.utils import dict_to_pretty_json | ||
|
||
|
||
def test_get_list_batches_with_all_parameters(mocker): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you using a mocker in this test? Please, send the command with all parameters to the real test node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
tests/batch/test_get_list_batches.py
Outdated
result_header_signature = json.loads(result.output).get('result').get('data')[0].get('header_signature') | ||
|
||
assert PASSED_EXIT_FROM_COMMAND_CODE == result.exit_code | ||
assert isinstance(json.loads(result.output), dict) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is meaningless, remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
assert dict_to_pretty_json(expected_error_message) in result.output | ||
|
||
|
||
def test_get_list_batches_with_invalid_node_url(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is for a non-existing node URL, but not an invalid node URL. Update documentation.
def test_get_list_batches_with_invalid_node_url(): | |
def test_get_batch_status_with_non_existing_node_url(): |
Create test for invalid node URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
assert PASSED_EXIT_FROM_COMMAND_CODE == result.exit_code | ||
assert expected_result == json.loads(result.output).get('result') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create tests for valid, but non-existing parameters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
tests/batch/test_get_list_batches.py
Outdated
|
||
def test_get_list_batches_with_non_existing_ids(): | ||
""" | ||
Case: get a list of batches by non existing identifiers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non existing
> non-existing
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
tests/batch/test_get_list_batches.py
Outdated
def test_get_list_batches_with_non_existing_ids(): | ||
""" | ||
Case: get a list of batches by non existing identifiers. | ||
Expect: list of batches not found error message is returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list of batches not found error message is returned.
> list of batches not found error message
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
tests/batch/test_get_list_batches.py
Outdated
]) | ||
|
||
expected_error_message = { | ||
'errors': f'List of batches not found.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove f-string
if you haven't passed any argument to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
tests/batch/test_get_list_batches.py
Outdated
def test_get_list_batches_with_start(): | ||
""" | ||
Case: get a list of batches by batch identifier starting from. | ||
Expect: batches are returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
batches are returned
> batches are returned beginning from the batch with an identifier which matches specified start parameter
or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
tests/batch/test_get_list_batches.py
Outdated
def test_get_list_batches_with_non_existing_start(): | ||
""" | ||
Case: get a list of batches by non-existing batch identifier starting from. | ||
Expect: list of batches not found error message is returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list of batches not found error message is returned
> list of batches not found error message
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
tests/batch/test_get_list_batches.py
Outdated
def test_get_list_batches_by_head(): | ||
""" | ||
Case: get a list of batches by block identifier. | ||
Expect: batches are returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check this and other tests for common points I have mentioned on above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
…into f-list-batches
README.md
Outdated
--start=6bd3382e3deef34d0bc63a7b450c88c7ae00152f5168c7b4dc4357feff6d52175209919cd0710441fa2768f4c12adf97143440ef8414bb5144b9459d78ff3e0e \ | ||
--limit=2 \ | ||
--head=57a7944497ca41f424932ae6b70897e7086652ab98450d4aba6a02a2d891501460947812a41028b8041f087066df6dc7e1100c4b0e5cc94bb58b002f6950eb02 \ | ||
--node-url=node-6-testnet.remme.io \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--node-url=node-6-testnet.remme.io \ | |
--reverse \ | |
--node-url=node-6-testnet.remme.io |
Node URL must be last.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
1, | ||
'--head', | ||
head, | ||
'--node-url', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Node URL must be last.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
'--reverse', | ||
]) | ||
|
||
assert PASSED_EXIT_FROM_COMMAND_CODE == result.exit_code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add checks, please! (example or like this assert expected_header_signature == result_header_signature
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
tests/batch/test_get_list_batches.py
Outdated
NODE_IP_ADDRESS_FOR_TESTING, | ||
]) | ||
|
||
assert PASSED_EXIT_FROM_COMMAND_CODE == result.exit_code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add checks, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
tests/batch/test_get_list_batches.py
Outdated
assert expected_header_signature == result_header_signature | ||
|
||
|
||
def test_get_list_batches_with_non_existing_ids(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make one test case using @pytest.mark.parametrize
for all tests with non-existing arguments (ids, start, head), they have the same error message 'List of batches not found.'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
tests/batch/test_get_list_batches.py
Outdated
assert dict_to_pretty_json(expected_error_message) in result.output | ||
|
||
|
||
@pytest.mark.parametrize('command_flag', ('--start', '--head')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pytest.mark.parametrize('command_flag', ('--start', '--head')) | |
@pytest.mark.parametrize('command_flag', ('--ids', '--start', '--head')) |
Add argument ids
to this test case and delete test test_get_list_batches_with_invalid_ids
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
tests/batch/test_get_list_batches.py
Outdated
assert PASSED_EXIT_FROM_COMMAND_CODE == result.exit_code | ||
|
||
|
||
def test_get_list_batches_with_invalid_limit(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
…into f-list-batches
} | ||
] | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the blank line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
NODE_IP_ADDRESS_FOR_TESTING, | ||
]) | ||
|
||
assert PASSED_EXIT_FROM_COMMAND_CODE == result.exit_code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a check like this assert result_header_signature == start
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is for head. Result doesn't include block identifier so there is nothing to compare with head.
'result': batch_data.get('data'), | ||
} | ||
|
||
mock_get_batch_by_ids = mocker.patch('cli.batch.service.loop.run_until_complete') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mock_get_batch_by_ids = mocker.patch('cli.batch.service.loop.run_until_complete') | |
mock_get_batches = mocker.patch('cli.batch.service.loop.run_until_complete') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Jira references
Description
Get a list of batches —
remme batch get-list
: