Skip to content

Commit f51a3f4

Browse files
Adds multi_select and true_false options to CustomProperty.value_type (#3173)
Adds `multi_select` and `true_false` options for `value_type` parameter when creating custom properties. See: https://docs.github.com/en/rest/orgs/custom-properties?apiVersion=2022-11-28#create-or-update-custom-properties-for-an-organization Fixes #3172 --------- Co-authored-by: Enrico Minack <[email protected]>
1 parent e7110bf commit f51a3f4

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

github/OrganizationCustomProperty.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(
5050
):
5151
assert isinstance(property_name, str), property_name
5252
assert isinstance(value_type, str), value_type
53-
assert value_type in ["string", "single_select"], value_type
53+
assert value_type in ["string", "single_select", "multi_select", "true_false"], value_type
5454
assert is_optional(required, bool), required
5555
assert is_optional(default_value, (type(None), str, list)), default_value
5656
assert is_optional(description, (str, type(None))), description

tests/Organization.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
# Copyright 2024 Thomas Crowley <[email protected]>#
4646
# Copyright 2025 Bill Napier <[email protected]> #
4747
# Copyright 2025 Enrico Minack <[email protected]> #
48+
# Copyright 2025 Greg Fogelberg <[email protected]> #
4849
# #
4950
# This file is part of PyGithub. #
5051
# http://pygithub.readthedocs.io/ #
@@ -684,13 +685,33 @@ def testCreateCustomProperties(self):
684685
allowed_values=["foo", "bar"],
685686
values_editable_by="org_and_repo_actors",
686687
),
688+
CustomProperty(
689+
property_name="property_3",
690+
value_type="multi_select",
691+
required=True,
692+
default_value="bar",
693+
description="Lorem ipsum",
694+
allowed_values=["foo", "bar"],
695+
values_editable_by="org_and_repo_actors",
696+
),
697+
CustomProperty(
698+
property_name="property_4",
699+
value_type="true_false",
700+
required=False,
701+
description="description",
702+
values_editable_by="org_actors",
703+
),
687704
]
688705
properties = self.org.create_custom_properties(properties)
689706
properties_map = {p.property_name: p for p in properties}
690707
property_1 = properties_map["property_1"]
691708
self.assertEqual(property_1.value_type, "string")
692709
property_2 = properties_map["property_2"]
693710
self.assertEqual(property_2.description, "Lorem ipsum")
711+
property_3 = properties_map["property_3"]
712+
self.assertEqual(property_3.value_type, "multi_select")
713+
property_4 = properties_map["property_4"]
714+
self.assertEqual(property_4.value_type, "true_false")
694715

695716
def testCreateCustomProperty(self):
696717
custom_property = CustomProperty(

tests/ReplayData/Organization.testCreateCustomProperties.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ api.github.com
44
None
55
/orgs/BeaverSoftware/properties/schema
66
{'Authorization': 'token private_token_removed', 'User-Agent': 'PyGithub/Python', 'Content-Type': 'application/json'}
7-
{"properties": [{"property_name": "property_1", "value_type": "string", "required": false, "description": "description", "values_editable_by": "org_actors"}, {"property_name": "property_2", "value_type": "single_select", "required": true, "default_value": "bar", "description": "Lorem ipsum", "allowed_values": ["foo", "bar"], "values_editable_by": "org_and_repo_actors"}]}
7+
{"properties": [{"property_name": "property_1", "value_type": "string", "required": false, "description": "description", "values_editable_by": "org_actors"}, {"property_name": "property_2", "value_type": "single_select", "required": true, "default_value": "bar", "description": "Lorem ipsum", "allowed_values": ["foo", "bar"], "values_editable_by": "org_and_repo_actors"}, {"property_name": "property_3", "value_type": "multi_select", "required": true, "default_value": "bar", "description": "Lorem ipsum", "allowed_values": ["foo", "bar"], "values_editable_by": "org_and_repo_actors"}, {"property_name": "property_4", "value_type": "true_false", "required": false, "description": "description", "values_editable_by": "org_actors"}]}
88
200
99
[('Server', 'GitHub.com'), ('Date', 'Sat, 01 Jun 2024 07:33:15 GMT'), ('Content-Type', 'application/json; charset=utf-8'), ('Transfer-Encoding', 'chunked'), ('Cache-Control', 'private, max-age=60, s-maxage=60'), ('Vary', 'Accept, Authorization, Cookie, X-GitHub-OTP, Accept-Encoding, Accept, X-Requested-With'), ('ETag', 'W/"3d31331d3fa84370e751e90afbe5f289af6035258b6504dad42bb3cfd77ae983"'), ('github-authentication-token-expiration', '2024-06-08 02:45:21 +0100'), ('X-GitHub-Media-Type', 'github.v3; format=json'), ('x-accepted-github-permissions', 'organization_custom_properties=admin'), ('x-github-api-version-selected', '2022-11-28'), ('X-RateLimit-Limit', '5000'), ('X-RateLimit-Remaining', '4947'), ('X-RateLimit-Reset', '1717228808'), ('X-RateLimit-Used', '53'), ('X-RateLimit-Resource', 'core'), ('Access-Control-Expose-Headers', 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'), ('Access-Control-Allow-Origin', '*'), ('Strict-Transport-Security', 'max-age=31536000; includeSubdomains; preload'), ('X-Frame-Options', 'deny'), ('X-Content-Type-Options', 'nosniff'), ('X-XSS-Protection', '0'), ('Referrer-Policy', 'origin-when-cross-origin, strict-origin-when-cross-origin'), ('Content-Security-Policy', "default-src 'none'"), ('Content-Encoding', 'gzip'), ('X-GitHub-Request-Id', 'CGNJ:L42SB3:M0O1IW:JEHZ3G:SUHX0TC4')]
10-
[{"property_name":"property_1","value_type":"string","required":false,"description":"description","values_editable_by":"org_actors"},{"property_name":"property_2","value_type":"single_select","required":true,"default_value":"bar","description":"Lorem ipsum","allowed_values":["foo","bar"],"values_editable_by":"org_and_repo_actors"}]
10+
[{"property_name":"property_1","value_type":"string","required":false,"description":"description","values_editable_by":"org_actors"},{"property_name":"property_2","value_type":"single_select","required":true,"default_value":"bar","description":"Lorem ipsum","allowed_values":["foo","bar"],"values_editable_by":"org_and_repo_actors"},{"property_name": "property_3", "value_type": "multi_select", "required": true, "default_value": "bar", "description": "Lorem ipsum", "allowed_values": ["foo", "bar"], "values_editable_by": "org_and_repo_actors"}, {"property_name": "property_4", "value_type": "true_false", "required": false, "description": "description", "values_editable_by": "org_actors"}]

0 commit comments

Comments
 (0)