configurationengine/source/plugins/example/ConeExamplePlugin/examplemlplugin/tests/unittest_exampleml_validation.py
changeset 3 e7e0ae78773e
equal deleted inserted replaced
2:87cfa131b535 3:e7e0ae78773e
       
     1 #
       
     2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Nokia Corporation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description: 
       
    15 #
       
    16 
       
    17 import os
       
    18 import __init__
       
    19 
       
    20 ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
       
    21 
       
    22 from testautomation.base_testcase import BaseTestCase
       
    23 from cone.public import api
       
    24 from cone.validation import schemavalidation, implmlvalidation
       
    25 
       
    26 class TestExamplemlValidation(BaseTestCase):
       
    27     
       
    28     def _run_test(self, filename):
       
    29         filepath = 'Layer1/implml/' + filename
       
    30         project_dir = os.path.join(ROOT_PATH, 'testdata/validation/project')
       
    31         config      = 'root.confml'
       
    32         
       
    33         prj = api.Project(api.Storage.open(project_dir))
       
    34         config = prj.get_configuration(config)
       
    35         problems = implmlvalidation.validate_impls(config, filter=filepath + '$')
       
    36         
       
    37         self.assert_problem_list_equals_expected(
       
    38             actual = problems,
       
    39             expected_file = os.path.join(ROOT_PATH, 'testdata/validation/expected', filename + '.txt'),
       
    40             outdir = os.path.join(ROOT_PATH, 'temp/validation', filename))
       
    41     
       
    42     def test_validate_invalid_refs(self):
       
    43         self._run_test('invalid_refs.exampleml')
       
    44     
       
    45     def test_validate_invalid_encoding(self):
       
    46         self._run_test('invalid_encoding.exampleml')
       
    47 
       
    48 class TestExamplemlSchemaValidation(BaseTestCase, schemavalidation.SchemaValidationTestMixin):
       
    49     NAMESPACE = 'http://www.example.org/xml/exampleml/1'
       
    50     PROBLEM_TYPE = 'schema.implml.exampleml'
       
    51     
       
    52     def test_schemavalidate_exampleml_valid_files(self):
       
    53         self.assert_schemavalidation_succeeds(
       
    54             type = 'implml',
       
    55             dir = os.path.join(ROOT_PATH, 'testdata/validation/schema/valid'),
       
    56             namespace = self.NAMESPACE)
       
    57     
       
    58     def test_schemavalidate_exampleml_invalid_files(self):
       
    59         self.assert_schemavalidation_fails(
       
    60             type = 'implml',
       
    61             dir = os.path.join(ROOT_PATH, 'testdata/validation/schema/invalid'),
       
    62             namespace = self.NAMESPACE,
       
    63             problem_type = self.PROBLEM_TYPE)