Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/927 add env settings #4603

Closed
wants to merge 29 commits into from
Closed
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion tests/server/test_env_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
Contact: code@inmanta.com
"""
from typing import Dict
from uuid import UUID

import pytest

from inmanta import data
from inmanta.data import Setting, convert_boolean
from inmanta.data import BaseDocument, Environment, Setting, convert_boolean
from inmanta.util import get_compiler_version


Expand Down Expand Up @@ -358,3 +359,19 @@ async def test_environment_add_new_setting_parameter(server, client, environment
result = await client.get_setting(tid=environment, id=data.AUTO_DEPLOY)
assert result.code == 200
assert result.result["value"] is False


async def test_get_setting_no_longer_exist(server, client, environment):
"""
Test what happens when a setting exists in the database for which the definition no longer exists
"""
env_id = UUID(environment)
env = await data.Environment.get_by_id(env_id)
project_id = env.project
setting_db_query = "UPDATE environment SET settings=jsonb_set(settings, $1::text[], to_jsonb($2::boolean), TRUE) WHERE name=$3 AND project=$4"
values = [["a new setting"], True, "dev", project_id]
await Environment._execute_query(setting_db_query, *values)

result = await client.get_setting(tid=environment, id="a new setting")
assert result.code == 404
assert result.result["message"] == "Request or referenced resource does not exist"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also verify it is not returned by a listing either and that if you register the option, it is returned by both?