Ppchelko has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/364809 )
Change subject: Fix up tests and adapt schemas.
......................................................................
Fix up tests and adapt schemas.
We have tests that verify that all the schemas contain
some common properties for their specific type of schema.
The tests were broken, now they are fixed and the schemas
are adapted to pass the tests.
Change-Id: If432630d3e013fac5ed8dc2da45b045055725a98
---
M jsonschema/mediawiki/job/1.yaml
M test/jsonschema/index.js
D test/jsonschema/mediawiki/mediawiki_common_schema.yaml
M test/jsonschema/mediawiki/page/page_common_schema.yaml
M test/jsonschema/mediawiki/revision/revision_common_schema.yaml
M test/jsonschema/mediawiki/user/user_common_schema.yaml
6 files changed, 106 insertions(+), 48 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/event-schemas
refs/changes/09/364809/1
diff --git a/jsonschema/mediawiki/job/1.yaml b/jsonschema/mediawiki/job/1.yaml
index 4e375f5..630df4a 100644
--- a/jsonschema/mediawiki/job/1.yaml
+++ b/jsonschema/mediawiki/job/1.yaml
@@ -44,6 +44,10 @@
- dt
- domain
+ database:
+ description: The name of the wiki database this event belongs to.
+ type: string
+
type:
description: type of the job
type: string
@@ -87,6 +91,7 @@
required:
- meta
+ - database
- type
- page_namespace
- page_title
\ No newline at end of file
diff --git a/test/jsonschema/index.js b/test/jsonschema/index.js
index 4b33a85..c3d1e07 100644
--- a/test/jsonschema/index.js
+++ b/test/jsonschema/index.js
@@ -35,12 +35,7 @@
// Go recursively
return Object.keys(example)
.filter((key) => key !== 'title' && key !== 'description')
- .forEach((key) => {
- if (example.required.indexOf(key) !== -1
- || schema.required.indexOf(key) !== -1) {
- assert.isSuperSchema(schema[key], example[key], path + '.' +
key)
- }
- });
+ .forEach((key) => assert.isSuperSchema(schema[key], example[key], path
+ '.' + key));
} else if (schema !== example) {
throw new assert.AssertionError({
message: `Error at path: ${path}`,
diff --git a/test/jsonschema/mediawiki/mediawiki_common_schema.yaml
b/test/jsonschema/mediawiki/mediawiki_common_schema.yaml
deleted file mode 100644
index 9813e5c..0000000
--- a/test/jsonschema/mediawiki/mediawiki_common_schema.yaml
+++ /dev/null
@@ -1,41 +0,0 @@
-title: Mediawiki Common Schema
-description: Used to validate that all mediawiki events have common properties
-$schema: http://json-schema.org/draft-04/schema#
-type: object
-properties:
- ### Mediawiki entity fields. All Mediawiki entity events should have these.
- database:
- type: string
-
- performer:
- type: object
- properties:
- user_id:
- type: integer
- user_text:
- type: string
- user_groups:
- type: array
- items:
- type: string
- user_is_bot:
- type: boolean
- user_registration_dt:
- description: >
- The datetime of the user account registration.
- Not present for anonymous users or if missing in the MW database.
- type: string
- format: date-time
- user_edit_count:
- description: >
- The number of edits this user has made at the time this revision is
created.
- Not present for anonymous users.
- type: integer
- minimum: 0
- required:
- - user_text
- - user_groups
- - user_is_bot
-
-required:
- - database
diff --git a/test/jsonschema/mediawiki/page/page_common_schema.yaml
b/test/jsonschema/mediawiki/page/page_common_schema.yaml
index 0ce9d70..ae5f6eb 100644
--- a/test/jsonschema/mediawiki/page/page_common_schema.yaml
+++ b/test/jsonschema/mediawiki/page/page_common_schema.yaml
@@ -3,9 +3,42 @@
$schema: http://json-schema.org/draft-04/schema#
type: object
properties:
+ database:
+ type: string
+
+ performer:
+ type: object
+ properties:
+ user_id:
+ type: integer
+ user_text:
+ type: string
+ user_groups:
+ type: array
+ items:
+ type: string
+ user_is_bot:
+ type: boolean
+ user_registration_dt:
+ description: >
+ The datetime of the user account registration.
+ Not present for anonymous users or if missing in the MW database.
+ type: string
+ format: date-time
+ user_edit_count:
+ description: >
+ The number of edits this user has made at the time this revision is
created.
+ Not present for anonymous users.
+ type: integer
+ minimum: 0
+ required:
+ - user_text
+ - user_groups
+ - user_is_bot
+
page_id:
type: integer
- minimum: 1
+ # minimum: 1 It's different for the page-restriction-change schema.
page_title:
type: string
diff --git a/test/jsonschema/mediawiki/revision/revision_common_schema.yaml
b/test/jsonschema/mediawiki/revision/revision_common_schema.yaml
index f677ac6..6574d27 100644
--- a/test/jsonschema/mediawiki/revision/revision_common_schema.yaml
+++ b/test/jsonschema/mediawiki/revision/revision_common_schema.yaml
@@ -3,6 +3,39 @@
$schema: http://json-schema.org/draft-04/schema#
type: object
properties:
+ database:
+ type: string
+
+ performer:
+ type: object
+ properties:
+ user_id:
+ type: integer
+ user_text:
+ type: string
+ user_groups:
+ type: array
+ items:
+ type: string
+ user_is_bot:
+ type: boolean
+ user_registration_dt:
+ description: >
+ The datetime of the user account registration.
+ Not present for anonymous users or if missing in the MW database.
+ type: string
+ format: date-time
+ user_edit_count:
+ description: >
+ The number of edits this user has made at the time this revision is
created.
+ Not present for anonymous users.
+ type: integer
+ minimum: 0
+ required:
+ - user_text
+ - user_groups
+ - user_is_bot
+
### revision entity fields - all revision related events should have these.
page_id:
type: integer
diff --git a/test/jsonschema/mediawiki/user/user_common_schema.yaml
b/test/jsonschema/mediawiki/user/user_common_schema.yaml
index 43bded3..e45f4a9 100644
--- a/test/jsonschema/mediawiki/user/user_common_schema.yaml
+++ b/test/jsonschema/mediawiki/user/user_common_schema.yaml
@@ -3,6 +3,39 @@
$schema: http://json-schema.org/draft-04/schema#
type: object
properties:
+ database:
+ type: string
+
+ performer:
+ type: object
+ properties:
+ user_id:
+ type: integer
+ user_text:
+ type: string
+ user_groups:
+ type: array
+ items:
+ type: string
+ user_is_bot:
+ type: boolean
+ user_registration_dt:
+ description: >
+ The datetime of the user account registration.
+ Not present for anonymous users or if missing in the MW database.
+ type: string
+ format: date-time
+ user_edit_count:
+ description: >
+ The number of edits this user has made at the time this revision is
created.
+ Not present for anonymous users.
+ type: integer
+ minimum: 0
+ required:
+ - user_text
+ - user_groups
+ - user_is_bot
+
### user entity fields - all user related events should have these.
user_id:
type: integer
--
To view, visit https://gerrit.wikimedia.org/r/364809
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If432630d3e013fac5ed8dc2da45b045055725a98
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/event-schemas
Gerrit-Branch: master
Gerrit-Owner: Ppchelko <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits