Make the schema of default_data hard-coded
default_data.schema.json can be used for checking the config file default_data.json. The check will be able to block an error on stackalytics-processor internally. The schema should not exist as a config file, so this patch makes the schema hard-coded. NOTE: The copyright of schema.py comes from the initial version of default_data.schema.json: I7b5104b25fecc6a7da7c025bf48f72885c1fbebc Change-Id: Ia98c6d9ce2cec3bac80ff9159f854b1a65b6a4d8
This commit is contained in:
parent
0622fbaa77
commit
7a94c9eeee
@ -1,4 +1,19 @@
|
|||||||
{
|
# Copyright (c) 2013 Mirantis Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
# implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
default_data = {
|
||||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": ["users", "releases", "companies", "repos", "project_types"],
|
"required": ["users", "releases", "companies", "repos", "project_types"],
|
||||||
@ -31,7 +46,8 @@
|
|||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"pattern": "^[a-z\\d_\\.\\+-]+@([a-z\\d\\.-]+\\.)*(([a-z]+)|\\(none\\))$"
|
"pattern": ("^[a-z\\d_\\.\\+-]+@([a-z\\d\\.-]+\\.)"
|
||||||
|
"*(([a-z]+)|\\(none\\))$")
|
||||||
},
|
},
|
||||||
"minItems": 1
|
"minItems": 1
|
||||||
},
|
},
|
||||||
@ -48,13 +64,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["company_name", "end_date"],
|
"required": ["company_name", "end_date"],
|
||||||
"additionalProperties": false
|
"additionalProperties": False
|
||||||
},
|
},
|
||||||
"minItems": 1
|
"minItems": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["user_name", "emails"],
|
"required": ["user_name", "emails"],
|
||||||
"additionalProperties": false
|
"additionalProperties": False
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"releases": {
|
"releases": {
|
||||||
@ -73,7 +89,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["release_name", "end_date"],
|
"required": ["release_name", "end_date"],
|
||||||
"additionalProperties": false
|
"additionalProperties": False
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"repos": {
|
"repos": {
|
||||||
@ -122,7 +138,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["uri", "module", "organization"],
|
"required": ["uri", "module", "organization"],
|
||||||
"additionalProperties": false
|
"additionalProperties": False
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"companies": {
|
"companies": {
|
||||||
@ -148,7 +164,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["company_name", "domains"],
|
"required": ["company_name", "domains"],
|
||||||
"additionalProperties": false
|
"additionalProperties": False
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"project_sources": {
|
"project_sources": {
|
||||||
@ -185,7 +201,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["organization"],
|
"required": ["organization"],
|
||||||
"additionalProperties": false
|
"additionalProperties": False
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"module_groups": {
|
"module_groups": {
|
||||||
@ -205,7 +221,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["module_group_name", "modules"],
|
"required": ["module_group_name", "modules"],
|
||||||
"additionalProperties": false
|
"additionalProperties": False
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mail_lists": {
|
"mail_lists": {
|
||||||
@ -244,14 +260,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["id", "title", "modules"],
|
"required": ["id", "title", "modules"],
|
||||||
"additionalProperties": false
|
"additionalProperties": False
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"date_format": {
|
"date_format": {
|
||||||
"type": ["string", "null"],
|
"type": ["string", "null"],
|
||||||
"pattern": "^20\\d{2}-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-[0-3]\\d$"
|
"pattern": ("^20\\d{2}-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|"
|
||||||
|
"Nov|Dec)-[0-3]\\d$")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -23,6 +23,7 @@ import six
|
|||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from stackalytics.processor import normalizer
|
from stackalytics.processor import normalizer
|
||||||
|
from stackalytics.processor import schema as coded_schema
|
||||||
|
|
||||||
|
|
||||||
IGNORED_COMPANIES = ['*robots', 'April', 'Chelsio Communications',
|
IGNORED_COMPANIES = ['*robots', 'April', 'Chelsio Communications',
|
||||||
@ -97,9 +98,8 @@ class TestConfigFiles(testtools.TestCase):
|
|||||||
|
|
||||||
def _verify_default_data_by_schema(self, file_name):
|
def _verify_default_data_by_schema(self, file_name):
|
||||||
default_data = self._read_file(file_name)
|
default_data = self._read_file(file_name)
|
||||||
schema = self._read_file('etc/default_data.schema.json')
|
|
||||||
try:
|
try:
|
||||||
jsonschema.validate(default_data, schema)
|
jsonschema.validate(default_data, coded_schema.default_data)
|
||||||
except jsonschema.ValidationError as e:
|
except jsonschema.ValidationError as e:
|
||||||
self.fail(e)
|
self.fail(e)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user