зеркало из https://github.com/Azure/iotedgedev.git
Merge pull request #503 from MahrRah/feature/test-cli-command-structure
Add cli structure test
This commit is contained in:
Коммит
b237107c2c
|
@ -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()}
|
||||
|
|
Загрузка…
Ссылка в новой задаче