def test_taxonomy(self): tax = taxonomy.Taxonomy() self.assertIsInstance(tax, taxonomy.Taxonomy) self.assertIsInstance(tax.semantic, taxonomy_semantic.TaxonomySemantic) self.assertIsInstance(tax.types, taxonomy_types.TaxonomyTypes) self.assertIsInstance(tax.units, taxonomy_units.TaxonomyUnits) self.assertIsInstance(tax.numeric_types, taxonomy_misc.TaxonomyNumericTypes) self.assertIsInstance(tax.generic_roles, taxonomy_misc.TaxonomyGenericRoles) self.assertIsInstance(tax.ref_parts, taxonomy_misc.TaxonomyRefParts) self.assertIsInstance(tax.documentation, taxonomy_misc.TaxonomyDocumentation)
# 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. import unittest from oblib import identifier, taxonomy, validator tax = taxonomy.Taxonomy() validator = validator.Validator(tax) class TestValidator(unittest.TestCase): def test_validate_concept_value(self): concept = taxonomy.ConceptDetails() concept.id = "SomeId" concept.nillable = False self.assertEqual(1, len(validator.validate_concept_value(concept, None)[1])) concept.nillable = True self.assertEqual(0, len(validator.validate_concept_value(concept, None)[1])) concept.type_name = "xbrli:booleanItemType" self.assertEqual(1, len(validator.validate_concept_value(concept, "Arf")[1])) self.assertEqual(1, len(validator.validate_concept_value(concept, 52)[1]))
# 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. import unittest from six import string_types from oblib import taxonomy taxonomy_obj = taxonomy.Taxonomy() tax = taxonomy_obj.semantic class TestTaxonomySemantic(unittest.TestCase): def test_concept_details(self): # Data type checks ci = tax.get_concept_details("solar:ACDisconnectSwitchMember") self.assertIsNotNone(ci) self.assertIsInstance(ci.abstract, bool) self.assertIsInstance(ci.id, string_types) # 'six.string_types' is equivalent to "str or unicode" in python2, "str" in python3 self.assertIsInstance(ci.name, string_types) self.assertIsInstance(ci.nillable, bool) self.assertIsInstance(ci.period_independent, bool)
from oblib.parser import Parser, FileFormat INFO = """ This the CLI for the Orange Button Core library. Information is available at the following URL's: Orange Button Overview: https://sunspec.org/orange-button-initiative/ Orange Button GitHUb: https://github.com/SunSpecOrangeButton Orange Button pyoblib and CLI GitHub: https://github.com/SunSpecOrangeButton/pyoblib """ DASHES = "---------------------------------------------------------------------------------------" taxonomy = taxonomy.Taxonomy() csv = False json = False xml = False def info(args): print(INFO) def convert(args): p = Parser(taxonomy) ff = None if json: