Package: haondt-athena
athenaathena is a file-based rest api client.Usageathena can be run as a module, or with the included binary.python3-mathena--help

athena--helpSetupStart by running the init in your project directory.athenainit.Enter this directory, and create a workspacecdathena
athenacreateworkspacemy-workspaceLastly, create a new collection inside the workspaceathenacreatecollectionmy-collection-wmy-workspaceCreating testsTo create a test case, add a python file in therunfolder of a collectionvimathena/my-workspace/collections/my-collection/run/hello.pyCreate a function calledrun, that takes theAthenainstance as the argument.fromathena.clientimportAthenadefrun(athena:Athena):...Sending requestsThe injectedAthenainstance provides methods to create and send requests. Start by creating a newClient.defrun(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.defrun(athena:Athena):client=athena.client(lambdabuilder: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.defrun(athena:Athena):...response=client.put("planets/saturn",lambdabuilder:builder.body.json({"diameter":"120 thousand km","density":"687 kg/m^3","distance_from_sun":"1.35 billion km"}))The response is aResponseTrace, which contains information about the responsedefrun(athena:Athena):...print(f"status:{response.status_code}{response.reason}")athena can provide more information about the rest of the request with thetracemethod, which will return theAthenaTracefor the whole request/response saga.defrun(athena:Athena):...trace=athena.trace(response)print(f"request payload:{trace.request.raw}")print(f"request time:{trace.elapsed}")Running testsathena can search the directory for modules to execute. Useathena runto 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 directoryathenarun/path/to/athena/my-workspace/collections/my-collection/run/apiModule keysAny command that takes a module path can also take an argument of the formworkspace: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"athenarun"my-workspace:*:hello"For any module in a collectionrunfolder, the directory path relative to therunfolder 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.pyYou 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:redThe 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"athenarun"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 filesathenarun"*:*:**"# runs red.py and green.pyathenarun"*:*:*"# runs only blue.pyathenarun"*:*:*.*"athenarun"*:*:toast.*"athenarun"*:*:**blue"# run all modules in the collection of the current directoryathenarun".:.:**"Internally, asterisks are compiled into the regular expression[^.]+and double asterisks are compiled into.+.