Awesome universal-test-tool to make tests configurable with a yaml file.
Project description
universal-test-tool
Awesome universal-test-tool to make tests configurable with a yaml file.
Install the repository
pip install universal-test-tool
Run the tests
test-tool
# This programm is a tool for running tests.
# options:
# -h, --help show this help message and exit
# -p PROJECT, --project PROJECT
# The path to the project.
# -ca CALLS, --calls CALLS
# The filename of the calls configuration.
# -d DATA, --data DATA The filename of the data configuration.
# -X, --debug Activate debugging.
Calls File
Per default a file calls.yaml
is searched in the project folder, which is by default the current working directory.
It is a list where every entry is one step to test.
The tests are done in the following available plugins:
- Assert (test_tool_assert_plugin)
- Bash Cmd (test_tool_bash_cmd_plugin)
- Copy Files SSH (test_tool_copy_files_ssh_plugin)
- JDBC SQL (test_tool_jdbc_sql_plugin)
- Read Jar Manifest (test_tool_read_jar_manifest_plugin)
- Rest (test_tool_rest_plugin)
- SSH Cmd (test_tool_ssh_cmd_plugin)
Assert (test_tool_assert_plugin)
Make an assertion.
Call:
- type: ASSERT
call:
value: None
expected: None
operator: ==
error_msg: The value is not as expected.
Parameters:
Parameter | Default | Description |
---|---|---|
value | None | The given value. |
expected | None | The expected value. |
operator | == | One of the supported operations (==, !=, <, <=, >, >=). |
error_msg | The value is not as expected. | The error message for the logs. |
Bash Cmd (test_tool_bash_cmd_plugin)
Runs a command on the local machine.
Call:
- type: BASH_CMD
call:
cmd: None
timeout: None
save: None
Object for save:
save:
name: None
type: None
Parameters:
Parameter | Default | Description |
---|---|---|
cmd | None | The command to run. |
timeout | None | The timeout for the command. |
save | None | Save the result to value. |
Parameters for save:
Parameter | Default | Description |
---|---|---|
name | None | The name for the variable to save the result in. |
type | None | The type for how to treat the result (STRING, JSON). |
Copy Files SSH (test_tool_copy_files_ssh_plugin)
Copies files and folders between local machine and remote machine via ssh.
Call:
- type: COPY_FILES_SSH
call:
user: ${REMOTE_CMD_USER}
password: ${REMOTE_CMD_PASSWORD}
host: ${REMOTE_CMD_HOST}
local_path: None
remote_path: None
download: False
Parameters:
Parameter | Default | Description |
---|---|---|
user | ${REMOTE_CMD_USER} | The user for the ssh connection. |
password | ${REMOTE_CMD_PASSWORD} | The password for the ssh connection. |
host | ${REMOTE_CMD_HOST} | The host for the ssh connection. |
local_path | None | The local file or folder for the transfer. |
remote_path | None | The remote file or folder for the transfer. |
download | False | If this flag is set to true, the file transfer is a download, otherwise it is an upload. |
JDBC SQL (test_tool_jdbc_sql_plugin)
Runs SQL Statements with JayDeBeApi.
Call:
- type: JDBC_SQL
call:
query: None,
save: [],
validate: [],
driver: ${DB_DRIVER},
driver_path: ${DB_DRIVER_PATH},
url: ${DB_URL},
username: ${DB_USERNAME},
password: ${DB_PASSWORD}
Object for save:
save:
raw: None
column: None
name: None
Object for validate:
save:
raw: None
column: None
value: None
Parameters:
Parameter | Default | Description |
---|---|---|
query | None | The SQL statement to run |
save | [] | Save a entry of a cell to a variable |
vaidate | [] | Validate the entry of a cell |
driver | ${DB_DRIVER} | The Class of the driver |
driver_path | ${DB_DRIVER_PATH} | The Path of the jar file |
url | ${DB_URL} | The jdbc connection string |
username | ${DB_USERNAME} | The username of the db |
password | ${DB_PASSWORD} | The password of the db |
Read Jar Manifest (test_tool_read_jar_manifest_plugin)
Unpacks a jar file and parses and prints the manifest file to the logger. It also optionally saves a value.
Call:
- type: READ_JAR_MANIFEST
call:
jar_path: ${PATH_JAR_FILE}
manifest_path: META-INF/MANIFEST.MF
save: []
Object for save:
save:
name: None
key: None
Parameters:
Parameter | Default | Description |
---|---|---|
jar_path | ${PATH_JAR_FILE} | The absolute or relative path to the jar file. |
manifest_path | META-INF/MANIFEST.MF | The path within the jar file to the manifest. |
save | None | Save values of the result to a variable with the given name. |
Parameters for save:
Parameter | Default | Description |
---|---|---|
name | None | The name for the variable to save the result in. |
key | None | The key of the parsed manifest. |
Rest (test_tool_rest_plugin)
Tests REST endpoints.
Call:
- type: REST
call:
base_url: ${REST_BASE_URL}
path: ${REST_PATH}
url: None
method: GET
data: None
files: None
payload: None
headers: {}
response_type: JSON
assertion: None
hide_logs: False
status_codes: [200]
Parameters:
Parameter | Default | Description |
---|---|---|
base_url | ${REST_BASE_URL} | The base url of the service to test. |
path | ${REST_PATH} | The path of the endpoint to test. |
url | None | The url value is built dynamically from ${base_url}/${path} if not set. Otherwiese the oder values are ignored. |
method | GET | The method of the call. (GET, POST, DELETE, PUT) |
data | None | The data of the http call, an object is used as json. |
files | None | Path of files to send. |
payload | None | Payload for multipart request. |
header | {} | Headers to use for request. |
response_type | JSON | How to pasrse the response. (JSON, XML, TEXT) |
assertion | NONE | The assertion how the response should look like |
hide_log | False | Don't print the reply in the logs. |
status_codes | [200] | The status codes to accept. |
SSH Cmd (test_tool_ssh_cmd_plugin)
Runs a command on a remote machine via ssh.
Call:
- type: SSH_CMD
call:
user: ${REMOTE_CMD_USER}
password: ${REMOTE_CMD_PASSWORD}
host: ${REMOTE_CMD_HOST}
cmd: None
Parameters:
Parameter | Default | Description |
---|---|---|
user | ${REMOTE_CMD_USER} | The user for the ssh connection. |
password | ${REMOTE_CMD_PASSWORD} | The password for the ssh connection. |
host | ${REMOTE_CMD_HOST} | The host for the ssh connection. |
cmd | None | The command to run. |
Other available plugins:
This project can handle any other plugins as well. There just need to be a installed module following a naming convention. E.g. if you define a test in the calls.yaml like:
- type: EXAMPLE_CALL
call:
value1: Lorem
value2: Ipsum
This tool then searches for a plugin called test_tool_example_name_plugin with the following required methods:
# The default values of the plugin
default_example_name_call: Dict[str, Any] = {
'key1': 'value1',
'key2': 'value2'
}
# Change the values before the tests are run
def augment_example_name_call(call: Dict[str, Any], data: Dict[str, Any], path: Path) -> None:
# Do your stuff here
# call is a merged object from default_example_name_call and the object from the calls.yaml file.
# data is the data from the data.yaml file modified in test steps.
# The path of the folder where the test is.
pass
# Make the call
def make_example_name_call(call: Dict[str, Any], data: Dict[str, Any]) -> None:
# Do your stuff here
# call is a merged object from default_example_name_call and the object from the calls.yaml file.
# data is the data from the data.yaml file modified in test steps.
pass
If this module is found it is used to process the test case. In an case of an error, there should be thrown an AssertionError
.
Development
Read the CONTRIBUTING.md file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for universal-test-tool-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7479327e51c86135ef9e8e5df00423ac06ab1a2590416e8e757fc32eda692499 |
|
MD5 | ecf1746d1bfd4dc9ead722cd2af42a84 |
|
BLAKE2b-256 | 59bdacc9858339f5008b36eb6dcd757394a2516d3bb44b41a12a670bcd141a41 |
Hashes for universal_test_tool-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 343dd66efcdc1fb9f62e9a6f2844d04d8571ff1d622b620a130fe5b0a9ab8c76 |
|
MD5 | 4aaf80ea80c6068c7f73bf536b05e493 |
|
BLAKE2b-256 | 1ca8ce4fc614ee1a66b007b7992d7c1b66bf91000e30669d3196e9a6476948ed |