Skip to content

Commit

Permalink
fix: make clone_feature_states_async write only (#4811)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewelwell authored Nov 7, 2024
1 parent 2a7e734 commit 513b088
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
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

0 comments on commit 513b088

Please sign in to comment.