Metadata-Version: 2.4
Name: gfrast
Version: 0.3.0
Summary: GFRAST (GAMS Flexible Repository ASsertion Tool) is a small script to test HTTP server responses.
Keywords: GAMS,twill,testing
Author: Gunter Vasold
Author-email: Gunter Vasold <gunter.vasold@uni-graz.at>
License-Expression: MIT-0
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Testing
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Requires-Dist: twill>=3.4.0
Requires-Python: >=3.10
Project-URL: Homepage, https://git.uni-graz.at/open/562-dh/gams/tools/gfrast
Project-URL: Issues, https://git.uni-graz.at/open/562-dh/gams/tools/gfrast/issues
Project-URL: Documentation, https://git.uni-graz.at/open/562-dh/gams/tools/gfrast
Project-URL: Source, https://git.uni-graz.at/open/562-dh/gams/tools/gfrast
Project-URL: Download, https://pypi.org/project/gfrast
Description-Content-Type: text/markdown

# GFRAST

GFRAST (**G**AMS **F**lexible **R**epository **As**sertion **T**ool) is a small 
wrapper around the
[Twill](https://github.com/twill-tools/twill) HTTP testing client. It lets you run
repeatable, script-driven checks against a web server and summarize the results in
a machine-friendly way.

The main difference from using Twill directly is that GFRAST filters and normalizes
its output so it can be consumed by other tools or custom clients. The current CLI
provides a simple, focused interface for running scripts and writing a JSON summary.

## Installation

GFRAST is available on PyPI and can be installed with common package managers:

```bash
pip install gfrast
uv add gfrast
```

If you use `uv` and only want to run GFRAST temporarily, you can do so without a
permanent install:

```bash
uvx gfrast --help
```

## Usage

GFRAST executes Twill script files. These are plain text files that describe the
HTTP checks to run.

A minimal example script, `example.twill`, might look like this:

```text
go /foo/bar
   code 200
   find "foobar"
```

This loads `/foo/bar` from the configured base URL and asserts that the response has
status code `200` and contains the text `foobar`.

To run a script:

```bash
gfrast example.twill
```

By default, GFRAST uses `https://gams.uni-graz.at` as the base URL. You can override
that with `-u` / `--baseurl`:

```bash
gfrast -u https://example.com example.twill
```

You can run multiple scripts by passing several files:

```bash
gfrast -u https://example.com example1.twill example2.twill
```

Or you can point GFRAST to a directory. It will recursively run all `.twill` files
inside that directory:

```bash
gfrast -u https://example.com my_scripts
```

This is especially useful for organizing tests by project or repository section.

### Command-line options

The CLI supports the following options:

- `-u`, `--baseurl <URL>`: Set the base URL prepended to each `go` command.
- `-w`, `--workers <INTEGER>`: Number of worker processes to use. Default is `1`.
- `--log-level <STRING>`: Set the log level (`ERROR`, `WARNING`, `INFO`, `DEBUG`).
- `--logfile <PATH>`: Path for the JSON summary log file. Default is `gfrast.log.json`.
- `--no-log`: Disable writing the JSON summary file.

## Script files

A Twill script is just a plain text file that controls the client.

Example:

```text
go /foo/bar
   code 200
   find "foobar"
```

The first line (`go /foo/bar`) issues the request. The base URL is prepended before
sending the request. For example, with `--baseurl https://example.com`, this becomes:

```text
https://example.com/foo/bar
```

The next line (`code 200`) asserts that the response status is `200`.

The third line (`find "foobar"`) asserts that the response body contains the string
`foobar`.

For more advanced behavior, Twill supports a wide range of commands for forms,
cookies, redirects, and more. See the official Twill docs:
https://twill.readthedocs.io/en/latest/commands.html

## Frequently used script commands

### `go <PATH>`

This is usually the first command in a script. Most other commands operate on the
result of the last `go` request.

```text
go /foo/bar
   code 200
   find "foobar"
```

When the base URL is set, `go` values are automatically expanded to full URLs.

### `code <INT>`

Asserts that the response status matches the given integer.

```text
code 200
```

### `find <PATTERN> [<FLAGS>]`

Checks whether the response contains the given pattern.

```text
find "foo"
```

This supports regular expressions and flags such as `i` (ignore case) and `m`
(multiline). It can also be used with XPath via the `x` flag.

Example:

```text
find "//xhtml:input/@id[.='query']" x
```

### `not_find`

Asserts that a pattern does not appear in the response.

### `url <PATTERN>`

Asserts that the current page URL matches a given pattern. This is especially useful
for redirect tests.

### `title <PATTERN>`

Asserts that the page title matches the supplied pattern.

### `header <NAME>[<PATTERN>]`

Checks that an HTTP header has the expected value.

### `echo`

Prints a string to the output stream.

### `info`

Displays information about the current page for debugging.

### `show`

Prints the current page content for debugging.


## Development

The git.uni-graz.at server is only a mirror for the private repository, where the development takes place.
