Skip to content

Commit 8387279

Browse files
committed
feat: Make it valid for ORGS, LABELS, and PEOPLE to be empty
part of openedx/openedx-webhooks#218
1 parent f857602 commit 8387279

File tree

3 files changed

+71
-54
lines changed

3 files changed

+71
-54
lines changed

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ Change Log
99
1010
This project adheres to Semantic Versioning (https://semver.org/).
1111

12+
13+
2023-05-30
14+
~~~~~~~~~~
15+
16+
* Make it valid for ORGS, LABELS, and PEOPLE to be empty. This was prompted
17+
because we actually want LABELS to be empty as an intermediate step towards
18+
removing label creation from openedx-webhooks.
19+
1220
2023-03-02
1321
~~~~~~~~~~
1422

repo_tools_data_schema/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
Schema for repo-tools-data.
33
"""
44

5-
__version__ = '1.0'
5+
__version__ = '1.1'
66

77
from .repo_tools_data_schema import validate_labels, validate_orgs, validate_people, validate_salesforce_export

repo_tools_data_schema/repo_tools_data_schema.py

Lines changed: 62 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -140,52 +140,58 @@ def _check(d):
140140
)
141141

142142
PEOPLE_SCHEMA = Schema(
143-
{
144-
And(github_username, not_data_key): And(
145-
{
146-
'name': not_empty_string,
147-
'email': valid_email,
148-
'agreement': valid_agreement,
149-
Optional('institution'): not_empty_string,
150-
Optional('is_robot'): True,
151-
Optional('jira'): not_empty_string,
152-
Optional('comments'): [str],
153-
Optional('other_emails'): [valid_email],
154-
Optional('before'): {
155-
datetime.date: And(
156-
{
157-
Optional('agreement'): valid_agreement,
158-
Optional('institution'): not_empty_string,
159-
Optional('comments'): [str],
160-
Optional('committer'): COMMITTER_SCHEMA,
161-
},
162-
check_institution,
163-
),
143+
Or(
144+
{
145+
And(github_username, not_data_key): And(
146+
{
147+
'name': not_empty_string,
148+
'email': valid_email,
149+
'agreement': valid_agreement,
150+
Optional('institution'): not_empty_string,
151+
Optional('is_robot'): True,
152+
Optional('jira'): not_empty_string,
153+
Optional('comments'): [str],
154+
Optional('other_emails'): [valid_email],
155+
Optional('before'): {
156+
datetime.date: And(
157+
{
158+
Optional('agreement'): valid_agreement,
159+
Optional('institution'): not_empty_string,
160+
Optional('comments'): [str],
161+
Optional('committer'): COMMITTER_SCHEMA,
162+
},
163+
check_institution,
164+
),
165+
},
166+
Optional('beta'): bool,
167+
Optional('contractor'): bool,
168+
Optional('committer'): COMMITTER_SCHEMA,
169+
Optional('email_ok'): bool,
164170
},
165-
Optional('beta'): bool,
166-
Optional('contractor'): bool,
167-
Optional('committer'): COMMITTER_SCHEMA,
168-
Optional('email_ok'): bool,
169-
},
170-
check_institution,
171-
),
172-
}
171+
check_institution,
172+
),
173+
},
174+
{},
175+
),
173176
)
174177

175178
ORGS_SCHEMA = Schema(
176-
{
177-
str: {
178-
Optional("name"): not_empty_string,
179-
"agreement": Or("institution", "none"),
180-
Optional("contractor"): bool,
181-
Optional("committer"): bool,
182-
Optional("internal-ghorgs"): [str],
183-
Optional(Or("contact", "contact1", "contact2")): {
184-
"name": not_empty_string,
185-
"email": valid_email,
179+
Or(
180+
{
181+
str: {
182+
Optional("name"): not_empty_string,
183+
"agreement": Or("institution", "none"),
184+
Optional("contractor"): bool,
185+
Optional("committer"): bool,
186+
Optional("internal-ghorgs"): [str],
187+
Optional(Or("contact", "contact1", "contact2")): {
188+
"name": not_empty_string,
189+
"email": valid_email,
190+
},
186191
},
187192
},
188-
}
193+
{},
194+
)
189195
)
190196

191197

@@ -194,19 +200,22 @@ def color(s):
194200

195201

196202
LABELS_SCHEMA = Schema(
197-
{
198-
str: Or(
199-
# A label we don't want:
200-
{
201-
"delete": True,
202-
},
203-
# A label we want:
204-
{
205-
"color": color,
206-
Optional("description"): str,
207-
},
208-
),
209-
},
203+
Or(
204+
{
205+
str: Or(
206+
# A label we don't want:
207+
{
208+
"delete": True,
209+
},
210+
# A label we want:
211+
{
212+
"color": color,
213+
Optional("description"): str,
214+
},
215+
),
216+
},
217+
{},
218+
),
210219
)
211220

212221

0 commit comments

Comments
 (0)