|
45 | 45 | from environments.permissions.models import UserEnvironmentPermission |
46 | 46 | from features import views |
47 | 47 | from features.dataclasses import EnvironmentFeatureOverridesData |
48 | | -from features.feature_types import MULTIVARIATE |
| 48 | +from features.feature_types import MULTIVARIATE, STANDARD |
49 | 49 | from features.models import Feature, FeatureSegment, FeatureState |
50 | 50 | from features.multivariate.models import MultivariateFeatureOption |
51 | 51 | from features.value_types import STRING |
@@ -1816,8 +1816,8 @@ def test_audit_log_created_when_feature_updated( |
1816 | 1816 | args=[project.id, feature.id], |
1817 | 1817 | ) |
1818 | 1818 | data = { |
1819 | | - "name": "Test Feature updated", |
1820 | | - "type": "FLAG", |
| 1819 | + "name": feature.name, |
| 1820 | + "description": "Updated description", |
1821 | 1821 | "project": project.id, |
1822 | 1822 | } |
1823 | 1823 |
|
@@ -4488,3 +4488,42 @@ def test_list_features__edge_v2_project__makes_one_dynamo_query( |
4488 | 4488 | # Validate that only a single query is made to dynamodb, not one |
4489 | 4489 | # per feature. |
4490 | 4490 | assert mock_table.query.call_count == 1 |
| 4491 | + |
| 4492 | + |
| 4493 | +def test_create_feature__type_provided__ignores_type_and_defaults_to_standard( |
| 4494 | + admin_client_new: APIClient, |
| 4495 | + project: Project, |
| 4496 | +) -> None: |
| 4497 | + # Given |
| 4498 | + url = reverse("api-v1:projects:project-features-list", args=[project.id]) |
| 4499 | + data = {"name": "test_feature_type_readonly", "type": "boolean"} |
| 4500 | + |
| 4501 | + # When |
| 4502 | + response = admin_client_new.post( |
| 4503 | + url, data=json.dumps(data), content_type="application/json" |
| 4504 | + ) |
| 4505 | + |
| 4506 | + # Then |
| 4507 | + assert response.status_code == status.HTTP_201_CREATED |
| 4508 | + assert response.json()["type"] == STANDARD |
| 4509 | + |
| 4510 | + |
| 4511 | +def test_create_feature__multivariate_options_provided__sets_type_to_multivariate( |
| 4512 | + admin_client_new: APIClient, |
| 4513 | + project: Project, |
| 4514 | +) -> None: |
| 4515 | + # Given |
| 4516 | + url = reverse("api-v1:projects:project-features-list", args=[project.id]) |
| 4517 | + data = { |
| 4518 | + "name": "test_feature_mv_type", |
| 4519 | + "multivariate_options": [{"type": "unicode", "string_value": "option-a"}], |
| 4520 | + } |
| 4521 | + |
| 4522 | + # When |
| 4523 | + response = admin_client_new.post( |
| 4524 | + url, data=json.dumps(data), content_type="application/json" |
| 4525 | + ) |
| 4526 | + |
| 4527 | + # Then |
| 4528 | + assert response.status_code == status.HTTP_201_CREATED |
| 4529 | + assert response.json()["type"] == MULTIVARIATE |
0 commit comments