File: test_command.py

package info (click to toggle)
flask-openapi3 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,976 kB
  • sloc: python: 4,754; sh: 17; makefile: 15; javascript: 5
file content (32 lines) | stat: -rw-r--r-- 661 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# -*- coding: utf-8 -*-
# @Author  : llc
# @Time    : 2024/7/3 9:44
import os

import pytest

from flask_openapi3 import OpenAPI
from flask_openapi3.commands import openapi_command


@pytest.fixture
def app():
    app = OpenAPI(__name__)
    return app


@pytest.fixture
def cli_runner(app):
    return app.test_cli_runner()


def test_openapi_command(app, cli_runner):
    result = cli_runner.invoke(openapi_command, ("--output", "test.json"))
    os.remove("test.json")

    assert result.exit_code == 0
    assert "Saved to test.json." in result.output

    result = cli_runner.invoke(openapi_command, ("--format", "yaml"))

    assert result.exit_code == 0