Skip to content
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

test trace command: execute a trace against testnet #61

Merged
merged 6 commits into from
Jul 28, 2022

Conversation

andrey-kuprianov
Copy link
Contributor

Closes #27

This PR implements atomkraft test trace command

  • trace option is required now, until Store and retrieve the last model trace #55 is implemented
  • generates a new Pytest file, referencing the trace, the supplied / stored reactor
  • stores the test file in the tests dir
  • invokes Pytest on the new file.

This PR leaves for future work:

  • retrieving and storing blockchain logs
  • retrieving and storing test execution results
  • tests for the above functionality

@andrey-kuprianov andrey-kuprianov added this to the Atomkraft prototype milestone Jul 27, 2022
@andrey-kuprianov andrey-kuprianov requested a review from a team July 27, 2022 09:54
@andrey-kuprianov andrey-kuprianov self-assigned this Jul 27, 2022
Comment on lines 9 to 17
trace_test_stub = """
from modelator.pytest.decorators import itf

pytest_plugins = "{0}"

@itf("{1}", keypath="{2}")
def test_trace():
print("Successfully executed trace {1}")
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 for this!

but best to make the variable name capitalize because it is a constant.

Copy link
Member

@rnbguy rnbguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments 🙂

Comment on lines +42 to +47
test_name = (
test_name.replace("/", "_")
.replace(".", "_")
.replace(":", "_")
.replace("-", "_")
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're trying to convert test_name to a valid snake case. You can use the case-converter package here 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried it. snakecase produces this

test_tracesexample0itfjson_2022_07_28t104954601.py

instead of this

test_traces_example0_itf_json_2022_07_28T10_49_54_601.py

The latter I believe is more readable; so let's leave it as is for now.

print(f"Writing {test_name} ...")
test.write(
trace_test_stub.format(
str(reactor).replace("/", ".").replace(".py", ""), trace, keypath
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use .removesuffix(".py") instead of .replace(".py", "").

Base automatically changed from andrey/get_reactor to dev July 28, 2022 08:28
Copy link
Member

@rnbguy rnbguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@andrey-kuprianov andrey-kuprianov merged commit 7186c0b into dev Jul 28, 2022
@andrey-kuprianov andrey-kuprianov deleted the andrey/trace branch July 28, 2022 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement test trace subcommand
2 participants