跳转到主要内容

API watchdog

项目描述

API Watchdog

用法

api-watchdog discover path/to/test/files

将输出测试的缩略结果到stdout。

api-watchdog discover --email path/to/test/files

将测试结果发送到相关地址的电子邮件(由测试的email_to=字段确定。测试结果分组,以便在每次运行中每个地址只发送一封电子邮件。

当使用CLI时,必须设置以下环境变量以发送电子邮件结果

  • MAILGUN_API_URL
  • MAILGUN_API_TOKEN
  • MAILGUN_FROM
api-watchdog discover -o results_file.json path/to/test/files

WatchdogResultGroup对象序列化到由-o标志指定的路径。

安装

API watchdog通过额外需求处理验证支持。这意味着要使用TRAPI验证安装它,您需要调用

pip install api-watchdog[TRAPI]

如果您正在使用zsh,您将遇到括号通配符问题,应使用

pip install 'api-watchdog[TRAPI]'

有关上下文,请参阅此Stack Overflow问题

可用的扩展包括

  • TRAPI

如果您不需要任何验证支持,您可以使用纯pip install api-watchdog命令。

WatchdogTest格式

您将通过WatchdogTest与API Watchdog进行交互。每个WatchdogTest都有

  • 名称(str):测试的名称
  • 目标(url):测试的目标端点
  • 期望(Array[Expectation]):响应必须满足的一组要求,以便测试通过。
  • 负载(object):传递到端点的json。

期望格式

期望(Expectation)描述了在响应中查找数据的位置以及该数据应该是什么样,以便测试通过。每个期望(Expectation)都有:

  • 选择器(jq程序):一个描述jq程序的字符串,用于选择要测试的一个或多个元素
  • 值(Any):用于测试相等性的值
  • validation_type(ValidationType):API Watchdog用于验证值/响应的验证类型。值/响应将隐式转换为此类型。例如,如果您指定'float'且值是整数,则将隐式转换为浮点数。
  • level(Optional[ExpectationLevel]):期望的重要性。默认为"critical"。

ExpectationLevel

以下字符串之一

  • critical
  • warning
  • info 只有"critical"期望会影响WatchdogTest的成功或失败。

选择器格式是一个jq程序的字符串。这允许具有丰富的选择功能。例如

    {
      "selector": ".message.knowledge_graph.nodes[\"MONDO:0005148\"].name",
      "value": "type 2 diabetes mellitus",
      "validation_type": "string"
    },

是检查TRAPI响应的知识图中是否存在节点的期望(Expectation)。

可能的验证类型包括

  • "string",
  • "int",
  • "float",
  • "object",
  • "bool",
  • "null",
  • "trapi.knowledge_graph",
  • "trapi.node",
  • "trapi.edge",
  • "trapi.query_graph",
  • "trapi.q_node",
  • "trapi.q_edge",
  • "trapi.query_constraint",
  • "trapi.result",
  • "trapi.node_binding",
  • "trapi.edge_binding",
  • "trapi.message",
  • "trapi.query",
  • "trapi.response",
  • "trapi.async_query",
  • "trapi.operation",
  • "trapi.workflow",
  • "trapi.attribute",
  • "trapi.biolink_entity",
  • "trapi.biolink_predicate",
  • "trapi.curie",
  • "trapi.log_entry",
  • "trapi.log_level",
  • "trapi.meta_edge",
  • "trapi.meta_node",
  • "trapi.meta_knowledge_graph",
  • "trapi.meta_attribute"

是什么

一个API监控实用程序,希望支持

  • 验证
  • 持续集成
  • 多种输入和输出格式
  • 测试发现/最小配置

不是什么

项目详细信息


下载文件

下载适合您平台的文件。如果您不确定要选择哪个,请了解更多关于安装包的信息。

源分布

api_watchdog-0.6.0.tar.gz (13.4 kB 查看散列)

上传时间

构建分布

api_watchdog-0.6.0-py3-none-any.whl (15.0 kB 查看散列)

上传时间 Python 3

由以下支持