@@ -648,7 +648,7 @@ def test_create_feature_only_triggers_write_to_dynamodb_once_per_environment(
648648 project .save ()
649649
650650 url = reverse ("api-v1:projects:project-features-list" , args = [project .id ])
651- data = {"name" : "Test feature flag" , "type" : "FLAG" , "project" : project .id }
651+ data = {"name" : "Test feature flag" , "type" : STANDARD , "project" : project .id }
652652
653653 mock_dynamo_environment_wrapper .is_enabled = True
654654 mock_dynamo_environment_wrapper .reset_mock ()
@@ -1748,7 +1748,7 @@ def test_create_feature_returns_201_if_name_matches_regex(
17481748 feature_name = "valid_feature_name"
17491749
17501750 url = reverse ("api-v1:projects:project-features-list" , args = [project .id ])
1751- data = {"name" : feature_name , "type" : "FLAG" , "project" : project .id }
1751+ data = {"name" : feature_name , "type" : STANDARD , "project" : project .id }
17521752
17531753 # When
17541754 response = admin_client_new .post (url , data = data )
@@ -1766,7 +1766,7 @@ def test_create_feature_returns_400_if_name_does_not_matches_regex(
17661766 feature_name = "not_a_valid_feature_name"
17671767
17681768 url = reverse ("api-v1:projects:project-features-list" , args = [project .id ])
1769- data = {"name" : feature_name , "type" : "FLAG" , "project" : project .id }
1769+ data = {"name" : feature_name , "type" : STANDARD , "project" : project .id }
17701770
17711771 # When
17721772 response = admin_client_new .post (url , data = data )
@@ -1784,7 +1784,7 @@ def test_audit_log_created_when_feature_created(
17841784) -> None :
17851785 # Given
17861786 url = reverse ("api-v1:projects:project-features-list" , args = [project .id ])
1787- data = {"name" : "Test feature flag" , "type" : "FLAG" , "project" : project .id }
1787+ data = {"name" : "Test feature flag" , "type" : STANDARD , "project" : project .id }
17881788
17891789 # When
17901790 response = admin_client_new .post (url , data = data )
@@ -4490,22 +4490,34 @@ def test_list_features__edge_v2_project__makes_one_dynamo_query(
44904490 assert mock_table .query .call_count == 1
44914491
44924492
4493- def test_create_feature__type_provided__ignores_type_and_defaults_to_standard (
4493+ @pytest .mark .parametrize (
4494+ "feature_type, expected_status" ,
4495+ [
4496+ (STANDARD , status .HTTP_201_CREATED ),
4497+ (MULTIVARIATE , status .HTTP_201_CREATED ),
4498+ ("boolean" , status .HTTP_400_BAD_REQUEST ),
4499+ ("FLAG" , status .HTTP_400_BAD_REQUEST ),
4500+ ],
4501+ )
4502+ def test_create_feature__type_provided__validates_and_sets_type (
44944503 admin_client_new : APIClient ,
44954504 project : Project ,
4505+ feature_type : str ,
4506+ expected_status : int ,
44964507) -> None :
44974508 # Given
44984509 url = reverse ("api-v1:projects:project-features-list" , args = [project .id ])
4499- data = {"name" : "test_feature_type_readonly " , "type" : "boolean" }
4510+ data = {"name" : f"test_feature_ { feature_type } " , "type" : feature_type }
45004511
45014512 # When
45024513 response = admin_client_new .post (
45034514 url , data = json .dumps (data ), content_type = "application/json"
45044515 )
45054516
45064517 # Then
4507- assert response .status_code == status .HTTP_201_CREATED
4508- assert response .json ()["type" ] == STANDARD
4518+ assert response .status_code == expected_status
4519+ if expected_status == status .HTTP_201_CREATED :
4520+ assert response .json ()["type" ] == feature_type
45094521
45104522
45114523def test_create_feature__multivariate_options_provided__sets_type_to_multivariate (
0 commit comments