def test_config_create_edge_malformed( self, fixture_cmd2, serviceclient, sample_config_edge_malformed, config_id, hub_name, target_condition, priority, labels, ): with pytest.raises(CLIError) as exc: subject.iot_edge_deployment_create( cmd=fixture_cmd2, config_id=config_id, hub_name=hub_name, content=sample_config_edge_malformed, target_condition=target_condition, priority=priority, labels=labels, ) exception_obj = json.loads(str(exc.value)) assert "validationErrors" in exception_obj for error_element in exception_obj["validationErrors"]: assert "description" in error_element assert "contentPath" in error_element assert "schemaPath" in error_element
def test_config_create_edge( self, fixture_cmd, serviceclient, sample_config_edge, sample_config_metrics, config_id, hub_name, target_condition, priority, labels, ): subject.iot_edge_deployment_create( cmd=fixture_cmd, config_id=config_id, hub_name=hub_name, content=sample_config_edge[1], target_condition=target_condition, priority=priority, labels=labels, metrics=sample_config_metrics[1], layered=(sample_config_edge[0] == "layered"), ) args = serviceclient.call_args url = args[0][0].url method = args[0][0].method body = json.loads(args[0][0].body) assert "{}/configurations/{}?".format(hub_name, config_id.lower()) in url assert method == "PUT" assert body["id"] == config_id.lower() assert body.get("targetCondition") == target_condition assert body.get("priority") == priority assert body.get("labels") == evaluate_literal(labels, dict) if sample_config_edge[0] == "inlineB": assert ( body["content"]["modulesContent"] == json.loads(sample_config_edge[1])["modulesContent"] ) elif sample_config_edge[0] == "file": assert ( body["content"]["modulesContent"] == json.loads(read_file_content(sample_config_edge[1]))["content"][ "modulesContent" ] ) elif sample_config_edge[0] == "v1": assert ( body["content"]["modulesContent"] == json.loads(sample_config_edge[1])["content"]["moduleContent"] ) else: assert ( body["content"]["modulesContent"] == json.loads(sample_config_edge[1])["content"]["modulesContent"] ) self._assert_config_metrics_request(sample_config_metrics, body)
def test_config_create_error( self, fixture_cmd2, serviceclient_generic_error, sample_config_edge, config_id, hub_name, target_condition, priority, labels, ): with pytest.raises(CLIError): subject.iot_edge_deployment_create( cmd=fixture_cmd2, config_id=config_id, hub_name=hub_name, content=sample_config_edge[1], target_condition=target_condition, priority=priority, labels=labels, )