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

fix: make clone_feature_states_async write only #4811

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions api/environments/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class CloneEnvironmentSerializer(EnvironmentSerializerLight):
help_text="If True, the environment will be created immediately, but the feature states "
"will be created asynchronously. Environment will have `is_creating: true` until "
"this process is completed.",
write_only=True,
)

class Meta:
Expand Down
13 changes: 10 additions & 3 deletions api/tests/integration/environments/test_clone_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
[lazy_fixture("admin_master_api_key_client"), lazy_fixture("admin_client")],
)
def test_clone_environment_clones_feature_states_with_value(
client, project, environment, environment_api_key, feature
client: APIClient,
project: int,
environment: int,
environment_api_key: str,
feature: int,
):
# Firstly, let's update feature state value of the source environment
# fetch the feature state id to update
Expand All @@ -43,11 +47,14 @@ def test_clone_environment_clones_feature_states_with_value(
# Now, clone the environment
env_name = "Cloned env"
url = reverse("api-v1:environments:environment-clone", args=[environment_api_key])
res = client.post(url, {"name": env_name})
res = client.post(url, {"name": env_name, "clone_feature_states_async": False})

# Then, check that the clone was successful
assert res.status_code == status.HTTP_200_OK

# And check that the write only field wasn't returned
assert "clone_feature_states_async" not in res.json()

# Now, fetch the feature states of the source environment
source_env_feature_states = get_env_feature_states_list_with_api(
client, {"environment": environment}
Expand All @@ -58,7 +65,7 @@ def test_clone_environment_clones_feature_states_with_value(
client, {"environment": res.json()["id"]}
)

# Finaly, compare the responses
# Finally, compare the responses
assert source_env_feature_states["count"] == 1
assert (
source_env_feature_states["results"][0]["id"]
Expand Down
Loading