Skip to content

Commit

Permalink
test: Added first test for an app call
Browse files Browse the repository at this point in the history
  • Loading branch information
robdmoore committed Dec 10, 2023
1 parent 5ade91f commit daf7aa9
Show file tree
Hide file tree
Showing 13 changed files with 2,254 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ out/
watermark.txt
examples/**/*.json

__pycache__
30 changes: 29 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,33 @@
"eslint.options": {
"extensions": [".ts", ".graphql"]
},
"eslint.workingDirectories": ["./graphql"]
"eslint.workingDirectories": ["./graphql"],

// Python
"python.defaultInterpreterPath": "${workspaceFolder}/tests/contract/.venv",
"python.analysis.extraPaths": ["${workspaceFolder}/tests/contract"],
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff"
},
"python.analysis.typeCheckingMode": "basic",
"ruff.enable": true,
"ruff.lint.run": "onSave",
"ruff.lint.args": ["--config=${workspaceFolder}/tests/contract/pyproject.toml"],
"ruff.importStrategy": "fromEnvironment",
"ruff.fixAll": true, //lint and fix all files in workspace
"ruff.organizeImports": true, //organize imports on save
"ruff.codeAction.disableRuleComment": {
"enable": true
},
"ruff.codeAction.fixViolation": {
"enable": true
},

"mypy.configFile": "tests/contract/pyproject.toml",
// set to empty array to use config from project
"mypy.targets": [],
"mypy.runUsingActiveInterpreter": true,
"mypy.enabled": true,
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": false
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"commit-lint": "commitlint --edit -o",
"semantic-release": "semantic-release",
"generate:code-docs": "typedoc",
"generate:contract-client": "cd tests/contract && poetry run python -m build",
"pre-commit": "run-s check-types lint:fix audit format test generate:code-docs",
"dhm": "ts-node-dev --transpile-only --watch .env -r dotenv/config ./examples/data-history-museum/index.ts",
"watch-dhm": "cross-env RUN_LOOP=true npm run dhm",
Expand Down
2 changes: 2 additions & 0 deletions tests/contract/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.teal
*.json
Empty file added tests/contract/__init__.py
Empty file.
44 changes: 44 additions & 0 deletions tests/contract/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import logging
import subprocess
from pathlib import Path

import beaker

from contract import app

logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(levelname)-10s: %(message)s")
logger = logging.getLogger(__name__)
root_path = Path(__file__).parent


def build(output_dir: Path, app: beaker.Application) -> Path:
logger.info(f"Exporting {app.name} to {output_dir}")
specification = app.build()
specification.export(output_dir)

result = subprocess.run(
[
"algokit",
"generate",
"client",
"application.json",
"--output",
"client.ts",
],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
)
if result.returncode:
raise Exception("Could not generate typed client")

return output_dir / "application.json"


def main() -> None:
logger.info("Building contract")
build(root_path, app)


if __name__ == "__main__":
main()
Loading

0 comments on commit daf7aa9

Please sign in to comment.