Ejemplo n.º 1
0
 def testValidateOneBuildingExistFails(self):
   with self.assertRaises(SyntaxError):
     # there is missing building type in the test file
     input_file = os.path.join(_TESTCASE_PATH, 'GOOD', 'good_links.yaml')
     args = ['--input', input_file]
     instance_handler = handler.ValidationHelper(args)
     instance_handler.Validate()
Ejemplo n.º 2
0
 def testValidateOneBuildingExistFails(self):
     with self.assertRaises(SyntaxError):
         input_file = path.join(_TESTCASE_PATH, 'BAD',
                                'bad_missing_building.yaml')
         args = ['--input', input_file]
         instance_handler = handler.ValidationHelper(args)
         instance_handler.Validate()
Ejemplo n.º 3
0
 def testTelemetryArgsMissingServiceAccount(self):
     with self.assertRaises(SystemExit):
         input_file = path.join(_TESTCASE_PATH, 'GOOD',
                                'good_building_type.yaml')
         args = [
             '--input', input_file, '--subscription', 'some-subscription'
         ]
         handler.ValidationHelper(args)
Ejemplo n.º 4
0
 def testTelemetryArgsBothSetSuccess(self):
   try:
     input_file = os.path.join(_TESTCASE_PATH, 'GOOD',
                               'good_building_type.yaml')
     args = ['--input', input_file, '--service-account', 'file',
             '--subscription', 'some-subscription']
     handler.ValidationHelper(args)
   except SystemExit:
     self.fail('ValidationHelper:Validate raised ExceptionType unexpectedly!')
Ejemplo n.º 5
0
 def testValidateOneBuildingExist(self):
   try:
     input_file = os.path.join(_TESTCASE_PATH, 'GOOD',
                               'good_building_type.yaml')
     args = ['--input', input_file]
     instance_handler = handler.ValidationHelper(args)
     instance_handler.Validate()
   except SyntaxError:
     self.fail('ValidationHelper:Validate raised ExceptionType unexpectedly!')
Ejemplo n.º 6
0
 def testValidateMultipleInputFilesSuccess(self):
     try:
         input_file1 = path.join(_TESTCASE_PATH, 'GOOD',
                                 'good_building_type.yaml')
         input_file2 = path.join(_TESTCASE_PATH, 'GOOD',
                                 'good_translation_identical.yaml')
         args = ['-i', input_file1, '-i', input_file2]
         instance_handler = handler.ValidationHelper(args)
         instance_handler.Validate()
     except SyntaxError:
         self.fail(
             'ValidationHelper:Validate unexpectedly raised Exception')
# 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
#
#    https://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.
"""Main of the instance validator. This script takes a YAML building
configuration file as an argument and validates it for coherence with the
Digital Buildings ontology.

This is done by first ensuring the file syntax is valid YAML, then by
parsing the ontology and comparing it with the file contents.

This tool allows clients to independently validate their configuration files.
It saves time and provides more accuracy than manual error checks."""

from __future__ import print_function

import sys

from validate import handler

if __name__ == '__main__':
    handler = handler.ValidationHelper(sys.argv[1:])
    handler.Validate()