<commit_before>This page describes the *assertions* supported in [UnRAVL](Reference.md) scripts.

Assertions are what test the API.
There are two sets of supported assertions:
<code>"preconditions"</code> and <code>"assert"</code>.

<code>"preconditions"</code>
are evaluated *before* invoking the API and must
all pass before calling the API. This can be used to
validate environment variables that may have been set
from other APIs calls in earlier tests.

```JSON
 "preconditions" : assertions
```

<code>"assert"</code> assertions run after the API call and validate the result.

```JSON
 "assert" : assertions
```

<code>"preconditions"</code> and <code>"assert"</code> blocks are very similar, differing
only in when they are executed. In the description below,
descriptions of <code>"assert"</code> also applies to <code>"preconditions"</code>.

Assertions can take following form:

```
  "assert" : "expression-string"
  "assert" : json-object
  "assert" : json-array
```

In the first form, the "<code>expession-string</code>" is converted to
<code>"assert" : [ { "groovy" : "expression-string" } ]</code>;
see the <code>"[groovy](#groovy)"</code>
assertion element below.

The second form is converted to the general array form,
<code>"assert" : [ json-object ]</code>

The third form is the most general case: an array of
assertions, using the forms described below.
If an element of the array is a string, it is
assumed to be a Groovy (or JavaScript) assertion.

Each assertion in the array is evaluated in order. Validation stops
on the first failed assertion in the array.

Below is the set of assertions supported by UnRAVL.
Reminder: all the precondition/assertion forms described below are embedded within a
```JSON
"preconditions" : assertion
"precondition" : [ array of assertions ]
```
```JSON
"assert" : assertion
"assert" : [ array of assertions ]
```
element. Note however that some only make sense
inside <code>"assert"</code> since they make assertions about
the result of the API call.

## status ##

Checks that the HTTP status code matches the expected response.
<commit_msg>Continue to refactor reference doc<commit_after>This page describes the *assertions* supported in [UnRAVL](Reference.md) scripts.

Assertions are what test the API.
There are two sets of supported assertions:
<code>"preconditions"</code> and <code>"assert"</code>.

<code>"preconditions"</code>
are evaluated *before* invoking the API and must
all pass before calling the API. This can be used to
validate environment variables that may have been set
from other APIs calls in earlier tests.

```JSON
 "preconditions" : assertions
```

<code>"assert"</code> assertions run after the API call and validate the result.

```JSON
 "assert" : assertions
```

<code>"preconditions"</code> and <code>"assert"</code> blocks are very similar, differing
only in when they are executed. In the description below,
descriptions of <code>"assert"</code> also applies to <code>"preconditions"</code>.

Assertions can take following form:

```
  "assert" : "expression-string"
  "assert" : json-object
  "assert" : json-array
```

In the first form, the "<code>expession-string</code>" is converted to
<code>"assert" : [ { "groovy" : "expression-string" } ]</code>;
see the <code>"[groovy](#groovy)"</code>
assertion element below.

The second form is converted to the general array form,
<code>"assert" : [ json-object ]</code>

The third form is the most general case: an array of
assertions, using the forms described below.
If an element of the array is a string, it is
assumed to be a Groovy (or JavaScript) assertion.

Each assertion in the array is evaluated in order. Validation stops
on the first failed assertion in the array.

Below is the set of assertions supported by UnRAVL.
Reminder: all the precondition/assertion forms described below are embedded within a
```JSON
"preconditions" : assertion
"precondition" : [ array-of-assertions ]
```
```JSON
"assert" : assertion
"assert" : [ array-of-assertions ]
```
element. Note however that some only make sense
inside <code>"assert"</code> since they make assertions about
the result of the API call.

## status ##

Checks that the HTTP status code matches the expected response.

{'fraction_non_alphanumeric': 0.10740477880293352, 'fraction_numerical': 0.0, 'mean_word_length': 4.9132867132867135, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1600930', 'n_tokens_mistral': 1221, 'n_tokens_neox': 1135, 'n_words': 532}