Skip to main content

athena

athena is a file-based rest api client.

Usage

athena can be run as a module, or with the included binary.

python3 -m athena --help

athena --help

Setup

Start by running the init in your project directory.

athena init .

Enter this directory, and create a workspace

cd athena
athena create workspace my-workspace

Lastly, create a new collection inside the workspace

athena create collection my-collection -w my-workspace

Creating tests

To create a test case, add a python file in the run folder of a collection

vim athena/my-workspace/collections/my-collection/run/hello.py

Create a function called run, that takes the Athena instance as the argument.

from athena.client import Athena

def run(athena: Athena):
    ...

Sending requests

The injected Athena instance provides methods to create and send requests. Start by creating a new Client.

def run(athena: Athena):
    client = athena.client()

The client can be configured by providing a builder function. The builder will be applied to each request sent by the client.

def run(athena: Athena):
    client = athena.client(lambda builder: builder
        .base_url("http://haondt.com/api/")
        .header("origin", "athena")
        .auth.bearer("some_secret_key"))

The client can be used to send api requests. The requets themselves can also be configured with a builder.

def run(athena: Athena):
    ...
    response = client.put("planets/saturn", lambda builder: builder
        .body.json({
            "diameter": "120 thousand km",
            "density": "687 kg/m^3",
            "distance_from_sun": "1.35 billion km"
        }))

The response is a ResponseTrace, which contains information about the response

def run(athena: Athena):
    ...
    print(f"status: {response.status_code} {response.reason}")

athena can provide more information about the rest of the request with the trace method, which will return the AthenaTrace for the whole request/response saga.

def run(athena: Athena):
    ...
    trace = athena.trace(response)
    print(f"request payload: {trace.request.raw}")
    print(f"request time: {trace.elapsed}")

Running tests

athena can search the directory for modules to execute. Use athena run to start, and provide an argument of the module to run. This can be a path to the module or to a directory along the module hierarchy. In the latter case, athena will run all the modules it can find inside that directory.

# run all the modules inside the api directory
athena run /path/to/athena/my-workspace/collections/my-collection/run/api

Module keys

Any command that takes a module path can also take an argument of the form workspace:collection:module, and run all the modules that match. This key will be computed relative to the current working directory, and allows for more precision in determining which modules to run.

# run all modules in "my-workspace" named "hello.py"
athena run "my-workspace:*:hello"

For any module in a collection run folder, the directory path relative to the run folder will make up the module name. For example, given the following files:

athena/my-workspace/collections/my-collection/run/red.py
athena/my-workspace/collections/my-collection/run/green.py
athena/my-workspace/collections/my-collection/run/toast/blue.py
athena/my-workspace/collections/my-second-collection/run/red.py

You would have the following module keys:

my-workspace:my-collection:red
my-workspace:my-collection:green
my-workspace:my-collection:toast.blue
my-workspace:my-second-collection:red

The workspace and collection parts can contain wild cards. A single period (.) in either field will use the current directory. A single asterisk (*) will use all directories.

# run all modules in "my-workspace" named "hello.py"
athena run "my-workspace:*:hello"

For the module name, asterisks can be used to denote "any module/directory", and double asterisks (**) can be used to denote any subdirectory.

# runs all files
athena run "*:*:**"

# runs red.py and green.py
athena run "*:*:*"

# runs only blue.py
athena run "*:*:*.*"
athena run "*:*:toast.*"
athena run "*:*:**blue"

# run all modules in the collection of the current directory
athena run ".:.:**"

Internally, asterisks are compiled into the regular expression [^.]+ and double asterisks are compiled into .+.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

haondt_athena-1.1.0-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file haondt_athena-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: haondt_athena-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.11.6 Linux/6.2.0-1015-azure

File hashes

Hashes for haondt_athena-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b2ccfcc2f429e355582039304637e70f341311569f78396bd8606ebed0625ce
MD5 114863523d8457d4166ffdad66cdff7e
BLAKE2b-256 d42ae92946471aec0bb2fe7e8aa2deb285e278434e68ee87ecb4305331c6a6ac

See more details on using hashes here.

Release history Release notifications | RSS feed

5.1.2

2 files

5.1.1

2 files

5.1.0

2 files

5.0.4

2 files

5.0.3

2 files

5.0.2

2 files

5.0.1

2 files

5.0.0

2 files

4.1.1

2 files

4.1.0

2 files

4.0.2

2 files

4.0.1

2 files

4.0.0

2 files

3.0.2

2 files

3.0.1

2 files

3.0.0

2 files

2.4.0

2 files

2.3.2

2 files

2.3.1

2 files

2.3.0

2 files

2.2.2

2 files

2.2.1

2 files

2.2.0

2 files

2.1.0

2 files

2.0.3

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

1.2.0

1 file

This release

1.1.0 This release

1 file

1.0.5

1 file

1.0.4

1 file

1.0.3

1 file

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page