testing - 需要在 .yaml 文件中带上实际日期

标签 testing tavern

我正在使用“tavern”来测试 Django API rest。我在这个库中很新,我不知道我的问题是否可行,但需要第二个标题中的日期属性,带上当前日期而不是硬编码日期。

这可能吗?

stages:
  - name: login
    request:
      url: http//......
      json:
        email: email
        password: pass
      method: POST
      headers:
        content-type: application/json
    response:
      status_code: 200
      body:
        {
          "refresh": refresh token
          "access": access token
          "id": 1,
          "username": username,
          "email": email,
          "first_name": name,
          "last_name": last,
          "group": group,
          "manager": null,
          "profile_photo": photo
        } 
      headers:
        content-type: application/json
        Allow: GET, POST, HEAD, OPTIONS
        Content-Type: application/json
        Vary: Accept
        x-frame-options: SAMEORIGIN 
        connection: close 
        server: Werkzeug/0.12.2 Python/3.6.2
        date: { here is the field }

最佳答案

可能的解决方案是在顶部写下以下行

strict: False

这将允许您评估或不评估哪些属性

关于testing - 需要在 .yaml 文件中带上实际日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58064546/

相关文章:

Mysql显示不超过5个并发连接

unit-testing - 试图获得对 TDD 好处的信心

python - "ValueError: expected ' : ' after conversion specifier" when trying to authorise on site with x-api-key

python - 如何将响应值保存到酒馆中的变量?

python - 关于 yaml 架构验证的错误(此处不允许映射值)是什么意思?

java - JUnit 4 预期异常类型

python - 在 Django 中测试外部 URL

javascript - 如何仅在先前的异步测试通过后才运行 mocha 测试?

python - pytest-cov 在 Tavern 测试中始终显示 0 覆盖率