Merge pull request #503 from MahrRah/feature/test-cli-command-structure

Add cli structure test
This commit is contained in:
Eliise 2021-09-06 10:07:20 +02:00 коммит произвёл GitHub
Родитель 99d0f8b78c c211acd951
Коммит b237107c2c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 62 добавлений и 0 удалений

55
tests/test_cli.py Normal file
Просмотреть файл

@ -0,0 +1,55 @@
from iotedgedev.cli import main
from .utility import get_cli_command_structure
import pytest
pytestmark = pytest.mark.unit
def test_cli_structure():
# Arrange
expected_structure = {
"solution": {
"new": None,
"init": None,
"e2e": None,
"add": None,
"build": None,
"push": None,
"deploy": None,
"tag": None,
"genconfig": None
},
"simulator": {
"setup": None,
"start": None,
"stop": None,
"modulecred": None
},
"iothub": {
"deploy": None,
"monitor": None,
"setup": None
},
"docker": {
"setup": None,
"clean": None,
"log": None
},
"new": None,
"init": None,
"add": None,
"build": None,
"push": None,
"deploy": None,
"genconfig": None,
"setup": None,
"start": None,
"stop": None,
"monitor": None,
"log": None
}
# Act
structure = get_cli_command_structure(main)
# Assert
assert structure == expected_structure

Просмотреть файл

@ -3,6 +3,7 @@ import re
import subprocess
import sys
import click
from click.testing import CliRunner
from iotedgedev.dockercls import Docker
from iotedgedev.envvars import EnvVars
@ -123,3 +124,9 @@ def get_file_content(file_path):
content = f.read()
return content
def get_cli_command_structure(obj):
if isinstance(obj, click.Group):
return {name: get_cli_command_structure(value)
for name, value in obj.commands.items()}