wip
This commit is contained in:
parent
864321a45b
commit
53d878c75a
4 changed files with 64 additions and 5 deletions
|
|
@ -205,3 +205,30 @@ def test_cli_get_404(mocker):
|
|||
assert result.exception.status_code == 404
|
||||
assert result.exception.detail == "{{modelname}} not found"
|
||||
|
||||
|
||||
def test_cli_list(mocker):
|
||||
mocker.patch(
|
||||
"learn_sql_model.config.Database.engine",
|
||||
new_callable=lambda: create_engine(
|
||||
"sqlite://", connect_args={"check_same_thread": False}, poolclass=StaticPool
|
||||
),
|
||||
)
|
||||
|
||||
config = get_config()
|
||||
SQLModel.metadata.create_all(config.database.engine)
|
||||
|
||||
{{modelname.lower()}}_1 = {{modelname}}Factory().build(name="Steelman", age=25)
|
||||
{{modelname.lower()}}_2 = {{modelname}}Factory().build(name="Hunk", age=52)
|
||||
|
||||
with config.database.session as session:
|
||||
session.add({{modelname.lower()}}_1)
|
||||
session.add({{modelname.lower()}}_2)
|
||||
session.commit()
|
||||
session.refresh({{modelname.lower()}}_1)
|
||||
session.refresh({{modelname.lower()}}_2)
|
||||
result = runner.invoke({{modelname.lower()}}_app, ["list"])
|
||||
assert result.exit_code == 0
|
||||
assert f"name='{{{modelname.lower()}}_1.name}'" in result.stdout
|
||||
assert f"secret_name='{{{modelname.lower()}}_1.secret_name}'" in result.stdout
|
||||
assert f"name='{{{modelname.lower()}}_2.name}'" in result.stdout
|
||||
assert f"secret_name='{{{modelname.lower()}}_2.secret_name}'" in result.stdout
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue