configurationengine/source/cone/validation/tests/unittest_confmlvalidation.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 unittest
       
    19 import logging
       
    20 
       
    21 ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
       
    22 TESTDATA_DIR = os.path.join(ROOT_PATH, 'testdata')
       
    23 TEMP_DIR = os.path.join(ROOT_PATH, 'temp')
       
    24 
       
    25 from testautomation.base_testcase import BaseTestCase
       
    26 from cone.public import api
       
    27 import cone.validation.confmlvalidation
       
    28 
       
    29 
       
    30 class TestConfmlValidation(BaseTestCase):
       
    31         
       
    32     def _run_single_file_test(self, filename):
       
    33         # Open the file as a configuration
       
    34         prj_dir = os.path.join(TESTDATA_DIR, 'model/confml/single_files')
       
    35         prj = api.Project(api.Storage.open(prj_dir))
       
    36         conf = prj.get_configuration(filename)
       
    37         
       
    38         self.assert_problem_list_equals_expected(
       
    39             actual = cone.validation.confmlvalidation.validate_configuration(conf).problems,
       
    40             expected_file = os.path.join(TESTDATA_DIR, 'model/confml/single_files_expected', filename + '.txt'),
       
    41             outdir = os.path.join(TEMP_DIR, 'confml_model_single_files', filename))
       
    42     
       
    43     def test_validate_min_max_length(self):
       
    44         self._run_single_file_test('min_max_length.confml')
       
    45     
       
    46     def test_validate_data_without_feature(self):
       
    47         self._run_single_file_test('data_without_feature.confml')
       
    48 
       
    49     def test_validate_duplicates(self):
       
    50         self._run_single_file_test('duplicate_root.confml')
       
    51