This commit is contained in:
Tamara Rahimi 2021-09-03 08:52:47 +00:00
Родитель 2841d7b8e9
Коммит 6892852749
5 изменённых файлов: 10 добавлений и 11 удалений

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

@ -74,8 +74,8 @@ LOGS_PATH="logs"
DEVICE_TAGS=""
# To specifiy the tags for an edge device
# Examples:
# DEVICE_TAGS="{"environment":"dev"}
# DEVICE_TAGS="{"environment":"dev", "building":"9"}
# DEVICE_TAGS="{"environment":"dev"}"
# DEVICE_TAGS="{"environment":"dev", "building":"9"}"
#

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

@ -271,7 +271,6 @@ main.add_command(deploy)
@click.option("--target-condition",
"--tc",
"-t",
"target_condition",
default=envvars.get_envvar("IOTHUB_DEPLOYMENT_TARGET_CONDITION"),
show_default=True,
required=True,
@ -281,7 +280,6 @@ main.add_command(deploy)
"This property can be set via this parameter or in the .env under 'IOTHUB_DEPLOYMENT_TARGET_CONDITION'"))
@click.option("--device-tag",
"-dt",
"device_tag",
default=envvars.get_envvar("DEVICE_TAGS"),
required=False,
help="Specify the tags to be added to the device twin")
@ -301,7 +299,7 @@ def iothub_deploy(manifest_file, name, priority, target_condition, device_tag):
@click.option("--tags",
"-t",
"tags",
required=False,
required=True,
default=envvars.get_envvar("DEVICE_TAGS"),
show_default=True,
help="Specify the tags to be added to the device twin")

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

@ -1 +0,0 @@
{}

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

@ -1,5 +1,6 @@
import os
import uuid
import json
from unittest import mock
import pytest
@ -142,13 +143,13 @@ def test_iothub_deploy_and_add_tags():
assert azure_cli.invoke_az_cli_outproc(["iot", "edge", "deployment", "delete", "-d", deployment_name, "-l", envvars.get_envvar("IOTHUB_CONNECTION_STRING")])
assert azure_cli.invoke_az_cli_outproc(["iot", "hub", "device-twin", "replace", "-d", DeviceConnectionString(envvars.get_envvar("DEVICE_CONNECTION_STRING")).device_id,
"-l", envvars.get_envvar("IOTHUB_CONNECTION_STRING"), "--json", "tag_overwrite.json"])
"-l", envvars.get_envvar("IOTHUB_CONNECTION_STRING"), "--json", json.dumps({})])
def test_iothub_deploy_and_add_tags_retry_after_invalid_tag():
# GIVEN: `iothub deploy` run fails
# WHEN: Device tag has an invalid format
# THAN: Rerunning the command will lead to a failed deploy part,
# THEN: Rerunning the command will lead to a failed deploy part,
# as the deployment already exists from the previous run,
# but it will succeed in adding the new and correct device tags.
# Leaving the iothub and device in the initially desired end state again.
@ -192,4 +193,4 @@ def test_iothub_deploy_and_add_tags_retry_after_invalid_tag():
assert azure_cli.invoke_az_cli_outproc(["iot", "edge", "deployment", "delete", "-d", deployment_name, "-l", envvars.get_envvar("IOTHUB_CONNECTION_STRING")])
assert azure_cli.invoke_az_cli_outproc(["iot", "hub", "device-twin", "replace", "-d", DeviceConnectionString(envvars.get_envvar("DEVICE_CONNECTION_STRING")).device_id,
"-l", envvars.get_envvar("IOTHUB_CONNECTION_STRING"), "--json", "tag_overwrite.json"])
"-l", envvars.get_envvar("IOTHUB_CONNECTION_STRING"), "--json", json.dumps({})])

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

@ -1,5 +1,6 @@
import os
import pytest
import json
from .utility import (
runner_invoke,
)
@ -33,7 +34,7 @@ def test_add_tags():
azure_cli = AzureCli(output, envvars)
assert azure_cli.invoke_az_cli_outproc(["iot", "hub", "device-twin", "replace", "-d", DeviceConnectionString(envvars.get_envvar("DEVICE_CONNECTION_STRING")).device_id,
"-l", envvars.get_envvar("IOTHUB_CONNECTION_STRING"), "--json", "tag_overwrite.json"])
"-l", envvars.get_envvar("IOTHUB_CONNECTION_STRING"), "--json", json.dumps({})])
@pytest.mark.parametrize(
@ -82,7 +83,7 @@ def test_default_tag_from_env():
azure_cli = AzureCli(output, envvars)
assert azure_cli.invoke_az_cli_outproc(["iot", "hub", "device-twin", "replace", "-d", DeviceConnectionString(envvars.get_envvar("DEVICE_CONNECTION_STRING")).device_id,
"-l", envvars.get_envvar("IOTHUB_CONNECTION_STRING"), "--json", "tag_overwrite.json"])
"-l", envvars.get_envvar("IOTHUB_CONNECTION_STRING"), "--json", json.dumps({})])
def test_missing_default_tag_from_env():