def test_model_create(self, fixture_cmd, serviceclient, payload_scenario): payload = None # If file path provided if not payload_scenario[0]: payload = payload_scenario[1] else: payload = str(read_file_content(_pnp_create_model_payload_file)) subject.iot_pnp_model_create( fixture_cmd, model_definition=payload, repo_endpoint=mock_target["entity"], repo_id=mock_target["repository_id"], ) args = serviceclient.call_args url = args[0][0].url method = args[0][0].method data = args[0][0].data headers = args[0][0].headers assert method == "PUT" assert ("{}/models/{}?".format( _repo_endpoint, url_encode_str(_pnp_generic_model_id, plus=True)) in url) assert "repositoryId={}".format(_repo_id) in url assert json.dumps(data) assert headers.get("Authorization")
def test_model_create_invalid_payload(self, serviceclient): payload = str(read_file_content(_pnp_create_model_payload_file)) payload = json.loads(payload) del payload["@id"] payload = json.dumps(payload) with pytest.raises(CLIError): subject.iot_pnp_model_create(fixture_cmd, login=mock_target["cs"], model_definition=payload)
def test_model_create_error(self, fixture_cmd, serviceclient_generic_error, payload_scenario): if not payload_scenario[0]: payload = payload_scenario[1] else: payload = str(read_file_content(_pnp_create_model_payload_file)) with pytest.raises(CLIError): subject.iot_pnp_model_create(fixture_cmd, model_definition=payload, repo_endpoint=mock_target['entity'], repo_id=mock_target['repository_id'])
def test_model_create_invalid_args(self, serviceclient, payload_scenario, exp): with pytest.raises(exp): subject.iot_pnp_model_create(fixture_cmd, model_definition=payload_scenario)