adding Swisscloud content metadata
This commit is contained in:
0
otc_metadata/tests/__init__.py
Normal file
0
otc_metadata/tests/__init__.py
Normal file
65
otc_metadata/tests/test_otc_metadata.py
Normal file
65
otc_metadata/tests/test_otc_metadata.py
Normal file
@ -0,0 +1,65 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# 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.
|
||||
|
||||
"""
|
||||
test_otc-metadata
|
||||
----------------------------------
|
||||
|
||||
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_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",
|
||||
)
|
Reference in New Issue
Block a user