Skip to content

Commit

Permalink
Integraion tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TheR1D committed Apr 16, 2023
1 parent 7955881 commit 9019b24
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/test_integration.py
Expand Up @@ -339,3 +339,46 @@ def test_shell_stdin_with_prompt(self):
stdin = "What is in current folder\n"
result = runner.invoke(app, self.get_arguments(**dict_arguments), input=stdin)
assert result.stdout == "ls | sort\n"

def test_simple_role(self):
test_role = Path(cfg.get("ROLE_STORAGE_PATH")) / "test_json.json"
test_role.unlink(missing_ok=True)
dict_arguments = {
"prompt": "test",
"--create-role": "test_json",
}
input = (
"You are a JSON generator, return only JSON as response.\n"
"json\n"
)
result = runner.invoke(app, self.get_arguments(**dict_arguments), input=input)
assert result.exit_code == 0


dict_arguments = {
"prompt": "test",
"--list-roles": True,
}
result = runner.invoke(app, self.get_arguments(**dict_arguments))
assert result.exit_code == 0
assert "test_json" in result.stdout

dict_arguments = {
"prompt": "test",
"--show-role": "test_json",
}
result = runner.invoke(app, self.get_arguments(**dict_arguments))
assert result.exit_code == 0
assert "You are a JSON generator" in result.stdout

dict_arguments = {
"prompt": "random username, password, email",
"--role": "test_json",
}
result = runner.invoke(app, self.get_arguments(**dict_arguments))
assert result.exit_code == 0
generated_json = json.loads(result.stdout)
assert "username" in generated_json
assert "password" in generated_json
assert "email" in generated_json
test_role.unlink(missing_ok=True)

0 comments on commit 9019b24

Please sign in to comment.