forked from infra/otc-metadata
Add some basic unittests for metadata sanity
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com> Co-authored-by: gtema <artem.goncharov@gmail.com> Co-committed-by: gtema <artem.goncharov@gmail.com>
This commit is contained in:
parent
a7a4f676e0
commit
4989570371
@ -1,3 +1,19 @@
|
||||
# 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.
|
||||
|
||||
# Please consult with otc_metadata.services.Services:_sort_data for expected
|
||||
# sort order. When unsure perform tools/sort_metadata.py for getting it sorted.
|
||||
---
|
||||
documents:
|
||||
- hc_location: api/antiddos
|
||||
html_location: docs/antiddos/api-ref
|
||||
@ -1035,6 +1051,8 @@ service_categories:
|
||||
title: Security Services
|
||||
- name: storage
|
||||
title: Storage
|
||||
- name: other
|
||||
title: Other
|
||||
services:
|
||||
- repositories:
|
||||
- environment: internal
|
||||
|
@ -21,8 +21,45 @@ Tests for `otc-metadata` module.
|
||||
|
||||
from unittest import TestCase
|
||||
|
||||
from otc_metadata import services
|
||||
|
||||
|
||||
class TestOtcMetadata(TestCase):
|
||||
def setUp(self):
|
||||
self.data = services.Services()
|
||||
|
||||
def test_something(self):
|
||||
pass
|
||||
def test_data_is_sorted(self):
|
||||
curr = self.data
|
||||
new = services.Services()
|
||||
new._sort_data()
|
||||
self.assertEqual(
|
||||
curr._service_data, new._service_data, "Data is sorted properly"
|
||||
)
|
||||
|
||||
def test_service_categories(self):
|
||||
category = dict()
|
||||
for cat in self.data._service_data["service_categories"]:
|
||||
category[cat["name"]] = cat["title"]
|
||||
for srv in self.data.all_services:
|
||||
self.assertTrue(
|
||||
srv["service_category"] in category,
|
||||
f"Category {srv['service_category']} is present",
|
||||
)
|
||||
|
||||
def test_doc_contains_required_data(self):
|
||||
srv_types = dict()
|
||||
for srv in self.data.all_services:
|
||||
srv_types[srv["service_type"]] = srv
|
||||
for doc in self.data.all_docs:
|
||||
for attr in [
|
||||
"rst_location",
|
||||
"service_type",
|
||||
"title",
|
||||
"type",
|
||||
]:
|
||||
self.assertIn(attr, doc, f"Document {doc} contains {attr}")
|
||||
self.assertIn(
|
||||
doc["service_type"],
|
||||
srv_types,
|
||||
f"Document {doc} contains valid service_type",
|
||||
)
|
||||
|
1
tox.ini
1
tox.ini
@ -19,7 +19,6 @@ commands = {posargs}
|
||||
|
||||
[flake8]
|
||||
# E123, E125 skipped as they are invalid PEP-8.
|
||||
|
||||
show-source = True
|
||||
ignore = E123,E125,W503
|
||||
builtins = _
|
||||
|
Loading…
x
Reference in New Issue
Block a user