MCPcopy Index your code
hub / github.com/Flagsmith/flagsmith / create_feature_with_api

Function create_feature_with_api

api/tests/integration/helpers.py:12–42  ·  view source on GitHub ↗

Create a feature against the API using the provided test client. :param client: DRF api client to use to make the request :param feature_name: Name of the feature to create :param initial_value: Initial value to give the feature :param multivariate_options: List of 2-tuples con

(
    client: APIClient,
    project_id: int,
    feature_name: str,
    initial_value: str,
    feature_type: str = STANDARD,
)

Source from the content-addressed store, hash-verified

10
11
12def create_feature_with_api(
13 client: APIClient,
14 project_id: int,
15 feature_name: str,
16 initial_value: str,
17 feature_type: str = STANDARD,
18) -> int:
19 """
20 Create a feature against the API using the provided test client.
21
22 :param client: DRF api client to use to make the request
23 :param feature_name: Name of the feature to create
24 :param initial_value: Initial value to give the feature
25 :param multivariate_options: List of 2-tuples containing the string value and percentage allocation
26 :return: id of the created feature
27 """
28 create_feature_url = reverse(
29 "api-v1:projects:project-features-list", args=[project_id]
30 )
31 create_standard_feature_data = {
32 "name": feature_name,
33 "type": feature_type,
34 "initial_value": initial_value,
35 "default_enabled": True,
36 }
37 create_standard_feature_response = client.post(
38 create_feature_url,
39 data=json.dumps(create_standard_feature_data),
40 content_type="application/json",
41 )
42 return create_standard_feature_response.json()["id"] # type: ignore[no-any-return]
43
44
45def create_mv_option_with_api(

Calls 3

reverseFunction · 0.50
postMethod · 0.45
jsonMethod · 0.45